/*___________________________________________________________________________________________________ * * U C I C R I T T E R S T U D Y G R O U P * L E S S O N 4 * Working with IR Remote Control// Start the receiver * Ron Kessler * Created 5/14/2021 * Updated 5/16/2021 * Changed Raw decoding to 'command' to see first byte only. This * matches my IR decoding report! * * PURPOSE: * DEMO HOW TO DETECT SONY REMOTE IR KEY CODES * See my comments in loop function below. You can use either decode method. * Entire 12 bits First byte codes * Channel Up = 144 16 * Channel Dn = 145 17 * Volume Up = 146 18 * Volume Dn = 147 19 Using the IR receiver in your study group kit: 1. Place the IR module in a breadboard with the sensor facing you. 2. Connect a green wire from the leftmost pin to GND on Arduino. 3. Connect a RED wire from the center pin of the sensor to 5V on Arduino. 4. Connect another wire from the right pin to pin 2 of the Arduino. This is the signal pin. 5. Make sure you have the IRRemote library installed on your computer. I use ver 3.3 as of this writing. 6. Save & upload your code 7. Open the serial monitor window. TOOLS | SERIAL MONITOR. Make sure to set baud rate to 9600. 8. Point your Sony remote towards the sensor and push the buttons. The button code should appear in the monitor window. 9. WRITE YOUR CODES DOWN AND INCLUDE THEM IN YOUR SKETCHES!!! ___________________________________________________________________________________________________ */ //************* START CODE HERE ************ //---1. now add the library #include //ver 3.3 5/14/2021 //---2. define our sensor data pin and read first byte const byte IR_RECEIVE_PIN = 11; void setup() { //---3. open the serial port and monitor at 9600 baud rate. Serial.begin(9600); //---4. Start our IR receiver on the arduino. We pass in two arguments: pin# and system command // to ignore blinking the onboard LED when a message is received. IrReceiver.begin(IR_RECEIVE_PIN, DISABLE_LED_FEEDBACK); } void loop() { //---if data is beig received then decode it, print to the monitor, and keeping listening for more! if (IrReceiver.decode()) { //---use command to use first byte as described in my report Serial.println(IrReceiver.decodedIRData.command); //only the first byte! //---use this line to decode entire 12bits //Serial.println(IrReceiver.decodedIRData.decodedRawData); //to see entire stream IrReceiver.resume(); // Receive the next value } } //************* END OF CODE ************