print("Yellow is on") time.sleep(3) led.turn_on(led.yellow) if led.isOn(led.yellow): print("Yellow is on") else : print("Yellow is off") time.sleep(2) led.turn_off(led.yellow) time.sleep(1) print("Green and blue switch") #the led.switch(led) function knows whether an led is on or off and switches its value led.turn_on(led.green) time.sleep(3) led.switch(led.green) led.switch(led.blue) time.sleep(2.2) led.switch(led.blue) time.sleep(1.4) print("If switch is on, press yellow for yellow and red for red") #the btn.isOn(btn) function tells you if a particular button is being pressed or if a switch is on #your choices for buttons are currently btn.red, btn.yellow, btn.switch while btn.isOn(btn.switch) : if btn.isOn(btn.yellow): led.switch(led.purple) if btn.isOn(btn.red) : led.switch(led.blue) time.sleep(0.25) #this line keeps it from querying too fast and mistaking a long press for multiple presses
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()
print("Blue is off") time.sleep(2) led.turn_on(led.blue) if led.isOn(led.blue): print("Yellow is on") else : print("Blue is off") time.sleep(5) led.turn_off(led.blue) time.sleep(9) print("Green and purple switch") #the led.switch(led) function knows whether an led is on or off and switches its value led.turn_on(led.green) time.sleep(3) led.switch(led.green) led.switch(led.purple) time.sleep(1) led.switch(led.purple) time.sleep(2) print("If switch is on, press orange for orange and purple for purple") #the btn.isOn(btn) function tells you if a particular button is being pressed or if a switch is on #your choices for buttons are currently btn.orange, btn.blue, btn.switch while btn.isOn(btn.switch) : if btn.isOn(btn.red): led.switch(led.orange) if btn.isOn(btn.yellow) : led.switch(led.purple) time.sleep(0.50) #this line keeps it from querying too fast and mistaking a long press for multiple presses
time.sleep(2) led.turn_on(led.yellow) if led.isOn(led.yellow): print("Yellow is on") else: print("Yellow is off") time.sleep(2) led.turn_off(led.yellow) time.sleep(1) print("Green and blue switch") #the led.switch(led) function knows whether an led is on or off and switches its value # same led choices led.turn_on(led.green) time.sleep(2) led.switch(led.green) led.switch(led.blue) time.sleep(2) led.switch(led.blue) time.sleep(1) print("Blink") #the led.blink(led, number_of_times, seconds_between_blinks) blinks an led on and off # default is (led.white, 5, 0.25) led.blink() #blinks the white led 5 times for 0.25 seconds led.blink( led.purple, 50, 0.01 ) #blinks the purple led 50 times in 1 second (1/100 of a second pulse length) print("If switch is on, press yellow for yellow and red for red") #the btn.isOn(btn) function tells you if a particular button is being pressed or if a switch is on
print("Yellow is on") time.sleep(3) led.turn_on(led.yellow) if led.isOn(led.yellow): print("Yellow is on") else: print("Yellow is off") time.sleep(2) led.turn_off(led.yellow) time.sleep(1) print("Green and blue switch") #the led.switch(led) function knows whether an led is on or off and switches its value led.turn_on(led.green) time.sleep(3) led.switch(led.green) led.switch(led.blue) time.sleep(2.2) led.switch(led.blue) time.sleep(1.4) print("If switch is on, press yellow for yellow and red for red") #the btn.isOn(btn) function tells you if a particular button is being pressed or if a switch is on #your choices for buttons are currently btn.red, btn.yellow, btn.switch while btn.isOn(btn.switch): if btn.isOn(btn.yellow): led.switch(led.purple) if btn.isOn(btn.red): led.switch(led.blue) time.sleep( 0.25
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()