Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork49
Added duration variable to Blink.ino#20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
per1234 commentedSep 26, 2020
Please declare the variable outside of the function 'loop'. |
per1234 commentedSep 26, 2020
This is a coding style preference, and I'd prefer to keep it as it is. Is there a style guide that's been published by the Arduino team? That's not meant to be a snarky response, or defensive - I just would genuinely like to know if there is a style guide that's been published by the Arduino team, and if there is, if it states that variables be declared globally and at the top of the file. This is a coding style preference, and I prefer this convention for the following reasons:
I've worked at several companies in my career, and all companies (or at least the recent ones that I remember) used this coding style. I did some googling, and found these discussions: In Java, should variables be declared at the top of a function, or as they're needed? Declaring variables inside or outside of a loop Why declare variables close to where they are used? |
ubidefeo commentedSep 26, 2020
@per1234 Setup: enable the LED pin to be an output |
CLAassistant commentedMay 7, 2021
|
Moved fromarduino/Arduino#10648 by@JeffB42
Added duration variable to the Blink.ino sketch. This change has the following benefits: