bitRead()

Descripción

Lee un bit de un número.

Sintaxis

bitRead(x, n)

Parámetros

  • x: el número del que se quiere leer
  • n: el bit a leer, empezando por 0 del bit menos significativo (más a la derecha)

Retornos

  • El valor del bit (0 o 1).

Ejemplo

void setup() { Serial.begin(9600); byte x = 0b10000101; // the 0b prefix indicates a binary constant Serial.println(x, BIN); // 10000101 for (int i = 0; i < 8; i++) Serial.print(bitRead(x, i)); // print bits one by one } void loop() {}

The result in Serial Monitor:

COM6
Send
10000101 10100001
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Ver También

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.

※ OUR MESSAGES

  • We are AVAILABLE for HIRE. See how to hire us to build your project
  • Any suggestion, correction, and translation? please email us at ArduinoGetStarted@gmail.com, We appreciate it
  • We mainly keep improving the references in English. See English version of this page for the latest update.