Arduino Programming Language: BitWrite

Name

bitWrite()

Description

This command writes a determined bit of a number.

Syntax

var = bitWrite(byteVal, n, bitVal)

Parameters

  • byteValue: the byte or the name of variable
  • n: position of bit to write
  • bitVal: the value to write to the bit

Returns

none 

Usage

Application

Examples

int value = 22;                    // it sets the variable value to 22 (b:0010110)
int x = bitWrite(value,3,1);   // x= 30 because it sets to 1 the bit number 3 (b:0011110)


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