How to effectively use the Not equal to operator in Arduino

by Radu Tyrsina
Radu Tyrsina
Radu Tyrsina
CEO & Founder
Radu Tyrsina has been a Windows fan ever since he got his first PC, a Pentium III (a monster at that time). For most of the kids of... read more
Affiliate Disclosure
  • 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
To fix various PC problems, we recommend DriverFix:
This software will keep your drivers up and running, thus keeping you safe from common computer errors and hardware failure. Check all your drivers now in 3 easy steps:

  1. Download DriverFix (verified download file).
  2. Click Start Scan to find all problematic drivers.
  3. Click Update Drivers to get new versions and avoid system malfunctionings.
  • DriverFix has been downloaded by 0 readers this month.

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 your 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.

idee restoro Still having issues? Fix them with this tool:
  1. Download this PC Repair Tool rated Great on (download starts on this page).
  2. Click Start Scan to find Windows issues that could be causing PC problems.
  3. Click Repair All to fix issues with Patented Technologies (Exclusive Discount for our readers).

Restoro has been downloaded by 0 readers this month.

Frequently Asked Questions

  • The == sign in Arduino means that the values at each side of the condition are equal to one another

  • 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.

  • 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.

This article covers:Topics: