/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock
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
32
33
34
35
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 num, bool on )
{
	if( num < 0 || num > 9 ) return;

	// convert to pin no.
	num += 4;

	// pin 4 needs to be inverted (it's driving a PNP)
	if( num == 4 ) on = !on;

	digitalWrite( num, on? HIGH : LOW );
}

void loop()
{
	bool on = true;//digitalRead( 3 )? true : false;
	for( int a = 0; a < 9; a++ )
		ledOn( a, on );
	delay( 1000 );
}