bitSet()
Descripción
Activa (escribe una 1)en un bit de una variable numérica.
Sintaxis
bitSet(x, n)
Parámetros
- x: la variable numérica cuyo bit se quiere activar
- n: el bit a activar, empezando por 0 del bit menos significativo (más a la derecha)
Retornos
- Ninguno
Ejemplo
void setup() {
Serial.begin(9600);
byte x = 0b10000000; // the 0b prefix indicates a binary constant
Serial.print("BEFORE: ");
Serial.println(x, BIN); // 10000000
bitSet(x, 2); // write 1 to the third bit
Serial.print("AFTER: ");
Serial.println(x, BIN); // 10000100
}
void loop() {}
The result in Serial Monitor:
COM6
BEFORE: 10000000
AFTER: 10000100
Autoscroll
Clear output
9600 baud Â
Newline Â
Ver También
- Lenguaje: bit()
- Lenguaje: bitClear()
- Lenguaje: bitRead()
- Lenguaje: bitWrite()
- Lenguaje: highByte()
- Lenguaje: lowByte()
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |
Please note: These are affiliate links. If you buy the components through these links, We may get a commission at no extra cost to you. We appreciate it.
Follow Us