LDR mounted on model railway tracks
6 LDRs with adjustable resistors on a prototyping board.
Test circuit
The projects on these pages will also use the Arduino UNO and NANO. Note the LDR is sensitive to ambient light hence the 10 K ohm potentiometer.
The model train projects on this site can be sub-divided into
1. The sensors
2. The train signals
3. Using multiple sensors to control the signals.
4. Transmitting information to the outside world.
This folder is concerned specifically with the LDR_Sensor. Project using the IR sensor are on the IR_Sensor page. The train signals page will use these sensors to control train signals. Since the sensors will be used to test the signals and vice versa many projects are relevant to both. Using multiple sensors and transmitting information are in the folder Model Trains
Basically the projects developed in theses pages will generate a signal train_over_sensor( ) that will is used by the projects in the train signals page to control the signals.
Testing LDR: Testing with model train using room lights. Couplings above LDR an issue.
LDR_Sensor_Class: Develops a library that includes train_over_sensor( ) that detects when a train is over the LDR sensor. Includes a 1 second filter for couplings over filter.
LDR_Overload_Class: Overloads the LDR_Sensor_Class library to permit setting the filter time.
LDR_Analog_Class: Modifies LDR_Sensor_Class aand LDR_Overload_Class to use analog readings when attached to analog pins
LDR_Serial_Sensors_Class: Multiple LDRs read using parallel to serial converter. The output will be train_over_sensor(sen) where sen is position of sensor of interest.
1. LDR vs IR. LDR very inexpensive, easy to fit but sensitive to variations in ambient light levels
2. Filtering; Default program LDR_Sensor_Class gives a 1 second filter. If other filtering required use LDR_Overload_Class
3. It is assumed LDR_Sensor_Class and LDR_Overload_Class the input signal is digital. If the class is attached to an analog pin use LDR_Analog_Class. LDR_Analog_Class will select the appropriate code (analog vs digital) so effectively replaces the other two classes and can be used in all projects.
4. Micro-controller inputs: Default program LDR_Sensor_Class assumes each LDR wired to a single micro-controller pin. If a parallel to serial convertor is necessary use LDR_Serial_Sensors_Class.
See Train_Signals and Model_Trains pages