請教一個很小白的問題
剛玩Arduino還在玩LED燈的階段
目前買了LED燈珠來玩霹靂燈玩的還算正常
如下:
void setup() {
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() {
digitalWrite(12,HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(11,HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
digitalWrite(10,HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(9,HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(8,HIGH);
delay(100);
digitalWrite(8, LOW);
delay(100);
digitalWrite(7,HIGH);
delay(100);
digitalWrite(7, LOW);
delay(100);
digitalWrite(6,HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
digitalWrite(5,HIGH);
delay(100);
digitalWrite(5, LOW);
delay(100);
digitalWrite(5,HIGH);
delay(100);
digitalWrite(5, LOW);
delay(100);
digitalWrite(6,HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
digitalWrite(7,HIGH);
delay(100);
digitalWrite(7, LOW);
delay(100);
digitalWrite(8,HIGH);
delay(100);
digitalWrite(8,LOW);
delay(100);
digitalWrite(9,HIGH);
delay(100);
digitalWrite(9, LOW);
delay(100);
digitalWrite(10,HIGH);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(11,HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
digitalWrite(12,HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
}
同時買了紅外線接收與遙控器
已經下載 IRremote裝載在IDE了
只是用IRrecvDemo能遙控一顆燈
所以我修改成如下:
#include <IRremote.h>
IRrecv irrecv(2);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
Serial.println("Enabled IRin");
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
if(results.value==16738455)
{
digitalWrite(2,!digitalRead(12,11,10,9,8,7,6,5,))
}
irrecv.resume(); // Receive the next value
}
delay(100);
}
它卻無法上傳耶
更別玩紅外線遙控霹靂燈
|