Yash Sanghvi has Published 220 Articles

Modulo / Remainder in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:16:04

7K+ Views

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.ExampleThe following example illustrates the use of this operator −void ... Read More

Check if a character is Space/Whitespace in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:15:32

565 Views

The isSpace() and isWhitespace() functions can be used to check if a character is a space or, more specifically, a whitespace. Whitespace is a subset of space. While whitespace includes only space and horizontal tab (‘\t’), space includes form feed (‘\f’), new line (‘’), carriage return (‘\r’) and even vertical ... Read More

Check if a character is a punctuation mark in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:12:55

175 Views

Just like there is a function to check if a character is alphanumeric or not, there is another one to check if a character is a punctuation mark or not. The name of the function is isPunct(). It takes a character as an input and returns a Boolean: true if the ... Read More

Check if a character is alphanumeric in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:12:30

594 Views

Depending on your use case, you may need to check if a character is alphanumeric or not in Arduino. One example can be validating password strings, wherein you’ve allowed only alphanumeric characters for passwords. Or checking file names for storage in SD Card (sometimes some special characters are not allowed ... Read More

Bitwise XOR in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:12:06

2K+ Views

Just like other bitwise operators, bitwise XOR also applies on the corresponding bits individually.The operator is ^ and the syntax is, a ^ bwhere a and b are the two numbers to be XORed.The truth table for XOR is given below −PQP^Q000011101110As you can see, the XOR operator returns 1 ... Read More

Logical NOT in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:11:41

3K+ Views

Logical NOT is performed using the ! operator. The truth table is given below −ExpressionOutputTFFTAs you can see, the logical NOT inverts the truth value of the expression.ExampleThe usage can be understood from the example given below −void setup() {    // put your setup code here, to run once: ... Read More

Bitwise NOT in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:11:19

843 Views

Unlike logical NOT, which inverts the truth value of an expression, the bitwise NOT applies to each bit of a number and inverts its value (0 to 1 and 1 to 0). The operator is ~.The syntax thus is ~a, where a is the number on which this operator has ... Read More

Logical AND and OR in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:10:39

12K+ Views

The logical AND is denoted by the && operator, while the logical OR is denoted by the || operator.SyntaxExpression1 && Expression2ORExpression1 || Expression2Where expression1 and expression2 evaluate to Boolean values (true or false). The output of these statements is determined by the truth tables of logical AND and OR.The truth ... Read More

Get max and min values of an array in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 14:29:15

8K+ Views

In order to get the max/ min values of an array in Arduino, we can run a simple for loop. Two implementations are shown below. One uses the max() and min() functions of Arduino, and the other uses the > and < operators.The max and min functions have the following ... Read More

Exponential expressions in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 14:28:57

4K+ Views

The pow() function of Arduino can be used for evaluating exponential expressions. Any expression of the form ab can be expressed as pow(a, b). For example 23 becomes pow(2, 3).The type for both the base (a) and the exponent (b) is float. This function returns a double.Examplevoid setup() {   ... Read More

Advertisements