I have made my code but I need it to restart to the begining.
#include <LiquidCrystal.h>;
unsigned long startTime;
unsigned long stopTime;
unsigned long elapsedTime;
unsigned long Time;
boolean started = false;
boolean stopped = false;
int startPin = 9;
int stopPin = 8;
const int numRows = 2;
const int numCols = 16;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
pinMode(stopPin, INPUT);
pinMode(startPin, INPUT);
digitalRead;
Serial.begin(9600);
{
void loop();
{
if(digitalRead(startPin) == HIGH) // The sensor has been activated
{
started = true; // If this is ture start the timer
startTime = micros(); // States when the senor has been crossed
}
if(digitalRead(stopPin) == HIGH) // The sensor has been activated
{
stopped = true; // If this is ture start the timer
stopTime = micros(); // States when the senor has been crossed
}
if(started && stopped)
{
elasped = stopTime - startTime; // How long did that take?
Serial.print("Elapsed time, in microseconds: ");
Serial.println(elapsed);
started = false; // Reset so the senors can be tripped again
stopped = false;
}
Serial.print("Elapsed time, in seconds: ");
lcd.print("Elapsed time, in seconds: ");
Thank you I have done that but now its giving an error of "elasped wasn't declared in this scope.
What do I do?
#include <LiquidCrystal.h>
unsigned long startTime;
unsigned long stopTime;
unsigned long elapsedTime;
unsigned long Time;
boolean started = false;
boolean stopped = false;
int startPin = 9;
int stopPin = 8;
const int numRows = 2;
const int numCols = 16;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
pinMode(stopPin, INPUT);
pinMode(startPin, INPUT);
digitalRead;
Serial.begin(9600);
}
void loop()
{
if(digitalRead(startPin) == HIGH) // The sensor has been activated
{
started = true; // If this is ture start the timer
startTime = micros(); // States when the senor has been crossed
}
if(digitalRead(stopPin) == HIGH) // The sensor has been activated
{
stopped = true; // If this is ture start the timer
stopTime = micros(); // States when the senor has been crossed
}
if(started && stopped)
{
elasped = stopTime - startTime; // How long did that take?
Serial.print("Elapsed time, in microseconds: ");
Serial.println(elapsed);
started = false; // Reset so the senors can be tripped again
stopped = false;
}
Serial.print("Elapsed time, in seconds: ");
lcd.print("Elapsed time, in seconds: ");
}