bit()

Descripción

Calcula el valor del bit especificado (el bit 0 es 1, el bit 1 es 2, el bit 2 es 4, etc.).

Sintaxis

bit(n)

Parámetros

  • n: el bit cuyo valor se quiere calcular

Retornos

  • El valor del bit

Ejemplo

void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps long x; for (int n = 0; n < 16; n++) { x = bit(n); // equivalent to x = 1 << n; Serial.println(x, BIN); } } void loop() { }

The result in Serial Monitor:

COM6
Send
1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000 10000000000 100000000000 1000000000000 10000000000000 100000000000000 1000000000000000
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit
Please note: These are Amazon affiliate links. If you buy the components through these links, We will get a commission at no extra cost to you. We appreciate it.

※ OUR MESSAGES