def send(data): light.init() t = light.get_data() s = str(t) b = bytearray(s) print("send light data:", b) lora.send_data(b, len(b), lora.frame_counter)
def create(): render = G.render light.init(render) dir_light = light.add_directional(render) amb_light = light.add_ambient(render) G.cameraSelection = 0 G.lightSelection = 0 G.dir_light = dir_light G.amb_light = amb_light
def init(): #Temperature use Analog pin 1 temperature.init() #LED use Digital pin 13 led.init() #Light is on I2C, doesn't use a specific pin light.init() #Sound uses A0 Grove Port sound.init() #LCD is on I2C, doesn't use a specific pin lcd.init() lcd.setRGB(0,255,0) #Air Quality is on Analog Pin 1 air_quality.init() #Led bar is on pin D8, uses pin 8 and 9 led_bar.init()
import os import time import sound import feeds import streams import shutters import light import paho.mqtt.client as mqtt sound.startup() try: client = mqtt.Client() shutters.init(client) light.init(client) client.connect("iemxblog.fr", 1883, 60) client.loop_start() except Exception as e: print(e) sound.failure() sound.failure() sound.failure() stack = [] while True: l = input("> ") try: if l.isdecimal(): sound.click() stack.append(int(l))
def init(): "Initializes the global variables" GPIO.cleanup() #definition of the switches global switch1 switch1 = 19 global switch2 switch2 = 26 switch.init(switch1) switch.init(switch2) #definition of the buttons global button1 button1 = 2 global button2 button2 = 3 global button3 button3 = 4 global button4 button4 = 17 global button5 button5 = 27 global button6 button6 = 22 global startButton startButton = 6 #List of the buttons global buttonList buttonList = [button1,button2,button3,button4,button5,button6] button.init(startButton) for buttonNo in buttonList: button.init(buttonNo) # definition of the lights global light1 light1 = 20 global light2 light2 = 21 global light3 light3 = 18 global light4 light4 = 23 global light5 light5 = 24 global light6 light6 = 10 global readylight readylight = 13 #List of the lights global lightList lightList = [light1,light2,light3,light4,light5,light6] for lightNo in lightList: light.init(lightNo) light.init(readylight) #definition of the buzzers global buzzer1 buzzer1 = 9 global buzzer2 buzzer2 = 25 global buzzer3 buzzer3 = 11 global buzzer4 buzzer4 = 8 global buzzer5 buzzer5 = 7 global buzzer6 buzzer6 = 5 #List of the buzzers global buzzerList buzzerList = [buzzer1,buzzer2,buzzer3,buzzer4,buzzer5,buzzer6] for buzzerNo in buzzerList: buzzer.init(buzzerNo)
import light import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) try: print("Here we go") light.init() print("Initialized!") #inf.key_scan() print("key scanned!") while True: #There is obstacle, the indicator light of the infrared obstacle avoidance module is on, and the port level is LOW #There is no obstacle, the indicator light of the infrared obstacle avoidance module is off, and the port level is HIGH LeftSensorValue = GPIO.input(light.LdrSensorLeft); RightSensorValue = GPIO.input(light.LdrSensorRight); print("LeftSensorValue is", LeftSensorValue) print("RightSensorValue is", RightSensorValue) time.sleep(0.002) except KeyboardInterrupt: pass GPIO.cleanup()
#!/usr/bin/env python from light import init, writeByte, cleanup import sys, time, random if __name__ == "__main__": init() try: while (True): byte = random.randint(1, 255) writeByte(byte) time.sleep(0.1) except KeyboardInterrupt: writeByte(0xff) cleanup()
#!/usr/bin/env python from light import init, writeByte, cleanup import sys, time if __name__ == '__main__': init(6, 19, 13) for item in sys.argv[1:]: writeByte(int(item)) time.sleep(1) cleanup()
def init(): "Initializes the global variables" GPIO.cleanup() #definition of the switches global switch1 switch1 = 19 global switch2 switch2 = 26 switch.init(switch1) switch.init(switch2) #definition of the buttons global button1 button1 = 2 global button2 button2 = 3 global button3 button3 = 4 global button4 button4 = 17 global button5 button5 = 27 global button6 button6 = 22 global startButton startButton = 6 #List of the buttons global buttonList buttonList = [button1, button2, button3, button4, button5, button6] button.init(startButton) for buttonNo in buttonList: button.init(buttonNo) # definition of the lights global light1 light1 = 20 global light2 light2 = 21 global light3 light3 = 18 global light4 light4 = 23 global light5 light5 = 24 global light6 light6 = 10 global readylight readylight = 13 #List of the lights global lightList lightList = [light1, light2, light3, light4, light5, light6] for lightNo in lightList: light.init(lightNo) light.init(readylight) #definition of the buzzers global buzzer1 buzzer1 = 9 global buzzer2 buzzer2 = 25 global buzzer3 buzzer3 = 11 global buzzer4 buzzer4 = 8 global buzzer5 buzzer5 = 7 global buzzer6 buzzer6 = 5 #List of the buzzers global buzzerList buzzerList = [buzzer1, buzzer2, buzzer3, buzzer4, buzzer5, buzzer6] for buzzerNo in buzzerList: buzzer.init(buzzerNo)