Arduino Programming Language: BitwiseOr

Name

| (bitwise OR)

Description

The bitwise OR operator is the vertical bar symbol,|. Like the & operator, | operates independently each bit in its two surrounding integer expressions, but what it does is different (of course). The bitwise OR of two bits is 1 if either or both of the input bits is 1, otherwise it is 0.

Syntax

expression1 | expression2

Parameters

  • expression1: any valid expression
  • expression2: any valid expression

Usage

Application

Examples

unsigned int a = 60; // 60 = 0011 1100
unsigned int b = 13; // 13 = 0000 1101
unsigned int c = 0;
c = a | b; // 61 = 0011 1101


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