I will begin with my first experience working with Arduino and Arduino IDE. I made a speed detection "device" using 2 laser pointers and 2 LDR sensors connected to an Arduino UNO.

The device can be used for fun by measuring speed of your remote controled toy car, or even adapt it to be used in some other systems like alarm systems or to control other devices like garage doors, or whatever you can think of.

Building the schematics is very easy.

` `

The resistors are used as pull-down resistors and I wired the sensors and put them in a case, to avoid them detecting surrounding light. For each case, a hole was drilled so that the laser beam can light the sensor while the ambient light does not affect the sensor.

The working principle is easy: an object that passes by will "cut" the laser beams, this means the LDR sensor will detect this sudden drop of light intensity. First I defined a threshold value under which the sensor is considered triggered, once the value is under threshold for the first sensor then Arduino waits for the second one to be triggered. During this waiting time it counts the elapsed time between the two events. When the second beam is interrupted, the timer stops and now is just simple math. The distance between the 2 sensors is known, the time between the two events is known, and speed can be computed as speed = distance/time.

Below you can find the Arduino code:

```/*
by Claudiu Cristian
*/

unsigned long time1;
int photocellPin_1 = 0;     // 1st sensor is connected to a0
int photocellPin_2 = 1;     // 2nd sensor is connected to a1
int threshold = 700;        //value below sensors are trigerd
float Speed;              // declaration of Speed variable
float timing;
unsigned long int calcTimeout = 0; // initialisation of timeout variable

void setup(void) {
// We'll send debugging information via the Serial monitor
Serial.begin(9600);
}

void loop(void) {
// if reading of first sensor is smaller than threshold starts time count and moves to calculation function
time1 = millis();
startCalculation();
}
}

// calculation function
void startCalculation() {
calcTimeout = millis(); // asign time to timeout variable
//we wait for trigger of sensor 2 to start calculation - otherwise timeout