Step #7 : infra-red sensor test

arduino4fun
Site Admin
Posts: 37
Joined: Mon Jun 06, 2016 1:16 pm

Step #7 : infra-red sensor test

Postby arduino4fun » Thu Jun 09, 2016 8:00 am

this tests the infra-red sensor and gives the result of the remote to the serial.

Here is the video showing the test : https://youtu.be/pmjKY-VDzjw

NOTA : if you receive the following error message while compiling the code : "C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp:5:16: error: 'TKD2' was not declared in this scope
int RECV_PIN = TKD2; // the pin the IR receiver is connected to
^
Error compiling.";

simply remove the file C:\Program Files (x86)\Arduino\libraries\RobotIRremote\src\IRremoteTools.cpp & .h from the Arduino directory, this is a known conflict.

Code: Select all

// ---------------------------------------------------------------------------------------------------------------
 // This sketch allows to check the infrared receiver sensor connected to the digital pin #12
 //
 // S - pin #12 - Orange
 //
 // https://www.facebook.com/arduino4fun
 // http://www.arduino4fun.com
 // ---------------------------------------------------------------------------------------------------------------

‪#‎include‬ <IRremote.h>

int RECV_PIN = 12;
 IRrecv irrecv(RECV_PIN);
 decode_results results;

void setup()
 {
 Serial.begin(9600);

irrecv.enableIRIn(); // Start the receiver
 }

void loop()
 {
 if (irrecv.decode(&results))
 {
 Serial.print(results.value, HEX);
 Serial.println();
 irrecv.resume(); // Receive the next value
 }
 }


Image
Image

Return to “Multifunction Bluetooth Controlled Robot Smart Car Kits For Arduino”

Who is online

Users browsing this forum: No registered users and 0 guests