/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to test/phantom-button-presses/main.ino

  • Committer: edam
  • Date: 2012-02-08 23:32:34 UTC
  • Revision ID: edam@waxworlds.org-20120208233234-4h5pzeetrz0vp91f
added phantom button press test and temporarily disabled pin 4 (that drives the PNP transistor)

Show diffs side-by-side

added added

removed removed

 
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
 
16
void ledOn( int num, bool on )
 
17
{
 
18
        if( num < 0 || num > 9 ) return;
 
19
 
 
20
        // convert to pin no.
 
21
        num += 4;
 
22
 
 
23
        // pin 4 needs to be inverted (it's driving a PNP)
 
24
        if( num == 4 ) on = !on;
 
25
 
 
26
        digitalWrite( num, on? HIGH : LOW );
 
27
}
 
28
 
 
29
void loop()
 
30
{
 
31
        bool on = true;//digitalRead( 3 )? true : false;
 
32
        for( int a = 0; a < 9; a++ )
 
33
                ledOn( a, on );
 
34
        delay( 1000 );
 
35
}