Phil Howard | 6577b7e | 2016-03-09 12:19:22 +0000 | [diff] [blame] | 1 | import wiringpi |
Philip Howard | fa09d18 | 2013-04-01 21:11:00 +0000 | [diff] [blame] | 2 | INPUT = 0 |
| 3 | OUTPUT = 1 |
| 4 | LOW = 0 |
| 5 | HIGH = 1 |
| 6 | BUTTONS = [13,12,10,11] |
| 7 | LEDS = [0,1,2,3,4,5,6,7,8,9] |
| 8 | PUD_UP = 2 |
| 9 | |
| 10 | wiringpi.wiringPiSetup() |
| 11 | |
| 12 | for button in BUTTONS: |
| 13 | wiringpi.pinMode(button,INPUT) |
| 14 | wiringpi.pullUpDnControl(button,PUD_UP) |
| 15 | |
| 16 | for led in LEDS: |
| 17 | wiringpi.pinMode(led,OUTPUT) |
| 18 | |
| 19 | while 1: |
| 20 | for index,button in enumerate(BUTTONS): |
| 21 | button_state = wiringpi.digitalRead(button) |
| 22 | first_led = LEDS[index*2] |
| 23 | second_led = LEDS[(index*2)+1] |
| 24 | #print str(button) + ' ' + str(button_state) |
| 25 | wiringpi.digitalWrite(first_led,1-button_state) |
| 26 | wiringpi.digitalWrite(second_led,1-button_state) |
| 27 | wiringpi.delay(20) |