回答編集履歴
1
訂正
test
CHANGED
@@ -15,12 +15,6 @@
|
|
15
15
|
const unsigned char SW_PIN[] = { 4,5,6,7,8,9 }; // sw port
|
16
16
|
|
17
17
|
volatile unsigned char sw_flag[ SW_MAX ];
|
18
|
-
|
19
|
-
volatile unsigned char sw_mode = 0;
|
20
|
-
|
21
|
-
volatile unsigned long swa_time ;
|
22
|
-
|
23
|
-
volatile unsigned char swa , swb , swc ;
|
24
18
|
|
25
19
|
volatile unsigned char sw_code = 0;
|
26
20
|
|
@@ -40,7 +34,15 @@
|
|
40
34
|
|
41
35
|
void sw_scan(void){
|
42
36
|
|
37
|
+
static unsigned char sw_mode = 0;
|
38
|
+
|
39
|
+
static unsigned long swa_time ;
|
40
|
+
|
41
|
+
static unsigned char swa , swb , swc ;
|
42
|
+
|
43
43
|
unsigned char i;
|
44
|
+
|
45
|
+
if ( sw_code != 0 ){ return; }
|
44
46
|
|
45
47
|
for ( i=0 ; i<SW_MAX ; i++ ){
|
46
48
|
|
@@ -64,7 +66,7 @@
|
|
64
66
|
|
65
67
|
switch( sw_mode ){
|
66
68
|
|
67
|
-
case 1: if ( i == swa ){ bitSet( sw_code , swa ); sw_mode = 0; } // sw_single
|
69
|
+
case 1: if ( i == swa ){ bitSet( sw_code , swa ); sw_mode = 0; } // sw_single
|
68
70
|
|
69
71
|
break ;
|
70
72
|
|
@@ -106,7 +108,21 @@
|
|
106
108
|
|
107
109
|
void loop() {
|
108
110
|
|
111
|
+
if ( sw_code != 0 ){
|
112
|
+
|
113
|
+
Serial.print("sw_code = ");
|
114
|
+
|
115
|
+
prn_bin( sw_code );
|
116
|
+
|
109
|
-
if ( sw_code
|
117
|
+
if ( sw_code == 0b00000011 ){ Serial.print(" C"); }
|
118
|
+
|
119
|
+
if ( sw_code == 0b00000001 ){ Serial.print(" A"); }
|
120
|
+
|
121
|
+
Serial.println();
|
122
|
+
|
123
|
+
sw_code = 0;
|
124
|
+
|
125
|
+
} // if
|
110
126
|
|
111
127
|
}
|
112
128
|
|
@@ -116,7 +132,7 @@
|
|
116
132
|
|
117
133
|
> Arduino Leonardo !!
|
118
134
|
|
119
|
-
sw_code = 00000001
|
135
|
+
sw_code = 00000001 A
|
120
136
|
|
121
137
|
sw_code = 00000010
|
122
138
|
|
@@ -128,7 +144,7 @@
|
|
128
144
|
|
129
145
|
sw_code = 00100000
|
130
146
|
|
131
|
-
sw_code = 00000011
|
147
|
+
sw_code = 00000011 C
|
132
148
|
|
133
149
|
sw_code = 00000110
|
134
150
|
|