Devices & Components
Arduino Mega 2560 Rev3
Resistor 10k ohm
Photo resistor
Project description
Code
Code
arduino
1void setup(){ 2 Serial.begin(9600); 3 delay(100); 4} 5 6 7void loop(){ 8 int x = analogRead(A0); 9 delayMicroseconds(100); 10 if(abs(analogRead(A0) - x) > 2){ 11 unsigned long t = micros(); 12 while(1){ 13 x = analogRead(A1); 14 delayMicroseconds(100); 15 if(abs(analogRead(A1) - x) > 2){ 16 Serial.print(360000.0/(micros() - t)); 17 Serial.println(" km/h"); 18 delay(500); 19 break; 20 } 21 } 22 } 23}
Downloadable files
Schematics
Connect everything as shown in this picture. It is very important that the two photoresistors are 10cm apart from each other. Otherwise you will get wrong speed measurements.
Schematics

Schematics
Connect everything as shown in this picture. It is very important that the two photoresistors are 10cm apart from each other. Otherwise you will get wrong speed measurements.
Schematics

Comments
Only logged in users can leave comments