Nejduležitější je mít modul Arduino a starý polofunkční ovladač.
Vložtedo složky "C:\Program Files (x86)\Arduino\libraries" knihovny.
Knihovny
Připojte arduino a nahrajte do něj.
IR přijímač
#include <IRremote.h> const int RECV_PIN = 6; 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.print(" "); Serial.print(results.value, HEX); Serial.print(" "); Serial.println(results.bits); irrecv.resume(); // Receive the next value } }
Zapojení pinů.
Arduino NANO:
IR-LED =D3
IR-senzor =D6
Tlačítko1 =D4
Arduino UNO:
IR-LED =3
IR-senzor =6
Tlačítko1 =4
Je třeba zapnout Seriový monitor(Ctrl+Shift+M) a tam se zobrazí Hex kod daného tlačítka.
A ten Hex je třeba přeložit do Decimalu.
Př:
Hex: 30AF907F
Decimal: 816812159
Je třeba si vitvořit svůj ovladač.
Přepsat decimal v kodu pro ovladač dají se přidat i další tlačítka.
IR vysílač
#include <IRremote.h>
#include "LowPower.h"
IRsend irsend;
const int button1 = 4;
const int button2 = 5;
const int button3 = 6;
int timer;
void wakeUp()
{
timer = 0;
}
void setup()
{
// put your setup code here, to run once:
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(button3, INPUT);
timer = 0;
}
void loop()
{
attachInterrupt(0, wakeUp, HIGH);
while(timer < 3000)
{
// put your main code here, to run repeatedly:
if (digitalRead(button1) == HIGH)
{
timer = 0;
delay(50);
irsend.sendNEC(551522415, 32); //Vol+
}
if (digitalRead(button2) == HIGH)
{
timer = 0;
delay(50);
irsend.sendNEC(551522415, 32); //Vol+
}
if (digitalRead(button3) == HIGH)
{
timer = 0;
delay(50);
irsend.sendNEC(551522415, 32); //Vol+
}
delay(1);
timer = timer +1;
}
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
}
Dá se udělat i přijímač stačí v něm přepsat decimal kod, kterí je na ovladači daného tlačítka.
IR Přijímač
Zdroje:
http://www.instructables.com/id/How-to-Add-an-IR-Remote-to-a-Speaker-System/
https://circuitdigest.com/microcontroller-projects/universal-ir-remote-control-using-arduino-android