Skip to content

Instantly share code, notes, and snippets.

@bakueikozo

bakueikozo/airis

Created Jan 17, 2021
Embed
What would you like to do?
/*
* IRremote: IRsendRawDemo - demonstrates sending IR codes with sendRaw
* An IR LED must be connected to Arduino PWM pin 3.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*
* IRsendRawDemo - added by AnalysIR (via www.AnalysIR.com), 24 August 2015
*
* This example shows how to send a RAW signal using the IRremote library.
* The example signal is actually a 32 bit NEC signal.
* Remote Control button: LGTV Power On/Off.
* Hex Value: 0x20DF10EF, 32 bits
*
* It is more efficient to use the sendNEC function to send NEC signals.
* Use of sendRaw here, serves only as an example of using the function.
*
*/
#include <IRremote.h>
IRsend irsend;
void setup()
{
pinMode(3,OUTPUT);
pinMode(10,INPUT);
/*
while(1){
digitalWrite(3,1);
delay(1000);
digitalWrite(3,0);
delay(1000);
}*/
Serial.begin(9600);
}
unsigned int rawData1[115] = {9050,4450, 650,1600, 600,550, 600,500, 650,450, 650,1600, 650,500, 650,1600, 650,450, 700,450, 650,1600, 600,1650, 650,450, 650,1600, 650,1600, 650,1600, 650,500, 650,450, 650,450, 650,500, 650,450, 650,500, 650,1600, 650,450, 650,500, 650,450, 650,500, 600,500, 650,450, 650,1600, 650,500, 650,450, 650,500, 650,1600, 650,450, 650,500, 650,450, 650,450, 650,500, 650,450, 650,500, 650,450, 650,500, 650,450, 650,500, 600,500, 650,450, 650,500, 650,450, 650,500, 650,450, 650,1650, 600,1650, 600,500, 650,450, 650,1600, 600,500, 650}; // NEC 8A6E0408
unsigned int rawData2[115] = {9050,4450, 650,1600, 600,500, 650,500, 650,450, 650,1600, 650,500, 600,1650, 600,500, 650,450, 650,1600, 650,1600, 650,500, 650,1600, 650,1600, 600,1650, 600,500, 650,500, 650,450, 650,500, 650,450, 650,500, 650,1600, 650,450, 650,450, 650,500, 650,450, 650,500, 650,450, 650,1600, 650,500, 650,450, 650,500, 600,500, 650,1600, 650,450, 650,500, 650,450, 650,500, 650,450, 650,500, 650,450, 650,500, 650,450, 650,450, 650,500, 650,450, 650,500, 650,450, 650,1650, 600,1650, 600,1600, 650,1650, 600,500, 650,450, 650,1600, 650,500, 600}; // NEC 8A6E0408
int khz = 38; // 38kHz carrier frequency for the NEC protocol
char lastPin=1;
int count=0;
void loop() {
if( digitalRead(10)==0 ){
Serial.println("triggered");
delay(11000);
if( count ){
Serial.println("off");
irsend.sendRaw(rawData2, sizeof(rawData2) / sizeof(rawData2[0]), khz); //Note the approach used to automatically calculate the size of the array.
}else{
Serial.println("on");
irsend.sendRaw(rawData1, sizeof(rawData1) / sizeof(rawData1[0]), khz); //Note the approach used to automatically calculate the size of the array.
}
count=(count+1)&1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment