analogRead(D4) not working in saved program #4086
Replies: 1 comment
-
Posted at 2022-10-27 by @gfwilliams I think the issue is your use of You probably want:
Posted at 2022-10-27 by docmathoc That has helped, thank you. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2022-10-26 by docmathoc
On an MDBT42, I'm using analogRead() in a function, called from a main function, called by onInit().
The analogRead() works just once on the first run and the value is never updated.
I know the pin voltage changes because it is correctly returned when I do a command line analogRead(D4) while the program is running.
Any ideas why this might be? I am tending towards a problem with how I’m using onInit(), but even so I am a bit lost…
Here is the code:
What it does (meant to do) is flash the led twice at intervals if the voltage on D4 falls below 3, otherwise flash the led once at intervals. It's a low battery warning notification I want to add into other programs later. The led flashing functions perform as expected.
The main loop (at onInit()) is meant to call the routine and update every 10s. The code is saved to flash from the webIDE.
Thanks in advance for comments...
Beta Was this translation helpful? Give feedback.
All reactions