Hello there.
I have been reading this forum for a certain time, always finding answers to my questions... until now.
About IR, I have seen a lot of project using pretty complex signals, like IR remote, but this doesn't apply to my case:
I do have 6 objects (scalextric cars), whith each individual objects having its own ID (1 to 6), and each object may request one and only one action (request lane change).
These objects will pass in front of the IR receiver pretty quickly.
ID is provided through the IR emitter by the time between 2 pulse (called Length, I believe).
action requested is provided by the time the signal is actually up, so the time the pulse is high (called width, I believe).
I tried to read the signal using IRremote library and the code below, but I got an inconsistent reading: I never have the same result.
This leads me to believe that I need to write some code which can get length end width of the pulse, probably include some tolerance, and then take action.
here are a few datas I could get by using an oscilloscope connected at the emiter.
ID: 1 _ Pulse length: 186µs _ action requested Pulse width: 48µs
ID: 2 _ Pulse length: 236µs _ action requested Pulse width: 41µs
ID: 3 _ Pulse length: 283µs _ action requested Pulse width: 47µs
ID: 4 _ Pulse length: 330µs _ action requested Pulse width: 48µs
ID: 5 _ Pulse length: 374µs _ action requested Pulse width: 63µs
ID: 6 _ Pulse length: 426µs _ action requested Pulse width: 42µs
I am looking for recomandations about the way to collect pulse datas with an arduino, or any idea about a better way to achieve my goal: detecting ID and detecting if action is requested or not.
Oh, and I forgot to mention that I am using AX-1838HS which was in an elegoo kit.
/*
IR Receiver Demonstration 1
IR-Rcv-Demo1.ino
Demonstrates IR codes with IR Receiver
Displays results on Serial Monitor
DroneBot Workshop 2017
http://dronebotworkshop.com
*/
// Include IR Remote Library by Ken Shirriff
#include <IRremote.h>
// Define sensor pin
const int RECV_PIN = 4;
// Define IR Receiver and Results Objects
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
// Serial Monitor @ 9600 baud
Serial.begin(9600);
// Enable the IR Receiver
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results)) {
// Print Code in HEX
Serial.println(results.value, HEX);
irrecv.resume();
}
}