import tempsensor import time import btnlib as btn import ledlib as led red = 80 orange = 75 yellow = 70 green = 65 blue = 60 purple = 55 while btn.isOn(btn.switch): #while the switch is on: led.turn_on(led.white) temp = tempsensor.tempF() #get the temp print temp if temp > red: led.turn_on_all() elif temp > orange: led.turn_off(led.red) led.turn_on(led.orange) led.turn_on(led.yellow) led.turn_on(led.green) led.turn_on(led.blue) led.turn_on(led.purple) elif temp > yellow: led.turn_off(led.red) led.turn_off(led.orange) led.turn_on(led.yellow) led.turn_on(led.green) led.turn_on(led.blue)
import tempsensor import time import btnlib as btn import ledlib as led last_temp = 70 while btn.isOn(btn.switch): #while the switch is on: temp = tempsensor.tempF() #get the temp if temp > last_temp: #if it's gotten warmer print "Warmer" if led.isOn(led.blue): led.turn_off(led.blue) #turn off blue if led.isOn(led.yellow): led.turn_off(led.yellow) #turn off yellow led.turn_on(led.red) #turn on red elif temp == last_temp: #if it's the same print "Same" if led.isOn(led.blue): led.turn_off(led.blue) #turn off blue if led.isOn(led.red): led.turn_off(led.red) #turn off red led.turn_on(led.yellow) #turn on yellow elif temp < last_temp: #if it's cooler print "Cooler" if led.isOn(led.red): led.turn_off(led.red) #turn off red if led.isOn(led.yellow): led.turn_off(led.yellow) #turn off yellow led.turn_on(led.blue) #turn on blue last_temp = temp #set the new temp
import tempsensor import time import btnlib as btn import ledlib as led last_temp = 70 while btn.isOn(btn.switch): #while the switch is on: temp = tempsensor.tempF() #get the temp if temp > last_temp : #if it's gotten warmer print "Warmer" if led.isOn(led.blue) : led.turn_off(led.blue) #turn off blue if led.isOn(led.yellow) : led.turn_off(led.yellow) #turn off yellow led.turn_on(led.red) #turn on red elif temp == last_temp : #if it's the same print "Same" if led.isOn(led.blue) : led.turn_off(led.blue) #turn off blue if led.isOn(led.red) : led.turn_off(led.red) #turn off red led.turn_on(led.yellow) #turn on yellow elif temp < last_temp : #if it's cooler print "Cooler" if led.isOn(led.red) : led.turn_off(led.red) #turn off red if led.isOn(led.yellow) : led.turn_off(led.yellow) #turn off yellow led.turn_on(led.blue) #turn on blue last_temp = temp #set the new temp
if btn.isOn(btn.yellow): # if yellow and red it pressed laser.on(); time.sleep(0.10); laser.off(); time.sleep(0.10); else: #if read button pressed without yellow led.blink(led.red, 50, 0.1); led.blink(led.orange, 50, 0.1); led.blink(led.yellow, 50, 0.1); led.blink(led.green, 50, 0.1); led.blink(led.blue, 50, 0.1); led.blink(led.purple, 50, 0.1); led.blink(); if btn.isOn(btn.yellow): while(sam == 0): led.turn_on(led.red); led.turn_on(led.yellow); led.turn_on(led.blue); led.turn_on(led.white); time.sleep(3); sam = 1; led.switch(lcd.red); led.switch(lcd.orange); led.switch(lcd.yellow); led.switch(lcd.green); led.switch(lcd.blue); led.switch(lcd.purple); led.switch(lcd.white); print "Goodbye" btn.GPIO.cleanup()
#the led.startup() function cycles through the leds led.startup() time.sleep(1) print("All on and off") #to turn on all leds, use the led.turn_on_all(2) function: led.turn_on_all() time.sleep(2) #to turn off all: led.turn_off_all() time.sleep(1) print("Red on and off") #to turn on a single led, use a command like this: led.turn_on(led.red) #your choices for leds are led.red, led.yellow, led.green, led.blue time.sleep(2) #to turn it off: led.turn_off(led.red) time.sleep(1) print("Yellow with isOn test") #the led.isOn(led) function tells you if a particular led is currently on if led.isOn(led.yellow): print("Yellow is on") else : print("Yellow is on") time.sleep(3) led.turn_on(led.yellow) if led.isOn(led.yellow):
#the following lines will allow you to use buttons and leds import btnlib as btn import ledlib as led import time #led.startup() while btn.isOn(btn.switch): led.turn_on_all() time.sleep(1) led.turn_off_all() led.turn_on(led.green) time.sleep(1) led.turn_on(led.blue) time.sleep(.5) led.turn_on(led.purple) time.sleep(.5) led.turn_on(led.red) time.sleep(.2) led.turn_on_all() time.sleep(1) led.turn_on(led.blue) time.sleep(.2) led.turn_on(led.blue) time.sleep(.2) led.turn_on(led.blue) time.sleep(.2) led.turn_on(led.blue) time.sleep(.5) led.turn_off_all() led.blink(led.purple, 7, .3)
#the led.startup() function cycles through the leds led.startup() time.sleep(1) print("All on and off") #to turn on all leds, use the led.turn_on_all() function: led.turn_on_all() time.sleep(2) #to turn off all: led.turn_off_all() time.sleep(1) print("Orange on and off") #to turn on a single led, use a command like this: led.turn_on(led.orange) #your choices for leds are led.orange, led.blue, led.green, led.red time.sleep(2) #to turn it off: led.turn_off(led.orange) time.sleep(1) print("Blue with isOn test") #the led.isOn(led) function tells you if a particular led is currently on if led.isOn(led.blue): print("Blue is on") else : print("Blue is off") time.sleep(2) led.turn_on(led.blue) if led.isOn(led.blue):
#the following lines will allow you to use buttons and leds import btnlib as btn import ledlib as led import time #led.startup() while btn.isOn(btn.switch) : led.turn_on_all() time.sleep(1) led.turn_off_all() led.turn_on(led.green) time.sleep(1) led.turn_on(led.blue) time.sleep(.5) led.turn_on(led.purple) time.sleep(.5) led.turn_on(led.red) time.sleep(.2) led.turn_on_all() time.sleep(1) led.turn_on(led.blue) time.sleep(.2) led.turn_on(led.blue) time.sleep(.2) led.turn_on(led.blue) time.sleep(.2) led.turn_on(led.blue) time.sleep(.5) led.turn_off_all() led.blink(led.purple, 7, .3)
#the led.startup() function cycles through the leds led.startup() time.sleep(1) print("All on and off") #to turn on all leds, use the led.turn_on_all() function: led.turn_on_all() time.sleep(2) #to turn off all: led.turn_off_all() time.sleep(1) print("Red on and off") #to turn on a single led, use a command like this: led.turn_on(led.red) #your choices for leds are led.red, led.orange, led.yellow, # led.green, led.blue, led.purple, and led.white time.sleep(2) #to turn it off: led.turn_off(led.red) time.sleep(1) print("Yellow with isOn test") #the led.isOn(led) function tells you if a particular led is currently on # same led choices if led.isOn(led.yellow): print("Yellow is on") else: print("Yellow is off") time.sleep(2)
import tempsensor import time import btnlib as btn import ledlib as led red = 80 orange = 75 yellow = 70 green = 65 blue = 60 purple = 55 while btn.isOn(btn.switch): #while the switch is on: led.turn_on(led.white) temp = tempsensor.tempF() #get the temp print temp if temp > red : led.turn_on_all() elif temp > orange : led.turn_off(led.red) led.turn_on(led.orange) led.turn_on(led.yellow) led.turn_on(led.green) led.turn_on(led.blue) led.turn_on(led.purple) elif temp > yellow : led.turn_off(led.red) led.turn_off(led.orange) led.turn_on(led.yellow) led.turn_on(led.green) led.turn_on(led.blue)
led.startup() time.sleep(1) print("All on and off") #to turn on all leds, use the led.turn_on_all(2) function: led.turn_on_all() time.sleep(1) #to turn off all: led.turn_off_all() time.sleep(1) print("Red on and off") #to turn on a single led, use a command like this: led.turn_on(led.blue) #your choices for leds are led.red, led.yellow, led.green, led.blue time.sleep(2) #to turn it off: led.turn_off(led.red) time.sleep(1) print("Yellow with isOn test") #the led.isOn(led) function tells you if a particular led is currently on if led.isOn(led.yellow): print("Yellow is on") else : print("Yellow is on") time.sleep(1) led.turn_on(led.yellow)
if btn.isOn(btn.yellow): # if yellow and red it pressed laser.on() time.sleep(0.10) laser.off() time.sleep(0.10) else: #if read button pressed without yellow led.blink(led.red, 50, 0.1) led.blink(led.orange, 50, 0.1) led.blink(led.yellow, 50, 0.1) led.blink(led.green, 50, 0.1) led.blink(led.blue, 50, 0.1) led.blink(led.purple, 50, 0.1) led.blink() if btn.isOn(btn.yellow): while (sam == 0): led.turn_on(led.red) led.turn_on(led.yellow) led.turn_on(led.blue) led.turn_on(led.white) time.sleep(3) sam = 1 led.switch(lcd.red) led.switch(lcd.orange) led.switch(lcd.yellow) led.switch(lcd.green) led.switch(lcd.blue) led.switch(lcd.purple) led.switch(lcd.white) print "Goodbye" btn.GPIO.cleanup()