Yash Sanghvi has Published 220 Answers

Detach interrupts from a source in Arduino

Yash Sanghvi

Yash Sanghvi

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

We have seen that in order to attach interrupts to a source, we use the .attachInterrupt() function, with the required arguments.For example, for attaching the interrupts to a specific pin, we useattachInterrupt(digitalPinToInterrupt(pin), ISR, mode);In the same way, to detach the interrupt from a source, we can call the detachInterrupt() function. ... Read More

Interfacing GNSS receiver with Arduino to get location

Yash Sanghvi

Yash Sanghvi

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

In this tutorial, we will interface Arduino with a GNSS Receiver and obtain the current location. Any GNSS receiver generally uses UART for communication. We will be using the ublox Neo6M GNSS module for thisCircuit DiagramAs you can see, we connect Vcc to 5V, GND to GND, RX of the ... Read More

Controlling a DC Motor with Arduino

Yash Sanghvi

Yash Sanghvi

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

A DC Motor is the simplest kind of motor. It has two terminals or leads. When connected with a battery the motor will rotate, and if the connections are reversed, the motor will rotate in the opposite direction. If the voltage across the terminals is reduced, the motor speed will ... Read More

Controlling a Stepper Motor with Arduino

Yash Sanghvi

Yash Sanghvi

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

A stepper motor divides the full rotation into a number of discrete steps, ranging from as low as 12 to as high as 200 steps per revolution (corresponding to angles of 30 degrees per step to 1.8 degrees per step). While a DC motor rotates continuously, a stepper motor rotates ... Read More

Controlling a Servo Motor with Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:38:58

A servo motor has a shaft that can be, using coded signals, positioned to specific angular positions. Luckily for us, we won’t have to understand the coded signals required to rotate the shaft to a specific angle. The Arduino Servo library does it for us.Circuit DiagramAs you can see, the ... Read More

Clear/Set a specific bit of a number in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:38:36

When you delve into advanced firmware, you deal with a lot of registers, whose specific bits need to be set or cleared depending on your use case. Arduino has inbuild functions to do that.SyntaxbitSet(x, index)and, bitClear(x, index)Where x is the number whose bit has to be set/ cleared and index ... Read More

Constrain a number within a given range in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:18:08

The constrain() function in Arduino helps to, as the name suggests, constrain a number between an upper bound and a lower bound.Syntaxconstrain(val, min, max)where, val is the number to be constrained, min is the lower bound value, and max is the upper bound valueIf val is less than min, this ... Read More

Bitwise Right/ left shift numbers in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:17:17

If you are a firmware developer, then shifting numbers, or registers by certain number of bits may be quite common for you. In Arduino as well, the same bit shift operators can be used, that are used in the C language, namely << for left shift and >> for right shift.Syntaxx ... Read More

Modulo / Remainder in Arduino

Yash Sanghvi

Yash Sanghvi

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

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

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 (‘\n’), carriage return (‘\r’) and even vertical ... Read More

Advertisements