Page 39
Component:
Image Reference:
LED
(5mm)
+
-
+
-
h20
h21
Push Button
d4
g4
d6
g6
Push Button
d9
g9
d11
g1
1
Jumper Wire
Pin 2
h6
Jumper Wire
Pin 3
h11
Jumper Wire
Pin 13
j20
i4
Jumper Wire
i9
Jumper Wire
10K
Ω
Resistor
a15
i6
+
10K
Ω
Resistor
i11
+
330
Ω
Resistor
j21
+
One of the things that makes the RedBoard so useful is that it can make complex decisions based on the input it's getting. For example, you could make a thermostat that turns on a heater if it gets too cold, a fan if it gets too hot, waters your plants if they get too dry, etc.
In order to make such decisions, the Arduino environment provides a set of logic operations that let you build complex "if" statements. They include:
You can combine these functions to build complex if() statements.
For example:
if ((mode == heat) && ((temperature < threshold) || (override == true))) { digitalWrite(HEATER, HIGH); }
...will turn on a heater if you're in heating mode
AND
the temperature is low,
OR
if you
turn on a manual override. Using these logic operators, you can program your RedBoard to make intelligent decisions and take control of the world around it!
How to use logic like a Vulcan:
==
EQUIVALENCE
A == B
is true if A and B are the
SAME
.
!=
DIFFERENCE
A != B
is true if A and B are
NOT THE SAME
.
&&
AND
A && B
is true if
BOTH
A and B are
TRUE
.
||
OR
A || B
is true if
A
or
B
or
BOTH
are
TRUE
.
!
NOT
!A
is
TRUE
if A is
FALSE
.
!A
is
FALSE
if A is
TRUE
.
Jumper Wire
GND
Jumper Wire
5V
+
Summary of Contents for RedBoard
Page 13: ...Page 11...