67Views1Replies

Author Options:

Using a 3.5 tt screen to display speed from a laser chrono set up Answered

Timing a school project - my CO2 powered car (like this www.pitsco.com/Technology/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 speed trap 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 display out the speed but are having trouble working out how to do this. Any help would be great.

I have purchased the following equipment: 2.4inch TFT and a 3.5inch TFT. A Uno, Mega and Due boards. My preference is to use a Uno board and the 3.5 screen which plugs straight into the uno.

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 for the uno. Can I use one of the TFT pins for my 2nd LDR input?

I have been looking at writing code to make a simple 2 line read out - "Dragster Speed is...   XXX KPH".

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)*60*60;
Serial.print(kph );
Serial.println (" kph");
}

Comments

The forums are retiring in 2021 and are now closed for new topics and comments.
0
Downunder35m
Downunder35m

4 years ago

For a color TFT I recommend the Due as otherwise all CPU power might be lost to driving the display.
The output routines should be explained in the libraries for the display.
But unless you want to use proper graphics and the touch functions a normal (big) LCD would be better.
You can get them for serial communication as well and there they only need a few pins on your Arduino.