Радиоудлиннитель ИК пульта(nRF24l01)
- Войдите на сайт для отправки комментариев
Ср, 24/12/2014 - 23:09
Удлиннитель ИК пульта был собран для известных целей.
Железо:
Ардуино Уно + nRF24l01 + ИК приемник.
Ардуино дуе + nRF24l01 + ИК светодиод.
Код приемника ИК:
#include <IRremote.h>
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include <printf.h>
int RECV_PIN = 4;
RF24 radio(9,10);
IRrecv irrecv(RECV_PIN);
const uint64_t pipe = 0xE8E8F0F0E1LL;
decode_results results;
void setup()
{
Serial.begin(115200);
radio.begin();
radio.setRetries(15, 15);
radio.setChannel(120);
radio.setPayloadSize(32);
radio.powerUp();
radio.startListening();
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_250KBPS);
irrecv.enableIRIn(); // Start the receiver
radio.openWritingPipe(pipe);
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
radio.flush_tx();
radio.write( &results, sizeof(results) );
irrecv.resume(); // Receive the next value
}
delay(100);
}
Код передатчика ИК:
#include <SPI.h> #include "nRF24L01.h" #include "RF24.h" #include "printf.h" #include <OneWire.h> #include <IRremote.h> // Set up nRF24L01 radio on SPI bus plus pins 9 & 10 RF24 radio(9,10); int RECV_PIN = 4; IRrecv irrecv(RECV_PIN); // Single radio pipe address for the 2 nodes to communicate. const uint64_t pipe = 0xE8E8F0F0E1LL; IRsend irsend;//create transmitt object A fixed pin number is always used, depending on which timer the library is utilizing. decode_results results; void check_radio(void); uint32_t F; void setup(void) { Serial.begin(115200); radio.begin(); radio.setRetries(15, 15); radio.setChannel(120); radio.setPayloadSize(32); radio.powerUp(); radio.openReadingPipe(0,pipe); radio.startListening(); radio.setPALevel(RF24_PA_MAX); radio.setDataRate(RF24_250KBPS); attachInterrupt(0, check_radio, FALLING); } void loop(void) { } // Receiver role: Does nothing! All the work is in IRQ void check_radio(void) { // What happened? bool tx,fail,rx; radio.whatHappened(tx,fail,rx); // Did we receive a message? if ( rx ) { radio.read(&results,sizeof(results)); Serial.println(results.value, HEX); irsend.sendNEC(results.value, 32); } }Проверено на телевизоре LG 32lw615v и на ресивере GLOBO HD.
Сигналы повтора кнопки не проходят.
Если будут замечания(код один из первых) буду рад выслушать.