Arduino ir, my first project!

Hello i made an remote controlled Arduino device!
Controlling some Led's With an universal Remote Control!

Imgur

/* 5 Channel ir remote control
Created by Asghar Furqan
A fully open-sourse program!


circuit:
ir module connected to pin 2(Digital)
led 1-2-3-4-5 connected to pin 3-4-5-6-7
*/

#include <IRremote.h>

int RECV_PIN = 2;
int led1 = 7;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the ir receiver
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
}

void loop() {

if (irrecv.decode(&results)) {
Serial.println(results.value, DEC);

if(results.value == 16705559) //if you want to configure with your remote controll change the results.value
digitalWrite(led1, HIGH); // set the LED on
if (irrecv.decode(&results)) {
Serial.println(results.value, DEC);
if(results.value == 16656599)
digitalWrite(led1, LOW); // set the LED off

irrecv.resume(); // Receive the next value

if(results.value == 16672919)
digitalWrite(led2, HIGH); // set the LED on
if(results.value == 16697399)
digitalWrite(led2, LOW); // set the LED off

irrecv.resume(); // Receive the next value

if(results.value == 16689239)
digitalWrite(led3, HIGH); // set the LED on
if(results.value == 16664759)
digitalWrite(led3, LOW); // set the LED off

irrecv.resume(); // Receive the next value

if(results.value == 16668839)
digitalWrite(led4, HIGH); // set the LED on
if(results.value == 16676999)
digitalWrite(led4, LOW); // set the LED off

irrecv.resume(); // Receive the next value

if(results.value == 16674959)
digitalWrite(led5, HIGH); // set the LED on
if(results.value == 16650479)
digitalWrite(led5, LOW); // set the LED off

irrecv.resume(); // Receive the next value

}

}
}

Cool. Thanks for sharing.

Thank you for sharing very interesting project. There must be lots of applications with this.

I have a couple questions. Is the IRremote.h your own header file or some general header file? (Never mind, I just googled and found these two links: A Multi-Protocol Infrared Remote Library for the Arduino and http://code.google.com/p/arduino-compatible-robots/source/browse/trunk/oh_oh/oh_oh_software/oh_oh_arduino_lib/IRremote/IRremote.h?spec=svn29&r=29)

And how did you get those values?

Thanks. :slight_smile:

Thanks for sharing!

You can shorten some of the code with ? : condition(?: (conditional) / Reference / Processing.org)
For instance:

     digitalWrite(led5,(results.value==16674959)?HIGH:LOW);
     digitalWrite(led5,(results.value==16650479)?LOW:HIGH);

Even though it's a bit more confusing

You can shorten some of the code with ? : condition(http://processing.org/reference/conditional.html)

Wouldn't that make it only possible to have one led on at a time?

Thank you for sharing very interesting project. There must be lots of applications with this.

I have a couple questions. Is the IRremote.h your own header file or some general header file? (Never mind, I just googled and found these two links: A Multi-Protocol Infrared Remote Library for the Arduino and Google Code Archive - Long-term storage for Google Code Project Hosting....)

And how did you get those values?

Thanks.

i get those values on my serial port, its simple, make the circuit, connect Arduino With Pc and open (from Arduino Ide) Serial Monitor, and then press a Button on your Remote control the value appears on the serial monitor! :wink:

oh and the IRremote.h is not my own i get it from : Google Code Archive - Long-term storage for Google Code Project Hosting. :slight_smile:

I see. I missed this line

Serial.println(results.value, DEC);

Thanks.