Arduino Programming Language: BitRead

Name

bitRead()

Description

This command reads a determined bit of a number.

Syntax

var = bitRead(byteValue, n)

Parameters

  • byteValue: the byte or the name of variable from which to read
  • n: it represents the position of bit to read

Returns

bit 

Usage

Application

Examples

int value = 22;                   // sets value to 22 
int x = bitRead(value,3);  // x = 0, because 22 in binary is 0010110 and the 3th bit of value is 0


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc