У меня есть ИК-светодиод, который посылает ИК-сигнал, используя следующий код:
#include <IRremote.h>
IRsend irsend;
const int buttonPin = 8; // the number of the pushbutton pin
//const int ledPin = 3;
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
void loop() {
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(7, HIGH);
irsend.sendNEC(0x1FE08F7, 32);
} else {
digitalWrite(7,LOW);
}
}
Когда я печатаю сигнал с помощью ИК-приемника на другом Arduino, используя код:
#include <IRremote.h>
const int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true);
}
void loop() {
if (irrecv.decode(&results)) {
if (results.decode_type == NEC) {
Serial.print("NEC: ");
} else if (results.decode_type == SONY) {
Serial.print("SONY: ");
} else if (results.decode_type == RC5) {
Serial.print("RC5: ");
} else if (results.decode_type == RC6) {
Serial.print("RC6: ");
} else if (results.decode_type == UNKNOWN) {
Serial.print("UNKNOWN: ");
}
Serial.println(results.value, HEX);
Serial.println(results.value);
irrecv.resume(); // Receive the next value
}
}
Выход последовательного монитора:
UNKNOWN: BDD27AF2
3184687858
UNKNOWN: BDD27AF2
3184687858
UNKNOWN: BDD27AF2
3184687858
1FE
510
1FE
510
NEC: 1FE08F7
33425655
1FE
510
UNKNOWN: BDD27AF2
3184687858
1FE
510
UNKNOWN: BDD27AF2
3184687858
1FE
510
UNKNOWN: BDD27AF2
3184687858
1FE
510
UNKNOWN: BDD27AF2
3184687858
UNKNOWN: BDD27AF2
3184687858
UNKNOWN: BDD27AF2
3184687858
UNKNOWN: BDD27AF2
3184687858
1FE
510
UNKNOWN: BDD27AF2
3184687858
NEC: 1FE08F7
33425655
UNKNOWN: BDD27AF2
3184687858
Вывод не соответствует. Также мой динамик, чей HEX-код я написал, не отвечает ни на один из сигналов. Я ищу эту проблему в течение нескольких часов, но не смог найти никакого решения.
Любая помощь будет оценена по достоинству. Заранее спасибо!