Dear Friends,
Im a NewBee to Arduino setup, :o
Kindly help me through the Program.
I am doing a project in which i have three phototransistors , when a ball crosses the light to 1st phototransis. is obstructed , then the lcd connected to Arduino should start counting the time in milliseconds and when a ball cross, light to 3rd Phototransis. is obstructed the lcd should stop and display the time in ms.
//A program to display the time in milliseconds on LCD when a medium travels between two phototransistors//
//Please help me correct this program//
//these constants wont change:
const int analogPin0=A0; //pin that attached to first sensor
const int analogPin1=A1; //pin that attached to second sensor
const int analogPin2=A2; //pin that attached to third sensor
#include <LiquidCrystal.h>
const int rs=12, en=11, d4=5, d5=4, d6=3, d7=2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup()
{
//set up the LCD's number of column and rows:
lcd.begin(16,2);
//print message
lcd.print("zero, gravity!");
//initialize the serial communications:
Serial.begin(9600);
}
void loop()
{
int analogPin0=1; //A0 bcm1,when light to phototransis1. is blockd-LCD start counting time in millisec
int analogPin1=1; //would use later
int analogPin2=1; //A2 bcm1,when light to phototransis2. is blockd-LCD pausetime.
char time; // direct if needed or not
char count; //direct if needed or not
lcd.setCursor(0,1);
lcd.print(millis()/1000);
// read the value of first sensor fromPinA0:
// if A0 or analogpin0 becomes 1, the LCD should start counting time in Milliseconds;
if (analogPin0==1);
{
lcd.print(millis()/1000);//i want to start lcd count in milliseconds what is the correct code?
}
//read the value of last sensor from pinA2:
//if A2 or analogpin2 becomes 1, the LCD should pause or stop the reading in milliseconds
if (analogPin2==1);
{
lcd.print(millis()/1000);
}
delay(500);// stop the timer if A2=1
}
//display the time in milliseconds start lcd count when A0==1 & pause lcd counting when A2==1
// no idea how this syntax can make LCD count in milliseconds
Please help me edit this program so that it does the desired.
**Many Thanks in Advance **
Greatly Appreciated