質問編集履歴
4
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
この2つを同じ意味合いにしていますがコンパイルは通り動作が違います‼️
|
2
2
|
|
3
|
-
|
3
|
+
どこをどのように変えればいいですか?
|
4
4
|
|
5
|
+
|
6
|
+
|
5
|
-
|
7
|
+
動作成功
|
6
8
|
|
7
9
|
```Arduino
|
8
10
|
|
@@ -13,30 +15,6 @@
|
|
13
15
|
#include<util/delay.h>
|
14
16
|
|
15
17
|
const uint8_t tempo = 100; /*記憶*/
|
16
|
-
|
17
|
-
//1
|
18
|
-
|
19
|
-
uint8_t notes [2] [50] = {"gdefedccegfeddefgecc facbagdgfeddefgecc n",
|
20
|
-
|
21
|
-
"afgefdc afgeegba n"}; /* 音の速度 スペースは休憩を表します*/
|
22
|
-
|
23
|
-
uint8_t level [2] [50] = {{4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0,
|
24
|
-
|
25
|
-
4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0},
|
26
|
-
|
27
|
-
{4, 4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 0}};/*音の高さ*/
|
28
|
-
|
29
|
-
uint8_t beat [2] [50] = {{ 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2+1,
|
30
|
-
|
31
|
-
2, 1, 2, 1, 1, 3, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2},
|
32
|
-
|
33
|
-
{4, 4, 4, 4, 4, 4, 4, 4+1, 4, 4, 4, 4, 2, 2, 4, 4, 4}};/*ビート*/
|
34
|
-
|
35
|
-
uint8_t line [] = {0,0,1};/*行*/
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
18
|
|
41
19
|
void playTone(uint16_t tone, uint16_t duration) {
|
42
20
|
|
@@ -66,377 +44,11 @@
|
|
66
44
|
|
67
45
|
}
|
68
46
|
|
69
|
-
|
70
|
-
|
71
|
-
void playNote(uint8_t note, uint16_t level, uint16_t duration) {
|
72
|
-
|
73
|
-
uint8_t names[] = {'c', 'd', 'e', 'f', 'g', 'a', 'b'}; //ドレミファソラシ
|
74
|
-
|
75
|
-
uint16_t tones[] = { 19111, 17026, 15169 + 1, 14317, 12755, 11364, 10124};
|
76
|
-
|
77
|
-
/*
|
78
|
-
|
79
|
-
/ *
|
80
|
-
|
81
|
-
timeHigh =期間/ 2 = 1 /(2 * toneFrequency)
|
82
|
-
|
83
|
-
ここで、さまざまなトーンは次のように説明されています。
|
84
|
-
|
85
|
-
音符 頻度 期間 高い時間
|
86
|
-
|
87
|
-
do4 261.63 Hz 3830 1911.0958223445323548522722929328 (261->1915=1915.7088122605363984674329501916)
|
88
|
-
|
89
|
-
re4 293.66 Hz 3400 1702.6493223455697064632568276238 (294->1700=1700.6802721088435374149659863946)
|
90
|
-
|
91
|
-
mi4 329.63 Hz 3038 1516.8522282559233079513393805175 (329->1519=1519.7568389057750759878419452888)
|
92
|
-
|
93
|
-
fa4 349.23 Hz 2864 1431.7212152449674999284139392378 (349->1432=1432.6647564469914040114613180516)
|
94
|
-
|
95
|
-
so4 392 Hz 2550 1275=1275.5102040816326530612244897959
|
96
|
-
|
97
|
-
ra4 440 Hz 2272 1136=1136.3636363636363636363636363636
|
98
|
-
|
99
|
-
si4 493.88 Hz 2028 1012.3916740908722766663966955536 (493->1014=1014.1987829614604462474645030426)
|
100
|
-
|
101
|
-
do5 523.25 Hz 1912 955.566172957477305303392259914 (523->956=956.02294455066921606118546845124)
|
102
|
-
|
103
|
-
*/
|
104
|
-
|
105
|
-
/*音名に対応した音を再生します*/
|
106
|
-
|
107
|
-
for (uint8_t i = 0; i < 7; i++) {
|
108
|
-
|
109
|
-
if (note == names[i]) {
|
110
|
-
|
111
|
-
uint8_t a = level - 4;
|
112
|
-
|
113
|
-
playTone(tones[i] / pow(2, a), duration);
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
}
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
return;
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
void setup(){
|
128
|
-
|
129
|
-
DDRC = 0x0000001; /* 出力:ブザー(PORTC0)*/
|
130
|
-
|
131
|
-
DDRB = 0x00; /*入力:スィッチ(PINB5)*//* <iom328.h> #define PINB5 5*/
|
132
|
-
|
133
|
-
DDRD = 0x7F; /* DDRB 出力ピン対応ビットはセット、入力ピン対応ビットはクリア */
|
134
|
-
|
135
|
-
PORTD = 0xFF; /* 入力ピンに対応するビットに1を書き込み、内蔵プルアップ指定 */
|
136
|
-
|
137
|
-
DDRB = 0x00; /* I/ o:key(PORT0-7)*/
|
138
|
-
|
139
|
-
PORTB = 0xFF; /* 入力時にプルアップする必要があります。*/
|
140
|
-
|
141
|
-
}
|
142
|
-
|
143
|
-
void loop(){
|
144
|
-
|
145
|
-
static bool a_mode = 0; /*0-手動、1-自動*/
|
146
|
-
|
147
|
-
main_loop:
|
148
|
-
|
149
|
-
if (bit_is_clear(PORTD, PORTD7)) /* スイッチが閉じると成立 */
|
150
|
-
|
151
|
-
PORTB = PORTB & ~_BV(PB1); /* ここではPD0をクリアしてLED点灯 */
|
152
|
-
|
153
|
-
if (a_mode) { //auto(PIND == 0b00100000)
|
154
|
-
|
155
|
-
DDRB = 0xff; //出力のみ
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
for (uint8_t i = 0; i < 3; i++) { /*行数*/
|
160
|
-
|
161
|
-
for (uint8_t j = 0; ; j++) {
|
162
|
-
|
163
|
-
if (notes[line[i]][j] == ' ') {
|
164
|
-
|
165
|
-
for (uint16_t k = 0; k < beat[line[i]][j] * tempo; k++) {
|
166
|
-
|
167
|
-
_delay_ms(1); //rest(milli)
|
168
|
-
|
169
|
-
}
|
170
|
-
|
171
|
-
}
|
172
|
-
|
173
|
-
else if (notes[line[i]][j] == 'n') { /*(j <length [i])の場合、for {}は続行します。*/
|
174
|
-
|
175
|
-
break;
|
176
|
-
|
177
|
-
}
|
178
|
-
|
179
|
-
else{
|
180
|
-
|
181
|
-
uint8_t k;
|
182
|
-
|
183
|
-
if (notes[line[i]][j] == 'c') {
|
184
|
-
|
185
|
-
if (level[line[i]][j] == 4) {
|
186
|
-
|
187
|
-
k = 0;
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
else {
|
192
|
-
|
193
|
-
k = 7;
|
194
|
-
|
195
|
-
}
|
196
|
-
|
197
|
-
}
|
198
|
-
|
199
|
-
else if (notes[line[i]][j] == 'a') {
|
200
|
-
|
201
|
-
k = 5;
|
202
|
-
|
203
|
-
}
|
204
|
-
|
205
|
-
else if (notes[line[i]][j] == 'b') {
|
206
|
-
|
207
|
-
k = 6;
|
208
|
-
|
209
|
-
}
|
210
|
-
|
211
|
-
else {
|
212
|
-
|
213
|
-
for (k = 0; k < 5; k++) {
|
214
|
-
|
215
|
-
if (notes[line[i]][j] == 'c' + k) {
|
216
|
-
|
217
|
-
break;
|
218
|
-
|
219
|
-
}
|
220
|
-
|
221
|
-
}
|
222
|
-
|
223
|
-
}
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
PORTD ^= _BV(k);
|
228
|
-
|
229
|
-
playNote(notes[line[i]][j], level[line[i]][j], beat[line[i]][j] * tempo);
|
230
|
-
|
231
|
-
PORTD ^= _BV(k);
|
232
|
-
|
233
|
-
}//if
|
234
|
-
|
235
|
-
if (!(PINB & _BV(5))) { //auto(PINB is 0x00)
|
236
|
-
|
237
|
-
a_mode = 0;
|
238
|
-
|
239
|
-
goto main_loop;
|
240
|
-
|
241
|
-
}
|
242
|
-
|
243
|
-
}//for
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
}//for
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
}//auto
|
252
|
-
|
253
|
-
else { /*手動(PIND == 0x00)*/
|
254
|
-
|
255
|
-
DDRB = 0x00; /*入力のみ*/
|
256
|
-
|
257
|
-
PORTB = 0xff; /*プルアップ*/
|
258
|
-
|
259
|
-
switch (PINB) {
|
260
|
-
|
261
|
-
case 0b11111110:
|
262
|
-
|
263
|
-
do {
|
264
|
-
|
265
|
-
playNote('c', 4, 1 * tempo);
|
266
|
-
|
267
|
-
} while (PINB == 0b11111110);
|
268
|
-
|
269
|
-
break;
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
case 0b11111101:
|
274
|
-
|
275
|
-
do {
|
276
|
-
|
277
|
-
playNote('d', 4, 1 * tempo);
|
278
|
-
|
279
|
-
} while (PINB == 0b11111101);
|
280
|
-
|
281
|
-
break;
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
case 0b11111011:
|
286
|
-
|
287
|
-
do {
|
288
|
-
|
289
|
-
playNote('e', 4, 1 * tempo);
|
290
|
-
|
291
|
-
} while (PINB == 0b11111011);
|
292
|
-
|
293
|
-
break;
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
case 0b11110111:
|
298
|
-
|
299
|
-
do {
|
300
|
-
|
301
|
-
playNote('f', 4, 1 * tempo);
|
302
|
-
|
303
|
-
} while (PINB == 0b11110111);
|
304
|
-
|
305
|
-
break;
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
case 0b11101111:
|
310
|
-
|
311
|
-
do {
|
312
|
-
|
313
|
-
playNote('g', 4, 1 * tempo);
|
314
|
-
|
315
|
-
} while (PINB == 0b11101111);
|
316
|
-
|
317
|
-
break;
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
case 0b11011111:
|
322
|
-
|
323
|
-
do {
|
324
|
-
|
325
|
-
playNote('a', 4, 1 * tempo);
|
326
|
-
|
327
|
-
} while (PINB == 0b11011111);
|
328
|
-
|
329
|
-
break;
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
case 0b10111111:
|
334
|
-
|
335
|
-
do {
|
336
|
-
|
337
|
-
playNote('b', 4, 1 * tempo);
|
338
|
-
|
339
|
-
} while (PINB == 0b10111111);
|
340
|
-
|
341
|
-
break;
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
case 0b01111111:
|
346
|
-
|
347
|
-
do {
|
348
|
-
|
349
|
-
playNote('c', 5, 1 * tempo);
|
350
|
-
|
351
|
-
} while (PINB == 0b01111111);
|
352
|
-
|
353
|
-
break;
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
default:
|
358
|
-
|
359
|
-
break;
|
360
|
-
|
361
|
-
}
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
if (PINB & _BV(5)) { //manual(PINB is 0x20)
|
366
|
-
|
367
|
-
a_mode = 1;
|
368
|
-
|
369
|
-
}
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
}/*マニュアル*/
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
}
|
378
|
-
|
379
47
|
```
|
380
48
|
|
381
|
-
|
49
|
+
動作失敗
|
382
50
|
|
383
|
-
```Arduino
|
384
|
-
|
385
|
-
include <avr/io.h>
|
386
|
-
|
387
|
-
#include <avr/interrupt.h>
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
51
|
+
※このプログラムを動作同じにしていくこと
|
392
|
-
|
393
|
-
{
|
394
|
-
|
395
|
-
PORTB=0x01; // LED点灯(High)
|
396
|
-
|
397
|
-
}
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
ISR(TIM0_COMP_vect)
|
402
|
-
|
403
|
-
{
|
404
|
-
|
405
|
-
PORTB=0x00; // LED消灯(Low)
|
406
|
-
|
407
|
-
}
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
int main(void)
|
412
|
-
|
413
|
-
{
|
414
|
-
|
415
|
-
PORTB=0x00;
|
416
|
-
|
417
|
-
DDRB=0x01; //PORTB0 出力/Lowに。Highで点灯するようLEDを接続
|
418
|
-
|
419
|
-
TCNT0=0;
|
420
|
-
|
421
|
-
OCR0=38; // TCNT0=39の瞬間に比較一致成立。39*1024/4MHz≒10msec.
|
422
|
-
|
423
|
-
TIFR=_BV(OCF0)|_BV(TOV0); //OCF0/TOV0クリア
|
424
|
-
|
425
|
-
TIMSK=_BV(TOIE0)|_BV(OCIE0); //オーバーフロー・比較一致割り込み許可
|
426
|
-
|
427
|
-
TCCR0=5; // プリスケーラ 1/1024 タイマが動き出す
|
428
|
-
|
429
|
-
sei(); // 全割り込み許可
|
430
|
-
|
431
|
-
while(1);
|
432
|
-
|
433
|
-
}
|
434
|
-
|
435
|
-
```
|
436
|
-
|
437
|
-
試したこと
|
438
|
-
|
439
|
-
参考プログラムのledをブザーに置換えたけどエラーが発生しました。
|
440
52
|
|
441
53
|
```Arduino
|
442
54
|
|
@@ -446,114 +58,44 @@
|
|
446
58
|
|
447
59
|
#include<util/delay.h>
|
448
60
|
|
61
|
+
#include <avr/interrupt.h>
|
62
|
+
|
449
63
|
const uint8_t tempo = 100; //char
|
450
64
|
|
451
65
|
const byte PIN_BUZZLE = 10;
|
452
66
|
|
453
|
-
const byte PIN_INTERRUPT =
|
67
|
+
const byte PIN_INTERRUPT = 23;
|
454
68
|
|
455
|
-
volatile byte state = L
|
69
|
+
volatile byte state = LOW;
|
456
70
|
|
457
|
-
|
71
|
+
void playTone(uint16_t tone, uint16_t duration) {
|
458
72
|
|
459
|
-
|
73
|
+
pinMode( PIN_BUZZLE, OUTPUT );
|
460
74
|
|
461
|
-
|
75
|
+
digitalWrite( PIN_BUZZLE, state );
|
76
|
+
|
77
|
+
|
462
78
|
|
463
79
|
attachInterrupt(
|
464
80
|
|
465
|
-
digitalPinToInterrupt(PIN_INTERRUPT,
|
81
|
+
digitalPinToInterrupt(PIN_INTERRUPT),
|
82
|
+
|
83
|
+
toggle_BUZZLE, FALLING );
|
466
84
|
|
467
85
|
}
|
468
86
|
|
469
|
-
|
470
|
-
|
471
|
-
|
87
|
+
void duration() {
|
472
88
|
|
473
89
|
digitalWrite( PIN_BUZZLE, state );
|
474
90
|
|
91
|
+
}
|
92
|
+
|
93
|
+
void toggle_BUZZLE(){
|
94
|
+
|
475
95
|
state != state;
|
476
96
|
|
477
|
-
|
97
|
+
_delay_us(1);
|
478
98
|
|
479
|
-
}
|
99
|
+
}
|
480
|
-
|
481
|
-
return;
|
482
|
-
|
483
|
-
}
|
484
|
-
|
485
|
-
void setup()
|
486
|
-
|
487
|
-
{
|
488
|
-
|
489
|
-
/*
|
490
|
-
|
491
|
-
DDRx:Set i/o. 0->input, 1->output. When input, must pullup. cf.mega88A.pdf:14.2.3. "入出力間の切り替え"
|
492
|
-
|
493
|
-
PORTx:write only
|
494
|
-
|
495
|
-
PINx:read only
|
496
|
-
|
497
|
-
*/
|
498
|
-
|
499
|
-
DDRC = 0b0000001; //output:buzzer(PORTC0)
|
500
|
-
|
501
|
-
DDRB = 0x00; //input:switch(PINB5) //<iom328.h>#define PINB5 5
|
502
|
-
|
503
|
-
PORTB = 0xff; //When input, must pullup.
|
504
|
-
|
505
|
-
DDRD = 0x00; //i/o:key(PORT0-7)
|
506
|
-
|
507
|
-
PORTD = 0xff; //When input, must pullup.
|
508
|
-
|
509
|
-
//タイマ0,CTC,割り込み用、比較A一致で割り込み
|
510
|
-
|
511
|
-
TCCR0A = 0b00000010;
|
512
|
-
|
513
|
-
TCCR0B = 0b00000011; // N=64
|
514
|
-
|
515
|
-
OCR0A = 78; // 5msごとに割り込み
|
516
|
-
|
517
|
-
TIMSK0 = 0b0000010; //比較A一致割り込み有効
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
//方向レジスタの設定
|
524
|
-
|
525
|
-
DDRC = 0xff; //Cを出力
|
526
|
-
|
527
|
-
DDRD = 0xff; //Dを出力
|
528
|
-
|
529
|
-
PORTB = 0xff;
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
//割り込み許可
|
534
|
-
|
535
|
-
sei();
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
while(1){}
|
540
|
-
|
541
|
-
}
|
542
|
-
|
543
|
-
|
544
100
|
|
545
101
|
```
|
546
|
-
|
547
|
-
エラー
|
548
|
-
|
549
|
-
```Arduino
|
550
|
-
|
551
|
-
error: macro "digitalPinToInterrupt" passed 3 arguments, but takes just 1
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
exit status 1
|
556
|
-
|
557
|
-
macro "digitalPinToInterrupt" passed 3 arguments, but takes just 1
|
558
|
-
|
559
|
-
```
|
3
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,9 +6,15 @@
|
|
6
6
|
|
7
7
|
```Arduino
|
8
8
|
|
9
|
+
#define F_CPU 8000000UL
|
10
|
+
|
11
|
+
#include<avr/io.h>
|
12
|
+
|
13
|
+
#include<util/delay.h>
|
14
|
+
|
9
15
|
const uint8_t tempo = 100; /*記憶*/
|
10
16
|
|
11
|
-
|
17
|
+
//1
|
12
18
|
|
13
19
|
uint8_t notes [2] [50] = {"gdefedccegfeddefgecc facbagdgfeddefgecc n",
|
14
20
|
|
@@ -372,11 +378,11 @@
|
|
372
378
|
|
373
379
|
```
|
374
380
|
|
375
|
-
参考
|
381
|
+
参考プログラム
|
376
382
|
|
377
383
|
```Arduino
|
378
384
|
|
379
|
-
|
385
|
+
include <avr/io.h>
|
380
386
|
|
381
387
|
#include <avr/interrupt.h>
|
382
388
|
|
@@ -431,3 +437,123 @@
|
|
431
437
|
試したこと
|
432
438
|
|
433
439
|
参考プログラムのledをブザーに置換えたけどエラーが発生しました。
|
440
|
+
|
441
|
+
```Arduino
|
442
|
+
|
443
|
+
#define F_CPU 8000000UL
|
444
|
+
|
445
|
+
#include<avr/io.h>
|
446
|
+
|
447
|
+
#include<util/delay.h>
|
448
|
+
|
449
|
+
const uint8_t tempo = 100; //char
|
450
|
+
|
451
|
+
const byte PIN_BUZZLE = 10;
|
452
|
+
|
453
|
+
const byte PIN_INTERRUPT =PORTC ;
|
454
|
+
|
455
|
+
volatile byte state = Low:
|
456
|
+
|
457
|
+
//1
|
458
|
+
|
459
|
+
void playTone(uint16_t tone, uint16_t duration) {
|
460
|
+
|
461
|
+
for (uint32_t i = 0; i < duration * 1000L; i += tone * 2 / 10) {
|
462
|
+
|
463
|
+
attachInterrupt(
|
464
|
+
|
465
|
+
digitalPinToInterrupt(PIN_INTERRUPT, toggle_temp, FALLING );
|
466
|
+
|
467
|
+
}
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
void toggle_temp(){
|
472
|
+
|
473
|
+
digitalWrite( PIN_BUZZLE, state );
|
474
|
+
|
475
|
+
state != state;
|
476
|
+
|
477
|
+
}
|
478
|
+
|
479
|
+
}
|
480
|
+
|
481
|
+
return;
|
482
|
+
|
483
|
+
}
|
484
|
+
|
485
|
+
void setup()
|
486
|
+
|
487
|
+
{
|
488
|
+
|
489
|
+
/*
|
490
|
+
|
491
|
+
DDRx:Set i/o. 0->input, 1->output. When input, must pullup. cf.mega88A.pdf:14.2.3. "入出力間の切り替え"
|
492
|
+
|
493
|
+
PORTx:write only
|
494
|
+
|
495
|
+
PINx:read only
|
496
|
+
|
497
|
+
*/
|
498
|
+
|
499
|
+
DDRC = 0b0000001; //output:buzzer(PORTC0)
|
500
|
+
|
501
|
+
DDRB = 0x00; //input:switch(PINB5) //<iom328.h>#define PINB5 5
|
502
|
+
|
503
|
+
PORTB = 0xff; //When input, must pullup.
|
504
|
+
|
505
|
+
DDRD = 0x00; //i/o:key(PORT0-7)
|
506
|
+
|
507
|
+
PORTD = 0xff; //When input, must pullup.
|
508
|
+
|
509
|
+
//タイマ0,CTC,割り込み用、比較A一致で割り込み
|
510
|
+
|
511
|
+
TCCR0A = 0b00000010;
|
512
|
+
|
513
|
+
TCCR0B = 0b00000011; // N=64
|
514
|
+
|
515
|
+
OCR0A = 78; // 5msごとに割り込み
|
516
|
+
|
517
|
+
TIMSK0 = 0b0000010; //比較A一致割り込み有効
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
//方向レジスタの設定
|
524
|
+
|
525
|
+
DDRC = 0xff; //Cを出力
|
526
|
+
|
527
|
+
DDRD = 0xff; //Dを出力
|
528
|
+
|
529
|
+
PORTB = 0xff;
|
530
|
+
|
531
|
+
|
532
|
+
|
533
|
+
//割り込み許可
|
534
|
+
|
535
|
+
sei();
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
while(1){}
|
540
|
+
|
541
|
+
}
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
```
|
546
|
+
|
547
|
+
エラー
|
548
|
+
|
549
|
+
```Arduino
|
550
|
+
|
551
|
+
error: macro "digitalPinToInterrupt" passed 3 arguments, but takes just 1
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
exit status 1
|
556
|
+
|
557
|
+
macro "digitalPinToInterrupt" passed 3 arguments, but takes just 1
|
558
|
+
|
559
|
+
```
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -372,7 +372,9 @@
|
|
372
372
|
|
373
373
|
```
|
374
374
|
|
375
|
+
参考
|
376
|
+
|
375
|
-
```Arduino
|
377
|
+
```Arduino
|
376
378
|
|
377
379
|
#include <avr/io.h>
|
378
380
|
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
※ピン番号は変えないで行うこと
|
6
6
|
|
7
|
-
``Arduino
|
7
|
+
```Arduino
|
8
8
|
|
9
9
|
const uint8_t tempo = 100; /*記憶*/
|
10
10
|
|