Arduino Programming Language: Comparison Operators

 

Name

Comparison Operators

Description

The structure IF are used with a comparision operator:

  • x == y (x is equal to y)
  • x != y (x is not equal to y)
  • x < y (x is less than y)
  • x > y (x is greater than y)
  • x <= y (x is less than or equal to y)
  • x >= y (x is greater than or equal to y)

Warning

The single equal sign('=') is the assignment operator and set a value into a variable; instead, for to use a comparision operator, must be used the double equal sign ('==').

Example:

if(x=200) //puts the value 200 into the variable x

if(x==200)//tests whether x is equal to 200 or not


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