Skip to main content
10 events
when toggle format what by license comment
Jun 24, 2021 at 12:51 comment added Jurc192 Okay, I was considering this option as well. Could you point me to some resources or explanations what is the reasoning behind it? What do you mean by "safer"?
Jun 24, 2021 at 12:50 vote accept Jurc192
Jun 22, 2021 at 15:00 history tweeted twitter.com/StackArduino/status/1407352710710575104
Jun 22, 2021 at 11:04 answer added Jurc192 timeline score: 2
Jun 21, 2021 at 18:05 comment added Majenko It's safer for your class to have an internal record of the LED state instead of relying on digitalRead() to give you the right result.
Jun 21, 2021 at 17:26 comment added Dave Newton Got cranky and found it: forum.arduino.cc/t/…
Jun 21, 2021 at 17:17 comment added Dave Newton Re: the latter; it's (incrementally) safer to check against HIGH (or LOW) and use a conditional op. I forget the thread that led me to think this could be a potential issue moving forward--something on the Arduino forums. Sorry--it's probably not a big deal, either.
Jun 21, 2021 at 17:13 comment added Jurc192 Aha okay, the Arduino I'm using has been through alot so I will verify this with a new one soon. It could be faulty. But what exactly do you mean that "it should be coded as such"? Should I explicitly cast it to a bool? Or write it the "long way", checking if digitalRead==0 or ==1?
Jun 21, 2021 at 15:53 comment added Dave Newton Check the wiring; there's no particular reason this would be an issue specifically with that pin unless there's a wiring or electrical issue (which can be internal). Note that digitalRead returns an int, not a bool, and IMO should be coded as such to avoid breaking changes or cross-architecture issues.
Jun 21, 2021 at 15:40 history asked Jurc192 CC BY-SA 4.0