Skip to content
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 an example and Notes and warnings #749

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ashpande
Copy link
Contributor

Code was tested on Arduino Mega 2560.

Code was tested on Arduino Mega 2560.
@CLAassistant
Copy link

CLAassistant commented Apr 9, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@per1234 per1234 left a comment

Choose a reason for hiding this comment

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

You added the content inside the "see_also" block instead of creating a new "howtouse" block. This resulted in an invalid Asciidoc document which would break the website generator.

Please move the content out of the "see_also" block, following the reference sample here:

https://github.com/arduino/reference-en/blob/master/AsciiDoc_sample/Reference_Terms/AsciiDoc_Template-Single_Entity.adoc?plain=1

@@ -44,6 +44,32 @@ The value of the bit.
--

[float]
=== Example Code
// Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
Prints the output of `bit(n)` for n=0 to n=10 to the serial monitor. Values returned are 1 2 4 8 16 till 1024.
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
Prints the output of `bit(n)` for n=0 to n=10 to the serial monitor. Values returned are 1 2 4 8 16 till 1024.
Prints the output of `bit(n)` for n=0 to n=10 to the Serial Monitor. Values returned are 1 2 4 8 16 till 1024.

Use correct capitalization for Arduino's "Serial Monitor" tool

[source,arduino]
----
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);

Correctly format code

----
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
}
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
}

This will ensure those using a board like the Leonardo will see all the sketch output from n=0.

Comment on lines +57 to +61
for(int n=0;n<=10;n++) //loop from n=0 till 10
{
Serial.print(" "); //space between numbers, for readability
Serial.print(bit(n)); //print the value of bit(n)
delay(1000);
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
for(int n=0;n<=10;n++) //loop from n=0 till 10
{
Serial.print(" "); //space between numbers, for readability
Serial.print(bit(n)); //print the value of bit(n)
delay(1000);
//loop from n=0 till 10
for (int n = 0; n <= 10; n++) {
Serial.print(" "); //space between numbers, for readability
Serial.print(bit(n)); //print the value of bit(n)
delay(1000);

Use the standard Arduino code formatting style, as implemented by the default configuration of the Arduino IDE "Auto Format" feature.


[float]
=== Notes and Warnings
The variable `n` must be an integer type. float and double will return an error and the program will not compile.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems better to specify the parameter type in the "Parameters" section of the reference page.

I'm not sure what the best approach is for defining types of parameters of macros such as bit:

https://github.com/arduino/ArduinoCore-API/blob/1.3.1/api/Common.h#L71

@per1234 per1234 added the on hold The PR should not be merged at this time label Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement on hold The PR should not be merged at this time
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants