1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
void setup()
{
// set up output pins (4 to 13) for the led array
for( int a = 4; a < 14; a++ )
pinMode( a, OUTPUT );
// set up mode-switch button on pin 3
pinMode( 3, INPUT );
digitalWrite( 3, HIGH );
// pink LED on
digitalWrite( 13, HIGH );
}
// turn an led on/off
void ledOn( int pin, bool on )
{
// pin 4 needs to be inverted (it's driving a PNP)
if( pin == 4 ) on = !on;
digitalWrite( pin, on? HIGH : LOW );
}
void loop()
{
bool on = digitalRead( 3 )? true : false;
for( int a = 4; a < 12; a++ )
ledOn( a, false );
ledOn( 12, on );
delay( 100 );
}
|