-
-
Notifications
You must be signed in to change notification settings - Fork 45
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update BlinkWithoutDelay.ino example #15
base: main
Are you sure you want to change the base?
Conversation
* Remove unused ledPin constant * Make comments more natural language * Change if/ese statement to demonstrate shorthand variable flipping
From @cousteaulecommandant on 2018-02-22 I think that, although the code becomes more compact and simple, it also becomes less explicit and deviates from the typical Arduino code. Keep in mind that this is an example and thus needs to be easy to understand and modify.
I don't think this is a good idea. Sure, you could just use the macro every time instead of assigning it to a constant, but then if you want to change the pin you use you have to change EVERY line where it appears and risk forgetting one of them; it's better practice to define the pin at the beginning so that it can be modified easily.
I think this is not the point of this example; better to leave it as an explicit "if it's low then set it high, otherwise set it low" and leave the usage of
This part was good in my opinion (except for the Constants won't change/Variables will change part; I think it's useful to specify that distinction since they're part of what's being explained here). PS: I forgot to mention, but it seems that you removed the newline at the end of the file. Although C++ allows it and Arduino might be fine with that, it's better practice to always have your text files ending in a newline (for example it's illegal not to do so in C). |
From @DRSDavidSoft on 2018-02-22 @codetheorist With the introduction of However, as a better coding pattern for amateurs, I'd appreciate if @codetheorist still somehow makes its way to the examples. |
From @cousteaulecommandant on 2018-02-22 I disagree. Although Personally I strongly believe it's better practice to define all constants that will be used in the application in a single place near the beginning (as constants or as macros, which may or may not refer to other macros). I have found that it eventually simplifies modifying the program later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only remark I have is that I always update the time of operation and the very end of the if
block, but I can live with this :)
|
Moved from arduino/Arduino#7239 by @codetheorist