Exemple #1
0
	def setInstance(self, GPIO):
		print("set Instance")
		if self.useSensor[0] :
			self.sensorTimerControl.append(DHT11.Control(self.all_pin[0], GPIO, self.topic, [0, 1]))
			self.sensorTimerControlIndex.append(0)
			self.sensorTimerControlIndex.append(1)
		if self.useSensor[1] :
			self.sensorDetectControl.append(Fire.Control(self.all_pin[1], GPIO, self.topic, 0))
			self.sensorDetectControlIndex.append(0)
		if self.useSensor[2] :
			self.sensorDetectControl.append(Shock.Control(self.all_pin[4], GPIO, self.topic, 1))
			self.sensorDetectControlIndex.append(1)
		if self.useSensor[3] :
			self.sensorDetectControl.append(IR.Control(self.all_pin[5], GPIO, self.topic, 2))
			self.sensorDetectControlIndex.append(2)
		if self.useSensor[4] :
			self.sensorDetectControl.append(Gas.Control(self.adc_pin[0], self.topic, 3))
			self.sensorDetectControlIndex.append(3)
		if self.useSensor[5] :
			self.sensorTimerControl.append(Cds.Control(self.all_pin[7], GPIO, self.topic, 2))
			self.sensorTimerControlIndex.append(2)
		if self.useSensor[6] :
			self.button_instance = Button.Control(self.all_pin[6], GPIO, self.topic)
		if self.useSensor[7] :
			self.led_instance = LED.LED(self.all_pin[2], self.all_pin[3], GPIO)
			self.led_instance.write(1)
		if self.useSensor[8] :
			self.sensorMoveControl.append(SG90.SG90(self.all_pin[8], self.all_pin[9], GPIO))
		if self.useSensor[9] :
			self.sensorTimerControl.append(PM2008M.Control(self.topic,[3, 4]))
			self.sensorTimerControlIndex.append(3)
			self.sensorTimerControlIndex.append(4)
		if self.useSensor[10] :		
			self.sensorTimerControl.append(Sound.Control(self.adc_pin[1], GPIO, self.topic, 5))
			self.sensorTimerControlIndex.append(5)
Exemple #2
0
def run():
    sound = Sound.Control(0)
    while True:
        data = sound.dataConvt()
        print(data)