Skip to content

Commit 47c14dc

Browse files
Added example to Int doc
Added working code sample to int.adoc, along with explanation.
1 parent 8b7c090 commit 47c14dc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Language/Variables/Data Types/int.adoc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,21 @@ The Arduino takes care of dealing with negative numbers for you, so that arithme
4848
[float]
4949
=== Example Code
5050
// Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
51-
51+
This code creates an integer called 'countUp', which is initially set as the number 0 (zero). The variable goes up by 1 (one) each loop and displayed on the serial monitor.
5252

5353
[source,arduino]
5454
----
55-
int ledPin = 13;
55+
int countUp = 0; //creates a variable integer called 'countUp'
56+
57+
void setup() {
58+
Serial.begin(9600); // use the serial port to print the number
59+
}
60+
61+
void loop() {
62+
countUp++; //Adds 1 to the countUp int on every loop
63+
Serial.println(countUp); // prints out the current state of countUp
64+
delay(1000);
65+
}
5666
----
5767
[%hardbreaks]
5868

0 commit comments

Comments
 (0)