I need help with this Arduino code. I am currently using an Arduino Uno r3 with the Grover-LCD RGB Backlight, and the text does not display the void setup code, but instead displays the void loop code, and it doesn't preform properly. Any Ideas?
Put a delay after that line and the setup prints should show up. The setup prints are happening but very shortly thereafter the loop code starts and clears the display because the first if structure is true.
Thank for the help, however now it cannot display the times when it hits the power switch shown in the picture. Is there any idea that could help with this?
So after the LCD displays the "timer started", it doesn't display the times on the LCD when I press the power switch on the picture below.
if (((digitalRead(startButtonMain) == 0)|| (digitalRead(startButton) == 0)) && (!started)){
The way that you had it is that the first if is true when the start button is not pressed. The timer stats unconditionally. At the end of the sequence when you print to the LCD the information gets printed but then loop() starts over right away and the LCD gets cleared because that if executes. If you change to both switches unpressed, the first if is not true until one of the switches is pressed. You then must press one of the switches (startButtonMain or startButton) to initiate timing.
The code has a switch (startButtonMain) connected to pin 6 but there is nothing connected to pin 6 in the diagram. Which is right?
I wired up a circuit with an Uno, 4 momentary push button switches and an I2C LCD as closely copying your circuit as I could. I do not have a RGB display, I used a 20 x 4 (2004) character LCD and the excellent hd44780 library. Using the latest version of your code, the project seems to be working as one would expect.
What is the problem? Using my circuit (made from your diagram) and the latest code seems to work fine.
On restart the LCD reads
Brachistochrone
Experiment
Press the startButton (connected to pin 5). The display reads:
timer started
Press b1 (pin 4), b2 (pin 2), b3 (pin 2) in succession. Right after the 3rd switch, the display will change to something like:
t1 t2 t3
2.12 4.10 5.86
Press the startButton again. The display goes back to:
timer started
b1, b2, b3 can be pressed in any order.
If the above is not what your circuit is doing then there seems to be a hardware problem. Please describe, in detail, the problems that you have.
Or I am misunderstanding your requirements. In that case, please describe what the code is supposed to do.
Post some clear photos of your project wiring and layout. That is often helpful.
And here is a schematic showing my wiring. Note that the capacitors on the switches are not required. They do add hardware debounce and some noise immunity. Debounce can be done in software and there are those that would insist that software debounce is the best way.
Now the problem is that the Arduino Uno doesn't turn on when the orange wire goes into the 5V and the GMD wire connects to the LCD. Is there any problem here?
I can't tell much at all by the photo. It is hard to see where the wires go and the LCD nnd the switches are not in the photo. It would be much better if you would draw a schematic showing exactly how the wiring is done.
Draw the schematic with pencil and paper, photograph it and post.