Commit 84e26c89 authored by Daniel STAN's avatar Daniel STAN

code source de la wattuino

parent 5c4847b6
/* Example program for from IRLib – an Arduino library for infrared encoding and decoding
* Version 1.3 January 2014
* Copyright 2014 by Chris Young http://cyborg5.com
* Based on original example sketch for IRremuote library
* Version 0.11 September, 2009
* Copyright 2009 Ken Shirriff
* http://www.righto.com/
*/
/*
* IRLib: IRrecvDump - dump details of IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
*/
#include <IRLib.h>
int RECV_PIN = 11;
IRrecv My_Receiver(RECV_PIN);
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
IRdecodeNEC My_Decoder;
unsigned int Buffer[RAWBUF];
int incomingByte = 0;
int todo_channel = 4;
int todo_port = 1;
boolean todo_on = true;
unsigned long code = 0;
void setup()
{
Serial.begin(9600);
delay(2000);
while(!Serial);//delay for Leonardo
My_Receiver.enableIRIn(); // Start the receiver
My_Decoder.UseExtnBuf(Buffer);
mySwitch.enableTransmit(10);
}
void loop() {
int val;
if (My_Receiver.GetResults(&My_Decoder)) {
//Restart the receiver so it can be capturing another code
//while we are working on decoding this one.
My_Receiver.resume();
if ( My_Decoder.decode() )
switch (My_Decoder.value) {
case 0xFD807F:
Serial.println("Control: Pause");
break;
case 0xFD00FF:
Serial.println("Control: Vol-");
break;
case 0xFD40BF:
Serial.println("Control: Vol+");
break;
case 0xFD08F7:
Serial.println("Control: 1");
break;
case 0xFD8877:
Serial.println("Control: 2");
break;
case 0xFD48B7:
Serial.println("Control: 3");
break;
case 0xFD28D7:
Serial.println("Control: 4");
break;
case 0xfd10ef:
Serial.println("Control: Prev");
break;
case 0xfd50af:
Serial.println("Control: Next");
break;
default:
Serial.print("Unkwon: ");
Serial.println(My_Decoder.value);
}
//My_Decoder.DumpResults();
}
while(Serial.available()) {
incomingByte = Serial.read();
if(incomingByte == 'o')
todo_on = true;
else if(incomingByte == 'f')
todo_on = false;
else if(incomingByte == 'r') {
val = analogRead(3);
Serial.print("Current value: ");
Serial.println(val);
}
else if(incomingByte >= '1' && incomingByte <= '4')
todo_port = incomingByte - '0';
else {
code = 0b010101010101010101010101;
code ^= (unsigned long) 1<<(2*(4-todo_channel)+16);
code ^= 1<<(2*(4-todo_port)+8);
if(!todo_on)
code ^= 1;
mySwitch.send(code, 24);
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment