© 2024 EasyEDA Some rights reserved ISO/IEC
Brand new interactions and interfaces
Smooth support for design sizes of over 3W
devices or 10W pads
More rigorous design constraints, more
standardized processes
For enterprises, more professional users
Easy to use and quick to get started
The process supports design scales of 300
devices or 1000 pads
Supports simple circuit simulation
For students, teachers, creators
STD Infrared (IR) Remote
Mode:
#include "IRremote.h"
/*-----( Declare Constants )-----*/
int receiver = 3; // pin 1 of IR receiver to Arduino digital pin 3
/*-----( Declare objects )-----*/
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'
/*-----( Declare Variables )-----*/
void setup() /*----( SETUP: RUNS ONCE )----*/
{
Serial.begin(9600);
Serial.println("IR Receiver Raw Data + Button Decode Test");
irrecv.enableIRIn(); // Start the receiver
}/*--(end setup )---*/
void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
// Serial.println(results.value, HEX); UN Comment to see raw values
translateIR();
irrecv.resume(); // receive the next value
}
}/* --(end main loop )-- */
/*-----( Declare User-written Functions )-----*/
void translateIR() // takes action based on IR code received
// describing Car MP3 IR codes
{
switch(results.value)
{
case 0xFFA25D:
Serial.println(" CH- ");
break;
case 0xFF629D:
Serial.println(" CH ");
break;
case 0xFFE21D:
Serial.println(" CH+ ");
break;
case 0xFF22DD:
Serial.println(" PREV ");
break;
case 0xFF02FD:
Serial.println(" NEXT ");
break;
case 0xFFC23D:
Serial.println(" PLAY/PAUSE ");
break;
case 0xFFE01F:
Serial.println(" VOL- ");
break;
case 0xFFA857:
Serial.println(" VOL+ ");
break;
case 0xFF906F:
Serial.println(" EQ ");
break;
case 0xFF6897:
Serial.println(" 0 ");
break;
case 0xFF9867:
Serial.println(" 100+ ");
break;
case 0xFFB04F:
Serial.println(" 200+ ");
break;
case 0xFF30CF:
Serial.println(" 1 ");
break;
case 0xFF18E7:
Serial.println(" 2 ");
break;
case 0xFF7A85:
Serial.println(" 3 ");
break;
case 0xFF10EF:
Serial.println(" 4 ");
break;
case 0xFF38C7:
Serial.println(" 5 ");
break;
case 0xFF5AA5:
Serial.println(" 6 ");
break;
case 0xFF42BD:
Serial.println(" 7 ");
break;
case 0xFF4AB5:
Serial.println(" 8 ");
break;
case 0xFF52AD:
Serial.println(" 9 ");
break;
default:
Serial.println(" other button ");
}
delay(500);
} //END translateIR
If you use the IRrecvDemo Sketch (above) and count the 21 buttons from left to right and top to bottom, the codes received are these: (NOTE: Receiving "FFFFFFFF" means "repeat" if you hold the button down.)
![result][6]
[1]: /editor/20160105/568bb29a45918.jpg
[2]: /editor/20160105/568bb321b9b9a.jpg
[3]: /editor/20160105/568bb3903f59b.JPG
[4]: /editor/20160105/568bb3e55ca56.jpg
[5]: /editor/20160105/568bb4a806608.JPG
[6]: /editor/20160105/568bb578bfd9d.jpgID | Name | Designator | Footprint | Quantity |
---|---|---|---|---|
1 | TSOP1738 | U1 | TSOP17XX | 1 |
2 | Arduino MEGA 2560 | U2 | DIP | 1 |
Unfold
Loading...
Do you need to add this project to the album?