Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update BlinkWithoutDelay.ino example#15

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

Open
per1234 wants to merge1 commit intomain
base:main
Choose a base branch
Loading
frompr_7239
Open

Conversation

@per1234
Copy link
Contributor

Moved fromarduino/Arduino#7239 by@codetheorist

  • Remove unused ledPin constant
  • Make comments more natural language
  • Change if/ese statement to demonstrate shorthand variable flipping

* Remove unused ledPin constant* Make comments more natural language* Change if/ese statement to demonstrate shorthand variable flipping
@per1234per1234 added the type: enhancementProposed improvement labelSep 26, 2020
@per1234
Copy link
ContributorAuthor

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.

  • Remove unusedledPin constant

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.

  • Change if/else statement to demonstrate shorthand variable flipping

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! to another example.
Also I'd sayHIGH andLOW are not to be interpreted as true and false boolean values in Arduino, but rather as two abstract pin states (which just happen to be defined as1 and0, but that's an implementation detail that isn't evenin their documentation). Think of them as anenum.

  • Make comments more natural language

This part was good in my opinion (except for theConstants 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).

@per1234
Copy link
ContributorAuthor

From @DRSDavidSoft on 2018-02-22

@codetheorist With the introduction ofLED_BUILTIN, I thought this exampleshould have been modified according to your edit. However, as@cousteaulecommandant already pointed out, that' not the point of the example.

However, as a better coding pattern for amateurs, I'd appreciate if@codetheorist still somehow makes its way to the examples.

@per1234
Copy link
ContributorAuthor

From @cousteaulecommandant on 2018-02-22

I disagree. AlthoughLED_BUILTIN is a useful macro for referring to the built-in LED, I'd rather keep it this way, since this macro refers to a specific LED whereas the constant intends to refer to "whichever LED the design uses". It's not really redundant since both refer to different concepts ("LED used in this program" vs "LED built into board").

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.

Copy link
Contributor

@ubidefeoubidefeo left a 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 theif block, but I can live with this :)

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign ourContributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let usrecheck it.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ubidefeoubidefeoubidefeo approved these changes

Assignees

No one assigned

Labels

type: enhancementProposed improvement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@per1234@CLAassistant@ubidefeo@codetheorist

[8]ページ先頭

©2009-2025 Movatter.jp