- Notifications
You must be signed in to change notification settings - Fork 211
/
Copy pathSwitchInputs.ino
46 lines (35 loc) · 851 Bytes
/
SwitchInputs.ino
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
36
37
38
39
40
41
42
43
44
45
46
/*
SwitchInputs
For info and circuit diagrams see https://github.com/tardate/LittleArduinoProjects/tree/master/playground/SwitchInputs
*/
constint pinA = 2;
constint pinA_led = 3;
constint pinB = 4;
constint pinB_led = 5;
constint pinC = 6;
constint pinC_led = 7;
/*
* Command: one-time setup
*/
voidsetup() {
pinMode(pinA, INPUT);
pinMode(pinA_led, OUTPUT);
pinMode(pinB, INPUT);
pinMode(pinB_led, OUTPUT);
pinMode(pinC, INPUT_PULLUP);
pinMode(pinC_led, OUTPUT);
}
/*
* Command: main loop
*/
voidloop() {
static boolean pinA_state;
static boolean pinB_state;
static boolean pinC_state;
pinA_state = digitalRead(pinA);
digitalWrite(pinA_led, pinA_state);
pinB_state = digitalRead(pinB);
digitalWrite(pinB_led, pinB_state);
pinC_state = digitalRead(pinC);
digitalWrite(pinC_led, pinC_state);
}