Hide minor edits - Show changes to markup
Make sure you don't mistake the boolean AND operator, && (double ampersand) for the bitwise AND operator & (single ampersand). They are entirely different beasts.
Similarly, do not confuse the boolean || (double pipe) operator with the bitwise OR operator | (single pipe).
The bitwise not ~ (tilde) looks much different than the boolean not ! (exclamation point or "bang" as the programmers say) but you still have to be sure which one you want where.
Asegúrate de no confundir el operador AND booleano && (doble signo &) con el operador AND para bits & (un solo signo &).
De la misma manera no hay que confundir el operador OR booleano || (doble barra vertical) con el operador OR para bits | (una sola barra vertical).
El operador NOT de bits ~ (tilde) tiene una apariencia muy diferente del operador NOT booleano ! (exclamación o "bang", como lo llaman algunos programadores), pero debes asegurarte de usar cada uno de ellos dentro del contexto adecuado.
if (a >= 10 && a <= 20){} // true if a is between 10 and 20
if (a >= 10 && a <= 20){} // Verdadero sólo si el valor de a está entre 10 y 20
These can be used inside the condition of an if statement.
True only if both operands are true, e.g.
Se pueden usar dentro de operaciones condicionales o en una sentencia if.
Verdadero sólo si ambos operadores son Verdadero, por ejemplo:
if (digitalRead(2) == HIGH && digitalRead(3) == HIGH) { // read two switches
if (digitalRead(2) == HIGH && digitalRead(3) == HIGH) { // lee dos pulsadores
is true only if both inputs are high.
True if either operand is true, e.g.
Es Verdadero sólo si ambas entradas estás activadas, es decir, en estado HIGH.
Verdadero si alguno de los dos operadores es Verdadero, por ejemplo:
is true if either x or y is greater than 0.
True if the operand is false, e.g.
Es Verdadero si alguno de los valores x ó y es mayor que 0.
Verdadero si el operador es Falso, por ejempo:
is true if x is false (i.e. if x equals 0).
Es Verdadero si el valor de x es Falso (p. e. si x es igual a 0).
if (digitalRead(2) == 1 && digitalRead(3) == 1) { // read two switches
if (digitalRead(2) == HIGH && digitalRead(3) == HIGH) { // read two switches
is true only if x is 1, 2, 3, or 4.
is true only if both inputs are high.
if (x > 0 && x < 5) {
if (digitalRead(2) == 1 && digitalRead(3) == 1) { // read two switches
if (x > 0 && x< 5) {
if (x > 0 && x < 5) {
True if the operand is true, e.g.
True if the operand is false, e.g.
[@ if (a >= 10 && a <= 20){} // true if a is between 10 and 20
[@
digitalWrite(ledPin, !a); // this will turn on the LED every other time through the loop
@]
Make sure you don't mistake the boolean AND operator, && (double ampersand) for the bitwise AND operator & (single ampersand). They are entirely different beasts.
Similarly, do not confuse the boolean || (double pipe) operator with the bitwise OR operator | (single pipe).
The bitwise not ~ (tilde) looks much different than the boolean not ! (exclamation point or "bang" as the programmers say) but you still have to be sure which one you want where.
[@ if (a >= 10 && a <= 20){} // true if a is between 10 and 20
if (a >= 10 && a <= 20){} // true if a is between 10 and 20
digitalWrite(ledPin, !a); // this will turn on the LED every other time through the loop
&& (logical and): true only if both operands are true, e.g.
True only if both operands are true, e.g.
|| (logical or): true if either operand is true, e.g.
True if either operand is true, e.g.
! (not): true if the operand is true, e.g.
True if the operand is true, e.g.
&& (logical and): true only if both operands are true, e.g. if (x > 0 && x< 5) { } is true only if x is 1, 2, 3, or 4.
|| (logical or): true if either operand is true, e.g. if (x > 0 || y > 0) { } is true if either x or y is greater than 0.
! (not): true if the operand is true, e.g. if (!x) { } is true if x is false (i.e. if x equals 0).
&& (logical and): true only if both operands are true, e.g.
if (x > 0 && x< 5) {
// ...
}
is true only if x is 1, 2, 3, or 4.
|| (logical or): true if either operand is true, e.g.
if (x > 0 || y > 0) {
// ...
}
is true if either x or y is greater than 0.
! (not): true if the operand is true, e.g.
if (!x) {
// ...
}
is true if x is false (i.e. if x equals 0).
These can be used inside the condition of an if statement.
&& (logical and): true only if both operands are true, e.g. if (x > 0 && x< 5) { } is true only if x is 1, 2, 3, or 4.
|| (logical or): true if either operand is true, e.g. if (x > 0 || y > 0) { } is true if either x or y is greater than 0.
! (not): true if the operand is true, e.g. if (!x) { } is true if x is false (i.e. if x equals 0).