Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass
Created May 9, 2020 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffersGlass/0d167d5033b9db5e4e6707fb6d262700 to your computer and use it in GitHub Desktop.
Save JeffersGlass/0d167d5033b9db5e4e6707fb6d262700 to your computer and use it in GitHub Desktop.
/* rawSend.ino Example sketch for IRLib2
* Illustrates how to send a code Using raw timings which were captured
* from the "rawRecv.ino" sample sketch. Load that sketch and
* capture the values. They will print in the serial monitor. Then you
* cut and paste that output into the appropriate section below.
*/
#include <IRLibSendBase.h> //We need the base code
#include <IRLib_HashRaw.h> //Only use raw sender
IRsendRaw mySender;
void setup() {
Serial.begin(9600);
while (!Serial); //delay for Leonardo
Serial.println(F("Every time you press a key is a serial monitor we will send."));
}
/* Cut and paste the output from "rawRecv.ino" below here. It will
* consist of a #define RAW_DATA_LEN statement and an array definition
* beginning with "uint16_t rawData[RAW_DATA_LEN]= {…" and concludes
* with "…,1000};"
*/
const int dataLenOnOff = 78;
uint16_t rawDataOnOff[dataLenOnOff]={
4510, 4514, 510, 502, 506, 502, 506, 502,
506, 506, 506, 502, 506, 1486, 498, 510,
502, 506, 502, 506, 502, 510, 498, 510,
502, 506, 502, 510, 498, 510, 498, 510,
502, 506, 502, 4514, 510, 1482, 502, 1490,
506, 1486, 502, 506, 502, 510, 498, 510,
502, 506, 502, 506, 502, 510, 498, 510,
502, 506, 502, 506, 502, 1490, 506, 1486,
502, 1490, 506, 1486, 502, 1486, 498, 1494,
506, 1486, 498, 1494, 502, 1000};
const int dataLenLeft = 78;
uint16_t rawDataLeft[dataLenLeft]={
4518, 4510, 502, 534, 474, 510, 498, 510,
498, 510, 498, 538, 474, 1494, 502, 534,
474, 506, 502, 510, 498, 534, 478, 506,
502, 534, 474, 534, 474, 510, 502, 534,
474, 534, 474, 4518, 506, 1486, 498, 1494,
502, 1486, 502, 534, 474, 1494, 502, 1486,
502, 534, 474, 1490, 506, 1486, 502, 534,
474, 538, 470, 510, 498, 514, 494, 538,
474, 1494, 502, 530, 478, 534, 474, 1490,
498, 1494, 502, 1486, 498, 1000};
const int dataLenRight = 78;
uint16_t rawDataRight[dataLenRight]={
4510, 4518, 502, 534, 478, 534, 474, 534,
474, 538, 470, 538, 470, 1522, 478, 530,
478, 530, 478, 530, 478, 534, 474, 534,
478, 530, 478, 534, 474, 534, 474, 534,
474, 534, 478, 4514, 506, 1486, 502, 1490,
506, 1482, 502, 538, 474, 534, 474, 1490,
506, 530, 478, 1514, 474, 1490, 506, 530,
478, 530, 478, 530, 478, 1514, 474, 534,
474, 1518, 478, 530, 478, 534, 478, 1510,
474, 1490, 506, 1486, 502, 1000};
/*
* Cut-and-paste into the area above.
*/
void loop() {
if (Serial.available()) {
//send a code every time a character is received from the
// serial port. You could modify this sketch to send when you
// push a button connected to an digital input pin.
int character = Serial.read();
if (character == 'p'){
mySender.send(rawDataOnOff, dataLenOnOff,38);
Serial.println(F("Sent On/Off signal."));
}
else if (character == 'l'){
mySender.send(rawDataLeft, dataLenLeft,38);
Serial.println(F("Sent Left signal."));
}
else if (character == 'r'){
mySender.send(rawDataRight, dataLenRight,38);
Serial.println(F("Sent Right signal."));
}
else {
Serial.println(F("Got unknown command, no signal sent."));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment