Hi.
New at this but getting there.
Timing a school project - my CO2 powered car (like this Shop Pitsco | Dragsters )
I have written a code (well..copied and edited) that will measure a drop in reading on a LDR from a laser as my dragster moves through the beam, starts a timer and then stops time when a second laser is crossed 100mm away.
The code calculates the speed (average) over the 100mm.
I am using 2 analog inputs for the LDRs to read from. Works well using the Print Monitor.
I would like to place this onto a track and have a tft screen print out the speed.
I have purchased the following equipment:
2.4inch TFT
3.5inch TFT
Both fit straight onto the Uno without any wiring. Only problem is there is only 1 analogue channel left when the TFT shield is on. Can I use one of the TFT pins for my 2nd LDR input?
I have also purchased the Uno, mega and due. Hoping one of these will work (hopefully the Uno with the 3.5tft screen as preference)
I have been looking at writing code to make a simple 2 line read out - "Dragster Speed is... XXX KPH".
I would appreciate any help as the tutorials and help guides on these TFT's is confusing. I am a going crazy! They are very complicated and I want something simple.
I would be happy to donate $20 to your chose charity / arduino organisation if you can help. (I will place a screenshot of receipt). I have already spent too many nights stressing while looking for code to use -simple for some but impossible for me.
Current code (which prints to a serial monitor currently) below. Would love to know how to make this print out on a 2.4 or 3.5 inch screen.
I have attached pictures of my 'basic' set up.
int firstsens = 4;
int secondsens = 5;
unsigned long time, time2;
float kph, elap;
int val;
int val2;
void setup()
{
Serial.begin(9600);
pinMode (firstsens, INPUT);
pinMode (secondsens, INPUT);
}
void loop()
{
Serial.println("Waiting for Co2 car to launch....");
val = analogRead(firstsens);
val2 = analogRead(secondsens);
while (val > 200)
{
val = analogRead(firstsens);
}
while (val <= 200)
{
time = micros();
val = analogRead(firstsens);
}
while (val2 > 200)
{
val2 = analogRead(secondsens);
}
while (val2 <= 200)
{
time2 = micros();
val2 = analogRead(secondsens);
}
elap = time2 - time;
kph = (elap*1000)6060;
Serial.print(kph );
Serial.println (" kph");
}





