File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ void setup () {
2+ // put your setup code here, to run once:
3+ Serial.begin (9600 );
4+
5+ pinMode (13 , OUTPUT);
6+ pinMode (12 , OUTPUT);
7+ pinMode (11 , OUTPUT);
8+
9+ pinMode (5 , INPUT);
10+ pinMode (7 , INPUT);
11+
12+ }
13+
14+ void loop () {
15+ // put your main code here, to run repeatedly:
16+
17+ for (byte i = 0 ; i < 8 ; i++){
18+ bool A = false ;
19+ bool B = false ;
20+ bool C = false ;
21+
22+ switch (i) {
23+ case 0 : C = false ; B = false ; A = false ; break ;
24+ case 1 : C = true ; B = false ; A = false ; break ;
25+ case 2 : C = false ; B = true ; A = false ; break ;
26+ case 3 : C = true ; B = true ; A = false ; break ;
27+ case 4 : C = false ; B = false ; A = true ; break ;
28+ case 5 : C = true ; B = false ; A = true ; break ;
29+ case 6 : C = false ; B = true ; A = true ; break ;
30+ case 7 : C = true ; B = true ; A = true ; break ;
31+ }
32+
33+ out (A,B,C);
34+ delay (1500 );
35+ Serial.print (i);
36+ Serial.print (" : " );
37+ Serial.print (digitalRead (5 ));
38+ Serial.print (" ," );
39+ Serial.print (digitalRead (7 ));
40+ Serial.print (" ," );
41+ Serial.println (analogRead (0 ));
42+ delay (1500 );
43+
44+
45+
46+ }
47+
48+ }
49+
50+ void out (bool A, bool B, bool C) {
51+ if (A) {
52+ digitalWrite (13 , HIGH);
53+ } else {
54+ digitalWrite (13 , LOW);
55+ }
56+
57+ if (B) {
58+ digitalWrite (12 , HIGH);
59+ } else {
60+ digitalWrite (12 , LOW);
61+ }
62+
63+ if (C) {
64+ digitalWrite (11 , HIGH);
65+ } else {
66+ digitalWrite (11 , LOW);
67+ }
68+ }
You can’t perform that action at this time.
0 commit comments