Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork49
Open
Description
The following code typically loops one more time thantimes e.g. with 0, it loops once, with 1, it loops twice.
#define PTIME 30void pulse(int pin, int times) { do { digitalWrite(pin, HIGH); delay(PTIME); digitalWrite(pin, LOW); delay(PTIME); } while (times--);}ADDITIONAL SUGGESTION#1: Decide whether it should loop 0 times or once, whentimes is set to 0; looping almost forever is probably not desired.
ADDITIONAL SUGGESTION#2: Add optional additional parameterint duration that defaults toPTIME or 30.