I have been working on a project about simulating a vehicle and a race track digitally, and so far I have gotten the gas, brakes, and the steering working. I am having severe trouble implementing the actual track into the program.
I tried using delays to somehow simulate it. By "simulating" I mean having the user lower their speed and steer to the correct direction when facing a corner for example, if they don't, they should crash. The straights should also be a opportunity for the user to up their speed. Delays only slow down the other functions in the loop. Please help.
You will need some kind of digital model of the track. Perhaps a graphical map or a list of straights and arcs. For each time step you need to calculate the new position and velocity (speed and direction). If the car goes outside the bounds of the track: crash.
Using delay() (a blocking function) in your program will make it unresponsive. Using millis() for timing will allow you to write code that dos not block.
groundFungus:
Using delay() (a blocking function) in your program will make it unresponsive. Using millis() for timing will allow you to write code that dos not block.
Do you really mean to run the startup() function every time through loop()?
Not really, I don't really know how to call the startup() function outside the loop though, don't even know if that's possible. How can I implement millis() into my program?
slipstick:
How do you intend that the user is going to know where the race track goes and where they currently are on it?
Steve
They won't. The LEDs and the buzzer will turn on when a corner is near, if there are let's say 4 corners, then the user can keep that in mind.