Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Continuous or timed?

by Marshall (Canon)
on Dec 15, 2020 at 20:27 UTC ( [id://11125259]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Continuous or timed?
in thread Continuous or timed?

Oh, and by the way, don't blindly run after sleep returns. sleep may be interrupted, so your process may have slept for a much shorter time than expected.

Yes, indeed! I had forgotten about that. Sleep() returns the value of unslept seconds. So if its not zero, just sleep again for that return value. Sleep is often implemented with SIGALRM so that's another potential issue.

Good description of power/brightness for LED's. As another comment, you can get what are called "resistor LED's". In that case, the resistor is built into the LED. Probably the most common value will be 1K Ohms which is a good choice for 5V. For 3.3V perhaps, 470 or 560 Ohms would be fine. The brightness can also be adjusted by pulsing the LED. I forget exact waveforms that I've used in the past for "ON", but as a starting point, probably a square wave with 20-30ms/on-off is about as bright as 100%. Play with different duty cycles for "on" and see what happens... Current and duty cycle of that current vs perceived brightness is a non-linear function.

BTW, I like blinking as the "good state" -> that means that the processor is running and is able to turn the LED on/off. Also, different cadences of the LED can be used to indicate error conditions. Human brains are excellent at pattern recognition. My router has a particular flashing light sequence that I recognize as "normal" without really thinking about what each individual light means. If the LED is stuck either at ON or OFF, I would surmise that the processor is "dead". If you just have a single LED, perhaps Long blip, followed by short blip means Internet connection bad, etc.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11125259]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-04-25 15:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found