/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock
43 by edam
added phantom button press test and temporarily disabled pin 4 (that drives the PNP transistor)
1
void setup()
2
{
3
	// set up output pins (4 to 13) for the led array
4
	for( int a = 4; a < 14; a++ )
5
		pinMode( a, OUTPUT );
6
7
	// set up mode-switch button on pin 3
8
	pinMode( 3, INPUT );
9
	digitalWrite( 3, HIGH );
10
11
	// pink LED on
12
	digitalWrite( 13, HIGH );
13
}
14
15
// turn an led on/off
51 by edam
only one led comes on
16
void ledOn( int pin, bool on )
43 by edam
added phantom button press test and temporarily disabled pin 4 (that drives the PNP transistor)
17
{
18
	// pin 4 needs to be inverted (it's driving a PNP)
51 by edam
only one led comes on
19
	if( pin == 4 ) on = !on;
43 by edam
added phantom button press test and temporarily disabled pin 4 (that drives the PNP transistor)
20
51 by edam
only one led comes on
21
	digitalWrite( pin, on? HIGH : LOW );
43 by edam
added phantom button press test and temporarily disabled pin 4 (that drives the PNP transistor)
22
}
23
24
void loop()
25
{
51 by edam
only one led comes on
26
	bool on = digitalRead( 3 )? true : false;
27
	for( int a = 4; a < 12; a++ )
28
		ledOn( a, false );
29
	ledOn( 12, on );
30
	delay( 100 );
43 by edam
added phantom button press test and temporarily disabled pin 4 (that drives the PNP transistor)
31
}