Skip to content

Conversation

@ashpande
Copy link
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
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
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
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
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
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
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
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

CLAassistant commented Apr 9, 2021

CLA assistant check
All committers have signed the CLA.

@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