Weighbridge with loadcells, HX711, HC-SR04, 32x64 RGB led display, Arduino mega

Hello,

I have problems running the program in the attachment.
The part of the Sonar sensors (HC-SR04) and the display are working fine.
The problem is the weighing part.
It gives random results when using the RGB LED display, but when I use the calibrating program for loadcells in combination with a HX711 board, displayed by the serial monitor, the values are correct.

The program does the following:

  1. check if there is a vehicle at the beginning (using HC-SR04)
  2. when light is green check position of the vehicle on the weighbridge and when it het reached the center display STOP (using HC_SR04)
  3. the weighing process start and will be displayed (using loadcells with HX711 board)
  4. vehicle can drive from the weighbridge
  5. check if weighbridge is empty. (using HC-SR04)
  6. start at beginning (number 1)

Can it be that the complete program is to much for a Arduino mega? memory?

Or is there a programming issue?

I hope someone can help me.

Thanks in advance.

wieghbridge V3.09.txt (12.8 KB)

goto beginopnieuw;Uh-oh.

I am Dutch so some parts are written in Dutch. "Goto beginopnieuw" is used to get the program start at the begin to check the buttonstate.

Goto beginopnieuw" is used to get the program start at the begin to check the buttonstate.

We know what it accomplishes. It makes a mess of your code. A while statement does the same thing for well structured goto statements, without allowing you to jump to some random location. In 30 years of writing C and C++ code, I have used ONE goto statement, since removed.

Your code should not need ANY goto statements. Draw a flowchart to show what the logic is doing. If you can't fit a rectangle around part of your code, and create a function of that part that does the looping WITHOUT using goto, then your logic is wrong.