/* * 8sw.c: * Test program for GPIO 28,29,30,31 LED and Button board * Gordon Henderson * * The board is laid out as follows: * * LEDs: ( 17) (18) (19) (20) (17) (18) (19) (20) * * Switches: [0] [ 1] [ 2] [ 3] * [4] [ 5] [ 6] [ 7] * * Numbers here are wiringPi pin numbers and will work on either * a Rev1 or Rev2 Raspberry Pi * *********************************************************************** */ #include #include static int leds [8] = { 17, 18, 19, 20, 20, 19, 18, 17 } ; static int buttons [8] = { 0, 1, 2, 3, 4, 5, 6 ,7 } ; int main () { int i ; if (wiringPiSetup () < 0) { fprintf (stderr, "Unable to initialise wiringPi\n") ; return 1 ; } for (i = 0 ; i < 8 ; ++i) { pinMode (leds [i], OUTPUT) ; pinMode (buttons [i], INPUT) ; digitalWrite (leds [i], LOW) ; pullUpDnControl (buttons [i], PUD_UP) ; } for (;;) for (i = 0 ; i < 8 ; ++i) digitalWrite (leds [i], !digitalRead (buttons [i])) ; }