-
-
Notifications
You must be signed in to change notification settings - Fork 732
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
Added example code/Notes and warnings #751
base: master
Are you sure you want to change the base?
Conversation
Code was tested on Arduino Mega 2560
void setup() | ||
{ |
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.
void setup() | |
{ | |
void setup() { |
Arduino's standard code style uses attached braces.
---- | ||
void setup() | ||
{ | ||
Serial.begin(9600); |
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.
Serial.begin(9600); | |
Serial.begin(9600); | |
while (!Serial) { | |
; // wait for serial port to connect. Needed for native USB port only | |
} |
This will make the example more friendly to users of the native USB boards (e.g., Leonardo).
} | ||
|
||
void loop() | ||
{ |
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.
} | |
void loop() | |
{ |
Let's put this in setup()
so it only runs once.
|
||
void loop() | ||
{ | ||
int x = 6; int n = 1; //setting the value of x and n |
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.
int x = 6; int n = 1; //setting the value of x and n | |
int x = 6; | |
int n = 1; |
This is more beginner friendly.
void loop() | ||
{ | ||
int x = 6; int n = 1; //setting the value of x and n | ||
Serial.print(bitRead(x,n)); //reading the bit at position n and printing the value |
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.
Serial.print(bitRead(x,n)); //reading the bit at position n and printing the value | |
Serial.print(bitRead(x, n)); //read the bit at position n and print the value |
- Arduino style code formatting.
- Improve comment wording.
{ | ||
int x = 6; int n = 1; //setting the value of x and n | ||
Serial.print(bitRead(x,n)); //reading the bit at position n and printing the value | ||
} |
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.
} | |
} | |
void loop() { | |
} |
Necessary due to moving the code into setup()
.
Both `x` and `n` must be integer type. | ||
|
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.
Both `x` and `n` must be integer type. |
I think this information would be better in the Parameters section, using the sample reference page as a model:
https://github.com/arduino/reference-en/blob/master/AsciiDoc_sample/Reference_Terms/AsciiDoc_Template-Single_Entity.adoc#parameters
Code was tested on Arduino Mega 2560