Yash Sanghvi has Published 220 Answers

Check if a character is a punctuation mark in Arduino

Yash Sanghvi

Yash Sanghvi

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

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

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

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

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

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

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

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

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

Basic analogRead in Arduino Program

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 14:27:05

Converting analog values to digital is a common requirement from microcontrollers in general, and Arduino is no different. Arduino IDE has a built-in analogRead function to facilitate the conversion of analog values to digital.From the programming perspective, the only thing you require to know is the pins of your microcontroller that ... Read More

Bitwise AND and OR in Arduino

Yash Sanghvi

Yash Sanghvi

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

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

Advertisements