質問編集履歴
1
やったことにたいする追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -11,6 +11,44 @@
|
|
11
11
|
### やっていること
|
12
12
|
スケッチ例→Rotary-Master→Interrupt
|
13
13
|
をArduino leonaldoに書き込んだ
|
14
|
+
```ここに言語を入力
|
15
|
+
/*
|
16
|
+
Rotary Encoder - Interrupt Example
|
17
|
+
|
18
|
+
The circuit:
|
19
|
+
* encoder pin A to Arduino pin 2
|
20
|
+
* encoder pin B to Arduino pin 3
|
21
|
+
* encoder ground pin to ground (GND)
|
22
|
+
*/
|
23
|
+
|
24
|
+
#include <Rotary.h>
|
25
|
+
|
26
|
+
Rotary r = Rotary(2, 3);
|
27
|
+
void setup() {
|
28
|
+
Serial.begin(9600);
|
29
|
+
r.begin();
|
30
|
+
PCICR |= (1 << PCIE2);
|
31
|
+
PCMSK2 |= (1 << PCINT18) | (1 << PCINT19);
|
32
|
+
sei();
|
33
|
+
}
|
34
|
+
|
35
|
+
void loop() {
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
ISR(PCINT2_vect) {
|
40
|
+
unsigned char result = r.process();
|
41
|
+
if (result == DIR_NONE) {
|
42
|
+
// do nothing
|
43
|
+
}
|
44
|
+
else if (result == DIR_CW) {
|
45
|
+
Serial.println("ClockWise");
|
46
|
+
}
|
47
|
+
else if (result == DIR_CCW) {
|
48
|
+
Serial.println("CounterClockWise");
|
49
|
+
}
|
50
|
+
}
|
51
|
+
```
|
14
52
|
|
15
53
|
### エラーの内容
|
16
54
|
書き込みをする際に
|
@@ -22,6 +60,20 @@
|
|
22
60
|
|
23
61
|
### エラー解決のためにやったこと
|
24
62
|
PCIE2,PCINTが定義されていないという内容なので
|
63
|
+
こちらの[サイト](https://garchiving.com/external-interrupts-with-arduino/)を参考に
|
64
|
+
```ここに言語を入力
|
65
|
+
PCICR |= (1 << PCIE2);
|
66
|
+
PCMSK2 |= (1 << PCINT18) | (1 << PCINT19);
|
67
|
+
```
|
68
|
+
の部分を
|
69
|
+
```ここに言語を入力
|
70
|
+
PCICR |= B00000100;
|
71
|
+
PCMSK2 |= B00001000|B00000100;
|
72
|
+
```
|
73
|
+
と書き換えてみましたが
|
74
|
+
```ここに言語を入力
|
75
|
+
'PCMSK2' was not declared in this scope
|
25
76
|
|
77
|
+
```
|
78
|
+
と表示され、いまいち解決できそうにありません。
|
26
79
|
|
27
|
-
|