Stap 4: El código nl Arduino
Afschriften las kunt líneas o descargue el código desde aca y carguelo Arduino.
#include "< \IrRemote.h\ >";
IRsend ir;
int estado = 0;
char de dato;
Deze codes zijn voor het beheersen van het audiosysteem
unsigned int powerEquipo [32] = {300,750,300,1800,300,700,350,700,350,1750,350,700,300,1800,250,1800,350,700,300,1800,350,700,300,700,350,700,350,1750,300,750,300}; unsigned int chEmisoraUp [32] = {300,750,300,750,300,1750,250,800,300,750,300,750,250,800,300,750,250,1800,250,1850,300,750,250,800,200,800,300,1800,300,750,300}; unsigned int chEmisoraUp [32] = {300,750,300,750,300,1800,200,850,300,750,250,750,300,750,300,750,300,1800,300,1750,300,750,300,750,300,750,300,1800,250,750,300}; unsigned int chEmisoraDown [32] = {350,700,400,650,300,1750,350,700,350,700,350,700,300,750,300,700,350,700,300,750,350,1750,400,650,300,700,350,1750,300,750,300}; unsigned int playCd [32] = {400,650,400,650,350,1750,350,700,350,650,350,1750,350,1750,300,1750,400,1700,350,1750,350,700,350,650,400,650,350,1750,450,600,350}; These codes are for controlling the Tv unsigned int pwrTv[68]={4600,4350,700,1550,650,1550,650,1600,650,450,650,450,650,450,650,450,700,400,700,1550,650,1550,650,1600,650,450,650,450,650,450,700,450,650,450,650,450,650,1550,700,450,650,450,650,450,650,450,650,450,700,400,650,1600,650,450,650,1550,650,1600,650,1550,650,1550,700,1550,650,1550,650}; volume up unsigned int volUpTv[68]={4600,4350,650,1550,700,1500,700,1550,700,400,700,400,700,450,650,450,700,400,700,1500,700,1550,650,1550,700,400,700,400,700,450,650,450,700,400,700,1500,700,1550,650,1550,700,400,700,450,700,400,700,400,700,400,700,450,650,450,650,450,650,1550,700,1500,700,1550,700,1500,700,1550,650}; volume down unsigned int volDownTv[68]={4600,4350,700,1550,650,1550,700,1500,700,450,650,450,700,400,700,400,700,400,700,1550,700,1500,700,1550,700,400,700,400,700,400,700,450,650,450,650,1550,700,1500,700,450,650,1550,700,400,700,400,700,450,700,400,700,400,700,400,700,1550,700,400,700,1500,700,1500,700,1550,700,1500,700}; channel up unsigned int chUpTv[68]={4600,4350,700,1500,700,1500,700,1550,700,450,650,400,700,450,650,450,700,400,700,1500,700,1550,650,1550,700,450,650,450,700,400,700,400,700,400,700,400,700,1550,700,400,700,400,700,1550,650,450,700,400,700,400,700,1550,650,450,650,1600,650,1550,650,450,700,1500,700,1500,700,1550,650}; channel down unsigned int chDownTv[68]={4650,4300,700,1550,700,1500,700,1550,700,400,700,400,700,400,700,450,650,450,650,1550,700,1500,700,1550,700,400,700,400,700,400,700,450,700,400,700,400,700,400,700,450,650,450,650,1550,700,400,700,450,650,400,700,1550,700,1500,700,1550,700,1500,700,400,700,1550,650,1550,700,1500,700}; Tv/Video unsigned int videoTv[68]={4500,4300,650,1600,650,1550,650,1600,650,500,600,500,650,500,650,500,650,500,600,1650,600,1600,650,1550,650,500,650,500,650,500,600,500,650,500,650,1600,600,500,650,500,650,500,650,500,600,550,600,500,650,500,650,500,650,1550,650,1600,650,1550,650,1600,650,1550,650,1600,650,1550,650}; VOID Setup
{
Serial.begin(9600);
}
void loop
{
if(Serial.available() > 0)
{dato=Serial.read();
schakelaar (dato)
{
Case 'R':
ir.sendRaw(powerEquipo,32,38);
delay(500);
breken;
'T geval ':
ir.sendRaw(chEmisoraUp,32,38);
delay(100);
breken;
Case 'U':
ir.sendRaw(chEmisoraDown,32,38);
delay(100);
breken;
Case "V":
ir.sendRaw(playCd,32,38);
delay(100);
breken;
geval van "K": //Power de TV
ir.sendRaw(pwrTv,68,38);
delay(100);
breken;
geval 'L': //Volume +
ir.sendRaw(volUpTv,68,38);
delay(100);
breken; geval ben ': /
/ Volume-
ir.sendRaw(volDownTv,68,38);
delay(100);
breken;
geval 'N': //Channel +
ir.sendRaw(chUpTv,68,38);
delay(100);
breken;
geval ' o ': //Channel -
ir.sendRaw(chDownTv,68,38);
delay(100);
breken;
kast 'P': / / Tv/Video
ir.sendRaw(videoTv,68,38);
delay(100);
breken;
Case "A":
for (int i = 0; ik < 3; i ++)
{ir.sendNEC (0xFF30CF, 32); / / Power DVD
delay(40);
}
breken;
Case "B":
for (int i = 0; ik < 3; i ++)
{
ir.sendNEC (0xFF00FF, 32); Openen/sluiten van de cd-lade
delay(40);
}
breken;
Case "C":
for (int i = 0; ik < 3; i ++)
{
ir.sendNEC (0xFF52AD, 32); Cd afspelen
delay(40);
}
breken;
geval zou ':
for (int i = 0; ik < 3; i ++)
{
ir.sendNEC (0xFF728D, 32); Stop
delay(40);
}
breken;
} / / fin del schakelaar}
Fin del als
} //fin del lus