Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Modulo / Remainder in Arduino
The modulo operator in Arduino is exactly the same as in C language, or most other languages for that matter. The operator is %. The syntax is: a % b and it returns the remainder when a is divided by b.
Example
The following example illustrates the use of this operator −
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println();
Serial.println(10%3);
Serial.println(4%2);
Serial.println(50%9);
}
void loop() {
// put your main code here, to run repeatedly:
}
Output
The Serial Monitor output is shown below. You can work out the remainders yourself and verify that the output is correct.

Advertisements
