Skip to content

Commit ab8ffec

Browse files
per1234robsoncouto
authored andcommitted
Document bool data type
Previously only Arduino's type alias, boolean was documented. In this case it's arguable that the benefits of a slightly more descriptive type name outweigh the disadvantages of using a non-standard type. For that reason documenting bool and recommending its use instead of boolean is desirable.
1 parent 6eae1e3 commit ab8ffec

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: bool
3+
categories: [ "Variables" ]
4+
subCategories: [ "Data Types" ]
5+
---
6+
7+
8+
9+
10+
11+
= bool
12+
13+
14+
// OVERVIEW SECTION STARTS
15+
[#overview]
16+
--
17+
18+
[float]
19+
=== Description
20+
A `bool` holds one of two values, `true` or `false`. (Each `bool` variable occupies one byte of memory.)
21+
22+
23+
[%hardbreaks]
24+
25+
--
26+
// OVERVIEW SECTION ENDS
27+
28+
29+
30+
31+
// HOW TO USE SECTION STARTS
32+
[#howtouse]
33+
--
34+
35+
[float]
36+
=== Example Code
37+
// Describe what the example code is all about and add relevant code ►►►►► THIS SECTION IS MANDATORY ◄◄◄◄◄
38+
This code shows how to use the `bool` datatype.
39+
40+
[source,arduino]
41+
----
42+
int LEDpin = 5; // LED on pin 5
43+
int switchPin = 13; // momentary switch on 13, other side connected to ground
44+
45+
bool running = false;
46+
47+
void setup()
48+
{
49+
pinMode(LEDpin, OUTPUT);
50+
pinMode(switchPin, INPUT);
51+
digitalWrite(switchPin, HIGH); // turn on pullup resistor
52+
}
53+
54+
void loop()
55+
{
56+
if (digitalRead(switchPin) == LOW)
57+
{ // switch is pressed - pullup keeps pin high normally
58+
delay(100); // delay to debounce switch
59+
running = !running; // toggle running variable
60+
digitalWrite(LEDpin, running); // indicate via LED
61+
}
62+
}
63+
----
64+
65+
--
66+
// HOW TO USE SECTION ENDS
67+
68+
69+
// SEE ALSO SECTION STARTS
70+
[#see_also]
71+
--
72+
73+
[float]
74+
=== See also
75+
76+
[role="language"]
77+
* #LANGUAGE# link:../../../variables/constants/constants[constants]
78+
79+
--
80+
// SEE ALSO SECTION ENDS

Language/Variables/Data Types/boolean.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,22 @@ subCategories: [ "Tipos de Dados" ]
1111
--
1212

1313
[float]
14+
<<<<<<< HEAD
1415
=== Descrição
1516
O tipo `boolean` pode armazenar dois valores: `true` or `false`. (Cada variável `boolean` ocupa um byte na memória.)
17+
=======
18+
=== Description
19+
`boolean` is a non-standard type alias for link:../../../variables/data-types/bool/[bool] defined by Arduino. It's recommended to instead use the standard type `bool`, which is identical.
20+
21+
>>>>>>> a1ceb3b... Document bool data type
1622
1723
[%hardbreaks]
1824
1925
--
2026
// OVERVIEW SECTION ENDS
2127
2228
29+
<<<<<<< HEAD
2330
// HOW TO USE SECTION STARTS
2431
[#howtouse]
2532
--
@@ -56,6 +63,8 @@ void loop()
5663
5764
--
5865
// HOW TO USE SECTION ENDS
66+
=======
67+
>>>>>>> a1ceb3b... Document bool data type
5968

6069

6170
// SEE ALSO SECTION STARTS
@@ -66,7 +75,11 @@ void loop()
6675
=== Ver Também
6776

6877
[role="language"]
78+
<<<<<<< HEAD
6979
#LINGUAGEM# link:../../../variables/constants/constants[constants] +
80+
=======
81+
* #LANGUAGE# link:../../../variables/data-types/bool/[bool]
82+
>>>>>>> a1ceb3b... Document bool data type
7083
7184
--
7285
// SEE ALSO SECTION ENDS

0 commit comments

Comments
 (0)