• Arduino is based on the C/C++ programming language; most of the functions of C++ are available, plus some specific extensions.
  • The not equal to relational operator is one of the common language structure elements in Arduino and we'll see how it's used.
  • For more specific articles, make sure to take a look at our dedicated Arduino Hub.
  • Also, go to our Developer Tools section for more insightful information.

 

using not equal to in arduino

Single-board microcontroller Arduino uses C/C++ programming language, which comprises sets of functions, values (variables and constants), and language structure elements.

The not equal to a structure is part of the comparison operators, alongside equal toless than, less than or equal to, greater than, greater than or equal to. The graphic sign is !=.


How do I use not equal to with Arduino?

Not equal to is an element that compares one variable on the left with a value or variable on the right of the operator.

It returns true when the two operands are not equal.

The syntax is usually the following:

x != y; // is false if x is equal to y and it is true if x is not equal to y

What not equal to condition does is to say that if the current state doesn’t equal the previous state, then do this.arduino not equal

In the above example, you make a call for all values of x that are not equal to 2 to be printed in the Serial Monitor, with a delay of 500ms, to allow you to click the button.arduino not equal to results

It’s recommended to compare variables of the same data type including the signed/unsigned type. Comparing variables of different data types is possible, but it could generate unpredictable results.


The Serial Monitor is not working on you Arduino? Try these solutions.


Note that the Arduino IDE uses C++, but since the physical environment is limited,  not all C/C++ features can be used and the Arduino environment. As a result, Arduino has helper functions (specific extensions) to enable you to use the hardware easily.

FAQ: Read more about the Arduino programming language

  • What does != mean in Arduino?

The sign refers to a specific condition, that should be used between two values to indicate that one value is not equal to the other value.

  • What does == mean in Arduino?

The == sign in Arduino means that the values at each side of the condition are equal.

  • What does void mean in Arduino?

Void is a keyword used in Arduino function declarations, and it indicates that the function is expected to return no information to the function from which it was called.