Yash Sanghvi has Published 192 Articles

Check if a character is alphanumeric in Arduino

Yash Sanghvi

Yash Sanghvi

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

881 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

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

1K+ 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

15K+ 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

10K+ 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

5K+ 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

Bitwise AND and OR in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 14:26:50

1K+ Views

Bitwise AND/ OR means AND/ OR performed at a bit-level, individually. Each number has its binary representation. When you perform the bitwise AND of one number with another, the AND operation is performed on the corresponding bits of the two numbers. Thus, LSB of number 1 is ANDed with the ... Read More

Do-while loop in Arduino

Yash Sanghvi

Yash Sanghvi

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

2K+ Views

The do-while loop’s syntax in Arduino is similar to the syntax in C. It is given below −do{    //Code } while (condition);Note the semicolon at the end.Examplevoid setup() {    // put your setup code here, to run once:    Serial.begin(9600);    Serial.println();    int i = 5;   ... Read More

Timer registers in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 14:03:08

7K+ Views

In a previous article, we used the TimerOne library to add timer interrupts to Arduino. But what if we wish to generate timer interrupts without a third-party library? In that case, you will directly have to meddle with the timer registers in Arduino. In this article, we will just introduce ... Read More

Square and Square root in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 14:02:50

4K+ Views

Arduino has support for several popular math functions, square and square root being among them. Let’s look at the square root first.Syntaxsqrt(x)where x is a number of any data type. It returns a double.For square, you ideally shouldn’t need a separate function. You can just multiply the number by itself.x_squared = ... Read More

Advertisements