2
SKILL
LEVEL
Ringo Educational Guide Rev04.1 ~ Plum Geek
byte
MyData[]={0x00,0xFF,0x1C,0xE3};
//declare this before the loop() function
//this creates a packet of the 4 bytes to
//be sent. This packet is the same as
//pressing the “5” key on the IR remote.
void loop(){
TxIR(MyData,4);
//send the array MyData. The 4 means this is a 4 byte packet
delay(500);
//wait a half second
MyData[2]=0x52; MyData[3]=0xAD;
//change last 2 bytes in array to match
//the “8” key on the remote
TxIR(MyData,4);
delay(500);
//wait a half second
}
void loop(){
TxIRKey(1);
//Send the same packet as pressing the “1” button on the remote
delay(500); //wait a half second
TxIRKey(12);
//Send same packet as pressing the “left arrow” remote button
delay(500); //wait a half second
}
You can send IR data communication using the 3 IR sources. The supplied remote
control sends packets of 4 bytes each time a key is pressed, so it is suggested
that any IR communication use packets containing 4 bytes of data.
You can send a packet several ways.
This code loads 4 values into an array called
MyData
before starting the
loop()
.
The strange numbers are called hexadecimal numbers. (For more info on Arrays,
do a quick google search for “Arduino array” - it’s basically a variable that holds
several values). The
TxIR()
function takes an array as an argument, as well as an
argument saying how long the array is.
TxIR()
actually modulates the IR led light
sources as required to send this packet as if it were a TV remote control. Next,
the last 2 bytes of
MyData
are changed to new values, in this case, to match the
“8” key on the remote.
But there’s an easier way to send commands from Ringo as if Ringo was the IR
remote control. Here’s how.
IR Communication