Skip to content

Commit 9bd0530

Browse files
authored
Merge pull request #121 from robsoncouto/master
Documenting bool datatype
2 parents ce4acf8 + e1dfcf6 commit 9bd0530

File tree

2 files changed

+84
-3
lines changed

2 files changed

+84
-3
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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ subCategories: [ "Tipos de Dados" ]
1212

1313
[float]
1414
=== Descrição
15-
O tipo `boolean` pode armazenar dois valores: `true` or `false`. (Cada variável `boolean` ocupa um byte na memória.)
15+
16+
`boolean` é um alias de tipos de dados não padrão para link:../../../variables/data-types/bool/[bool] definido pelo Arduino. É recomendado usar em vez disso o tipo padrão `bool`, que é idêntico.
1617

1718
[%hardbreaks]
1819

@@ -57,7 +58,6 @@ void loop()
5758
--
5859
// HOW TO USE SECTION ENDS
5960

60-
6161
// SEE ALSO SECTION STARTS
6262
[#see_also]
6363
--
@@ -66,7 +66,8 @@ void loop()
6666
=== Ver Também
6767

6868
[role="language"]
69-
#LINGUAGEM# link:../../../variables/constants/constants[constants] +
69+
#LINGUAGEM# link:../../../variables/constants/constants[constantes] +
70+
#LINGUAGEM# link:../../../variables/data-types/bool/[bool]
7071

7172
--
7273
// SEE ALSO SECTION ENDS

0 commit comments

Comments
 (0)