Using IR sensor/transmitter for slotcar detection

Hi everybody, new (old ) member here.
I was given an Arduino UNO and a two lines display with a module on the back.
In my spare box are:

  • 3 mm IR Leds (black and transparant)
  • TSOP4838 IR receivers
  • some 5 mm IR Leds
  • breadboard and wiring.

The plan is to make a two lane slotcar detection and lapcounting set-up with one LED inbedded in the track and one in a gantry overhead, so the passing car interrupts the beam and the lap is registred, showing the data on the display.

I started with the tutorials on YT (the never ending number of 30 minute+ series) which is all very nice if you want to understand how it all works, but I'd like to have something working before I die... Being 70, I don't want to invest days of tinkering with all those projects, interesting as they are.

I did find a number of YT tutorials on the subject, but they use deadstrips in stead of a gantry.

Can I get some guidance please?
I'd like very specific instructions on what to do and what to build, handholding to get me underway.

Regards, Jan.

1 Like

That sounds like a slot car track used a lot in the Boy Scouts pine wood derbys. Search that and you will find a lot of possible solutions. Also with your setup it is best to put the sensor pointing down at the track and put it in a short (black) tube, this will block most of the extraneous light.

When I was a cub scout leader, the setup I used was having the sensor in the track. It was just a simple photo diode. When a car passed overhead, it blocked enough of the light that I could detect it. No emitter/sensor pair needed.

1 Like

Excellent simple solution

That sounds like you want someone else to just work it out for you and tell you what to do. That really isn't the purpose of this site. This is more of a place to get help when you get stuck. It's not a free code writing service.

You may want to try posting on the Jobs and Collaborations section and offer to pay someone to do all this heavy lifting for you. Be sure to include a reasonable budget in the post or you won't get very much attention accept from people asking what your budget is.

1 Like

Thank you for the responses.
It's not that I'd want someone to (all) the heavy lifting, but I've been looking at these video's, showing close to what I'm after, but lacking sufficient experience and electronics knowledge, I get confused on deciding which part I can use and which part I can/need to alter, as this video uses deadstrips to detect the car passing:

If you say I can use the V4838 IR receiver inbedded in the track, I'll look up which connections the Arduino needs to get a signal to work with. Mounting an IR in a gantry, pointing down at the sensor isn't a mechanical challenge.

My problem is that I can't figure out which part of the programming I can use and which to leave out, or change...

I'm not a complete idiot (don't ask the wife), but I'm overwhelmed by all options and need to ben pointed in the right direction.

Once I've cobbled something together, I'll show it here before I power things up.

Regards, Jan.

You can see I live in the Netherlands where Boy scouts do not engage in Pinewood derbys.
In fact; I had to look it up to see what was meant.

Also Covid had a huge impact on 'local' slotrace clubs, making them dissappear, so getting local knowledge at the scene is not really an option unless I spent a long time in the car...

Regards, Jan.

A few simple pointers:

-The OUT pin of the TSOP4838 IR Receiver can connect to any digital pin on the Arduino, then read the value using pinMode(input1, INPUT); (Some quick searching can find some tutorials)

-I would use the 5mm IR LED's, as they generally would emit the signal farther, which is needed if it will be mounted on a gantry.

-A few digitalReads and if statements will go far with lap counting.

-There are a lot of tutorials on how to use displays to display information, follow those and then slowly integrate the rest of the code together.

Good Luck!

This is a common trap that new users fall into. You're not ready for those videos yet. Take a little time with just an ir sensor and nothing else. Play with some examples. It will take a few hours at most. Once you understand how to get a value and work with it, then put that to the side and get some examples that just print "Hello World" to the lcd and figure out how to get the lcd working. That might take a few more hours.

Then after that you will be a lot more easily able to follow the code and stuff in those videos and understand what they are doing. You can put a couple of days in now and get it, or you can struggle with it for weeks and eventually "cobble together" something that isn't quite what you hoped.

I've seen too many fall into this trap. It's easy to get out. It just takes a little time to work up to the level you need to be at to follow those videos you're watching. Crawl before you try to run.

1 Like

Agree with @Delta_G, keep it simple and basic. You probably don't need most of the custom electronics the video shows, just an LCD and two sensors/led's

Right, I wired up the TSOP4838 IR Receiver and a 5 mm IR LED (with a 330 Ohm resistor in series) on the breadboard, following the schematics on the datasheetof the 4838.
Followed by an endless search on how the programming should look like (read the value using pinMode(input1, INPUT).
Keep in mind I just started with Arduino, so nothing comes natural (yet), so I can't even find how the first lines of the programming should look.

I started out with a looong series of tutorials and got a LED blinking S.O.S. That is the extend of me writing code.

Please point me in the direction I need to look for the basic start of writing a program.

To keep it simple, I did not hook up the display yet, not sure if I need that to be able to see if the LED and sensor work.

Regards, Jan.

Posting that working sketch would help in many ways. Please do, fearlessly. We all started somewhere, so don't worry about anything.

I am curious about how you used tat receiver with the LED to even get to SOS.

a7

I should have been more clear; the LED blinking S.O.S is from a Paul Worther tutorial: https://youtu.be/nPOKOi1jIK0?si=Vh8ZQV0YfswQvfKZ As a former (army)telegraphist I found it necessary to adjust the delay so the blinking would be in the rhythm in which I would have operated the key, all those years ago.

I don't have a sketch yet, I just mechanically wired the component to the breadboard.
Than looked at it thinking: now what?

Waiting for a reply, I'm preparing a four wire lead from the scrap box to connect the display to the Arduino, as I only have wires with pins, no sockets.

Regards, Jan.

To wire the TSOP4838, you can use a similar variable, like int sensor=12 (Using sensor as the variable name and pin 12 on the arduino)

Then, some code using


pinMode(sensor, INPUT);

and

digitalRead(sensor);

To actually act based on the reading, an if statement can be used:

if(digitalRead(sensor) == HIGH) {
digitalWrite(ledPin, HIGH);
}

Now it gets embarrassing, as I now show that I have no idea what to do...

[CODE]
void setup() {

// put your setup code here, to run once:

pinMode(12,OUTPUT);

pinMode(sensor, INPUT);

}void setup() {

// put your setup code here, to run once:

digitalRead(sensor);

}

void loop() {

// put your main code here, to run repeatedly:

if(digitalRead(sensor) == HIGH) {

digitalWrite(ledPin, HIGH);

}

This generates error messages I don't know how to deal with...

Regards, Jan.

The TSOP4838 is an IR receiver to be used with remote controls. It requires a modulated 38kHz carrier in order to work. Forget about trying to use it.

Hi Jim-p,

I thought I had read/seen video's (using a TV remote) that the ArduinoUNO could generate a modulated 38kHz carrier to be able to work with this IR receiver.

I could be wrong...

Regards, Jan.

You are right, it is possible if thats the way you want to go.

That's the point: I don't know if it's the way I want to go.
The IR Sensors were selected primarily for the size, being able to fit inside the track without the need to create a bump.

Regards, Jan.

Neither do I

1 Like