Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Arduino to MMbasic
Author | Message | ||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
I have a line in a small Arduino sketch that turns on a led for a random length of time analogWrite(ledPin1, random(50)+125) This I take it switches ledPin1 on for a random length of time plus 125, but 125 what are they milliseconds. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1109 |
That randomly sets the brightness of the LED. Analogwrite() generates an 8 bit PWM on the specified pin. So the random brightness is between roughly 1/2 and 3/4 bright. Visit Vegipete's *Mite Library for cool programs. |
||||
disco4now Guru Joined: 18/12/2014 Location: AustraliaPosts: 896 |
I think it may be the duty cycle for a PWM signal. I have no experience know but this is google result. The function used to output a PWM signal is analogWrite(pin, value). pin is the pin number used for the PWM output. value is a number proportional to the duty cycle of the signal. Footnote added 2024-06-25 08:17 by disco4now Too slow ! Latest F4 Latest H7 |
||||
Print this page |