Grove_4Digital_Display icon indicating copy to clipboard operation
Grove_4Digital_Display copied to clipboard

Arduino without PC

Open BodnaBersch opened this issue 3 years ago • 2 comments

I coded a program but it is only working with the PC connected. If the PC isn`t connected the Timer doesn´t work properly it only counts up to 2 or 3. I Have no Idea.

[ADUINO UNO R3] main.zip image image

BodnaBersch avatar Feb 16 '22 11:02 BodnaBersch

I have a few notes not sure if thiese would fix your problem tho

  1. Sensor() uses pulseIn() function which is blocking this might block execution or atleast make it slower if no pulse is detected. So maybe try commenting line 37
  2. Timer() counts seconds by sleeping for 1000ms which is not accurate because you don't take into account time it takes to run code (especially unknown pulseIn blocking time). For this I would adapt ideas from non blocking sleep sketch. Basically to use millis() or micros() to check if 1sec have passed.
  3. Line 100 and 102 don't mix bool with int. Technically it works but readability is worse
  4. If nothing works I would keep only Timer() inside loop() without any if statement to rule out any mistakes in those

Combinacijus avatar Feb 16 '22 13:02 Combinacijus

Hello @BodnaBersch,

Have you followed the tips from @Combinacijus? Any updates on the issue now?

Thank you.

lakshanthad avatar Mar 08 '22 03:03 lakshanthad

@BodnaBersch Hi, does this problem still exist?

ackPeng avatar Oct 16 '24 07:10 ackPeng