Skip to content

Added example code/Notes and warnings#751

Open
ashpande wants to merge 1 commit into
arduino:masterfrom
ashpande:patch-3
Open

Added example code/Notes and warnings#751
ashpande wants to merge 1 commit into
arduino:masterfrom
ashpande:patch-3

Conversation

@ashpande
Copy link
Copy Markdown
Contributor

Code was tested on Arduino Mega 2560

Code was tested on Arduino Mega 2560
Comment on lines +46 to +47
void setup()
{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void setup()
{
void setup() {

Arduino's standard code style uses attached braces.

----
void setup()
{
Serial.begin(9600);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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).

Comment on lines +49 to +52
}

void loop()
{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}
void loop() {
}

Necessary due to moving the code into setup().

Comment on lines +63 to +64
Both `x` and `n` must be integer type.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 9, 2021

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

@per1234 per1234 self-assigned this Aug 13, 2022
@per1234 per1234 removed their assignment Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants