Esempio n. 1
0
 def __init__(self, brokerIp=None, brokerPort=1883, topic=None):
     self.__brokerIp = brokerIp
     self.__brokerPort = brokerPort
     self.__topic = topic
     # mqtt의 Client 객체 생성
     self.__client = mqtt.Client()
     # 콜백 함수 설정
     self.__client.on_connect = self.__on_connect
     self.__client.on_disconnect = self.__on_disconnect
     # 메시지를 받았을때 자동을 호출되는 콜백함수
     self.__client.on_message = self.__on_message
     # 센서 객체 생성
     self.rgbLed = RgbLed(redpin=16, greenpin=18, bluepin=22)
     self.pca9685 = Pca9685()
     self.buzzer = ActiveBuzzer(35)
     self.laser = Laser(37)
     self.laser2 = Laser(29)
     self.sg90direction = Sg90(self.pca9685, channel=15)
     self.sg90sensor = Sg90(self.pca9685, channel=14)
     self.sg90camera_vertical = Sg90(self.pca9685, channel=13)
     self.sg90camera_horizontal = Sg90(
         self.pca9685, channel=8)  #12번인데 지금 개박살나서 8번으로 비활성화 해놨어요
     self.lcd1602 = Lcd1602(0x27)
     # 서보모터 각도 고정값
     self.camera_angle_vertical = 10
     self.camera_angle_horizontal = 70
     self.direction_angle = 90
     self.sensor_angle = 70
 def __init__(self, brokerIp=None, brokerPort=1883, topic=None):
     self.__brokerIp = brokerIp
     self.__brokerPort = brokerPort
     self.__topic = topic
     self.__client = mqtt.Client()
     self.__client.on_connect = self.__on_connect
     self.__client.on_disconnect = self.__on_disconnect
     self.__client.on_message = self.__on_message
     self.pca9685 = Pca9685()
     self.dcMotorL = DCMotor(IN1=11, IN2=12, pca9685=self.pca9685, pwm=5)
     self.dcMotorR = DCMotor(IN1=13, IN2=15, pca9685=self.pca9685, pwm=4)
     self.sg90direction = Sg90(self.pca9685, channel=15)
     self.sg90sensor = Sg90(self.pca9685, channel=14)
     self.sg90camera_vertical = Sg90(self.pca9685, channel=13)
     self.sg90camera_horizontal = Sg90(self.pca9685, channel=8)
     # 속도 정보가 저장되는 싱글톤 객체 생성
     self.singletonSpeed = SingletonSpeed()
     # 모터의 기본 속도 정의
     self.motorspeed = 0
     self.camera_angle_vertical = 10
     self.camera_angle_horizontal = 70
     self.direction_angle = 90
     self.sensor_angle = 70
     self.laser1 = Laser(37)
     self.laser2 = Laser(29)
     self.buzzer = ActiveBuzzer(35)
     self.rgbLed = RgbLed(redpin=16, greenpin=18, bluepin=22)
     self.checkStatus = False
Esempio n. 3
0
 def __init__(self, trigpin=None, echopin=None):
     self.__trigpin = trigpin
     self.__echopin = echopin
     GPIO.setmode(GPIO.BOARD)
     GPIO.setwarnings(False)
     GPIO.setup(trigpin, GPIO.OUT)
     GPIO.setup(echopin, GPIO.IN)
     self.buzzer = ActiveBuzzer(35)
Esempio n. 4
0
 def __init__(self):
     self.pcf8591 = Pcf8591(0x48)
     self.pca9685 = Pca9685()
     self.buzzer = ActiveBuzzer(35)
     self.dcmotor = DcMotor(self.pca9685)
     self.gas = Gas(self.pcf8591, ain=2)  # 클래스 생성자에서 스레드 생성
     self.hcsr = HcSr04(trigpin=40, echopin=38)  # 클래스 생성자에서 스레드 생성
     self.laser = Laser(37)
     self.photo = Photoresistor(self.pcf8591, 0)  # 클래스 생성자에서 스레드 생성
     self.led = RgbLed(redpin=16, greenpin=18, bluepin=22)
     self.servo1 = Sg90(self.pca9685, 0)  # 카메라 서보1
     self.servo2 = Sg90(self.pca9685, 1)  # 카메라 서보2
     self.servo3 = Sg90(self.pca9685, 8)  # 초음파 서보
     self.servo4 = Sg90(self.pca9685, 9)  # 앞바퀴 서보
     self.thermistor = Thermistor(self.pcf8591, 1)  # 클래스 생성자에서 스레드 생성
     self.tracker = Tracker(32)  # 클래스 생성자에서 스레드 생성
     self.lcd = Lcd1602(0x27)
Esempio n. 5
0
 def __init__(self, pcf8591, ain):
     self.__pcf8591 = pcf8591
     self.__ain = ain
     self.buzzer = ActiveBuzzer(35)
     self.rgbLed = RgbLed(redpin=16)
Esempio n. 6
0
class Gas:
    def __init__(self, pcf8591, ain):
        self.__pcf8591 = pcf8591
        self.__ain = ain
        self.buzzer = ActiveBuzzer(35)
        self.rgbLed = RgbLed(redpin=16)

    def read(self):
        value = self.__pcf8591.read(self.__ain)
        if value > 205:
            self.buzzer.on()
            self.rgbLed.red()
        else:
            self.buzzer.off()
            self.rgbLed.off()
        return value


if __name__ == '__main__':
    try:
        pcf8591 = Pcf8591(0x48)
        gas = Gas(pcf8591, ain=2)
        buzzer = ActiveBuzzer(35)
        led = RgbLed(redpin=16)
        while True:
            value = gas.read()
            print('value: {}'.format(value))
            time.sleep(1)
    finally:
        print('Program Exit')