Our downscaled model features a electrified track and an Arduino-controlled vehicle.
There are Arduino controlled installed on both vehicle and track.
When the vehicle is off-track, it is powered by onboard battery and controlled by its own Arduino chip.
When the vehicle is on-track, it draws electricity from the track. The supply of electricity is controlled by a chip connected to the track.
The car utilizes 4 DC motors, which enable precise braking and adequate power
Solidworks design of vehicle:
Arduino codes:
void myCode()
{
//—————————————————————————————-
// myCode();
//
// This is the tab where student programming is done.
// A list of available function calls are listed in detail under tab “00_Student_Functions”
//
// Note:
// (1) After running your program do not turn the controller off, connect the controller to a computer, or
// push the reset button on the Arduino. There is a 13 second processing period. In
// post processing, data is stored and battery recuperation takes place.
// (2) Time, current, voltage, total marks, forward marks, and backward marks traveled are recorded approximately
// every 60 milliseconds. This may vary depending on the vehicles operational tasks.
// It takes approximately 35-40 milliseconds for each recording. Thus when programming,
// code complexity may not be beneficial.
// (3) Always comment your code. Debugging will be quicker and easier to do and will
// especially aid the instructional team in helping you.
//—————————————————————————————-
// Program between here——————————————————————-
int trackVolts = analogRead(A0); // read voltage from track as integer value
voltage = trackVolts * (5.0 / 1023); //convert integer to actual voltage
if (voltage >1) motorSpeed(4,0); // when voltage is present motors do not run
if (voltage>1){ // loop inititated when voltage drops
digitalWrite(TRIGPIN,LOW);
delayMicroseconds(2);
digitalWrite(TRIGPIN,HIGH);
delayMicroseconds(10);
digitalWrite(TRIGPIN,LOW);
int distance = pulseIn(ECHOPIN,HIGH);
distance= distance/58;
Serial.println(distance);
delayMicroseconds(100); // Distance sensor setup
if (distance< 30) motorSpeed(4,0); // distance less than 30 centimeters stops motors
if (distance> 30) motorSpeed(4,100); // distance greater than 30 centimeters car runs full speed
}
// And here——————————————————————————–
} // DO NOT REMOVE. end of void myCode()