Statistics
| Revision:

root / Ports / examples / input_demo / input_demo.pde

History | View | Annotate | Download (741 Bytes)

1
//>>> The latest version of this code can be found at https://github.com/jcw/ !!
2
3
// Demo for the input plug - read 16 analog input channels once a second
4
// 2010-04-19 <jcw@equi4.com> http://opensource.org/licenses/mit-license.php
5
// $Id: input_demo.pde 7763 2011-12-11 01:28:16Z jcw $
6
7
#include <Ports.h>
8
#include <RF12.h> // needed to avoid a linker error :(
9
10
InputPlug input (1);
11
12
void setup () {
13
    Serial.begin(57600);
14
    Serial.println("\n[input_demo]");
15
    
16
    input.mode2(INPUT);
17
    input.digiWrite2(1); // pull-up, not a good idea in normal use
18
}
19
20
void loop () {
21
    Serial.print("INPUT");
22
    for (byte i = 0; i < 16; ++i) {
23
        input.select(i);
24
        Serial.print(' ');
25
        Serial.print(input.anaRead());
26
    }
27
    Serial.println();
28
        
29
    delay(1000);
30
}