bitRead()
Description
Lit un bit d'un nombre.
Syntaxe
bitRead(x, n)
Paramètres
- x: le nombre duquel le bit doit être lu
- n: le rang du bit à lire, en partant de 0 pour le bit de poids faible (le plus à droite).
Valeurs Renvoyées
- La valeur du bit (0 or 1).
Exemple
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
10000101
10100001
Autoscroll
Clear output
9600 baud
Newline
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.
Additionally, some links direct to products from our own brand, DIYables.