I am trying to make a timer that activates when one ir beam is broken then stop when a second beam is broken. The two beams are one inch apart, so with time and distance I can calculate speed(chronograph). Im not shure on how to go about making this timer, does anyone have any suggestions for me on how to program the timer, I can do everything else.
Thanks
So what your saying I should do is store the value in the EEPROM, and just read that value once the second beam breaks?
This is the code so far: Any tips?
int ir1 = 5;
int ir2 = 4;
int ir1val;
int ir2val;
int rawms;
int differance;
void setup(){
Serial.begin(115200);
}
void loop(){
ir1val = analogRead(ir1);
ir2val = analogRead(ir2);
if(ir2val < 1000){
differance = micros();
}
if(ir1val < 1000){
rawms = micros() - differance;
Serial.println(rawms, DEC);
delay(1000);
}
}
int ir1 = 5;
int ir2 = 4;
int ir1val;
int ir2val;
[glow]unsigned long[/glow] rawms;
[glow]unsigned long[/glow] differance;
void setup(){
Serial.begin(115200);
}
void loop(){
ir1val = analogRead(ir1);
ir2val = analogRead(ir2);
if( (ir2val < 1000) [glow]&& (ir1val >= 1000)[/glow] ){
differance = micros();
}
if( (ir1val < 1000) [glow]&& (ir2val >= 1000)[/glow] ){
rawms = micros() - differance;
Serial.println(rawms, DEC);
delay(1000);
}
}
Thanks bud, I got it from here.