Ok, I am new to Arduino but open to constructive criticism. I've been working on this for quite a bit. The overall goal for this project is a collision avoidance system for a golf cart. I am using three sonar sensors and an LCD with keypad for a display. I want the LCD to display in real time the speed of the cart and the current charge state of the golf cart. The LCD will also display a menu to change a few options: speed units, warning buzzer on and off, automatic brakes on and off (haven't made it that far into the project but went ahead and built this option into the menu).
At this point I'm still in the prototyping stage. I'm simulating the speed and voltage with two potentiometers.
I started off with two separate programs, one for the sensors and warning system and the other for the LCD. I'm to the point where I am putting the two programs together and now I'm having some issues. With the way I have the program written now, the LCD doesn't display in real time. I'm able to see the main display, and I'm able to go into the menu to change units of speed and turn the buzzer on and off, but the voltage reading isn't real time. It only updates when I leave the menu to go back to the display.
I think the issue is the display doesn't print in the loop, it prints in a separate function. Adding that function to the loop causes all kinds of issues. The LCD doesn't display correctly, I believe it is having issues keeping up with the loop. Adding a delay to the loop fixes this, but it throws off the sonar sensors. Adding the function to the loop also does not allow me to visit the menu to change settings, as it is always displaying the main display.
I'll try to post my code, may have to separate it into a couple posts due to length. Let me know if you see any simple fixes that do not require me to completely rewrite my code. If that's the case, I'll probably cry. It has taken weeks for me to get to this point.
You have an awful lot of Strings that should be strings, wasting memory unnecessarily.
I think the issue is the display doesn't print in the loop, it prints in a separate function.
You need to describe the problem in terms of function names in your code. What I think this statement means is "I think the issue is that changes to the LCD only happen in mainDisplay(), which I only call from loop() when...", which, to me, means that you aren't calling mainDisplay() under ALL the right circumstances.
If you meant something else, feel free to correct my guess-work of what you meant.
PaulS:
You have an awful lot of Strings that should be strings, wasting memory unnecessarily.
I'm new to this. From what I have coded so far I have pulled from other programs. I have them as strings because that's how the were in the other codes that I used for reference. What else can I do other than declare the strings and call them when needed?
PaulS:
You need to describe the problem in terms of function names in your code. What I think this statement means is "I think the issue is that changes to the LCD only happen in mainDisplay(), which I only call from loop() when...", which, to me, means that you aren't calling mainDisplay() under ALL the right circumstances.
If you meant something else, feel free to correct my guess-work of what you meant.
You honestly lost me here. Not sure what you are meaning.