#!/usr/bin/python import time import fox # Create an istance on Daisy11 class to refer the L1 led myled = fox.Daisy11('D2', 'L1') # Create an istance on Daisy5 class to refer the P1 push button mybutton = fox.Daisy5('D5', 'P1') # Never ending loop while True: # If mybutton (P1) is pressed... if mybutton.pressed(): # ...turn on myled (L1) myled.on() else: # ... if not turn off it myled.off()
#!/usr/bin/python #Read the state of each button on Daisy-5 #when wired on D5 connecor #http://www.acmesystems.it/DAISY-5 import time import fox # Create an istance for each button P1 = fox.Daisy5('D5', 'P1') P2 = fox.Daisy5('D5', 'P2') P3 = fox.Daisy5('D5', 'P3') P4 = fox.Daisy5('D5', 'P4') P5 = fox.Daisy5('D5', 'P5') P6 = fox.Daisy5('D5', 'P6') P7 = fox.Daisy5('D5', 'P7') P8 = fox.Daisy5('D5', 'P8') while True: if (P1.pressed()): print "P1 pressed" if (P2.pressed()): print "P2 pressed" if (P3.pressed()): print "P3 pressed" if (P4.pressed()): print "P4 pressed" if (P5.pressed()):
#Commento di prova def check_button(button,led): while True: if button.pressed(): led.on() else: led.off() time.sleep(0.1) def timed_led(button,led,delay): while True: if button.pressed(): led.on() time.sleep(delay) led.off() myled = fox.Daisy11('D2','L1') mybutton = fox.Daisy5('D5','P1') myled_2 = fox.Daisy11('D2','L2') mybutton_2 = fox.Daisy5('D5','P2') thread.start_new_thread(check_button,(mybutton,myled)) thread.start_new_thread(timed_led,(mybutton_2,myled_2,5)) loop_counter=0 while True: print "loop # " , loop_counter loop_counter += 1 time.sleep(1)
# Tests the first bits in input for Daisy18 # Daisy18 module wired on D2 connector Mon1 = fox.Daisy11('D2', 'L1') Mon2 = fox.Daisy11('D2', 'L2') Mon3 = fox.Daisy11('D2', 'L3') Mon4 = fox.Daisy11('D2', 'L4') Act18 = fox.Daisy11('D2', 'L8') Act19 = fox.Daisy11('D2', 'L7') MonOk = fox.Daisy11('D2', 'L6') MonErr = fox.Daisy11('D2', 'L5') SlowTest = fox.Daisy5('D3', 'P5') SelD18 = fox.Daisy5('D3', 'P7') SelD19 = fox.Daisy5('D3', 'P8') testD18 = False testD19 = False selTest = True blinkOn = True testDelay = 0.1 print "Select Test : " while selTest: if blinkOn: Mon1.on()