Yash Sanghvi has Published 220 Answers

Interfacing an ultrasonic sensor with Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 15:01:09

In this tutorial, we will interface the ultrasonic sensor HC-SR04 with the Arduino to get the distance from a surface in centimetres.Circuit DiagramAs you can see, you need to connect the Vcc pin of HC-SR04 to 5V, GND to GND, Trig pin to pin 7 of Arduino Uno, and Echo ... Read More

Read a specific bit of a number with Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 15:00:22

Each number has a specific binary representation. For example, 8 can be represented as 0b1000, 15 can be represented as 0b1111, and so on. If you wish to read a specific bit of a number, Arduino has an inbuilt method for it.SyntaxbitRead(x, index)where, x is the number whose bits you ... Read More

Interfacing a speaker with Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:59:20

In this tutorial, we will interface a simple piezo-buzzer with Arduino to create beeping sounds. Such an arrangement can be used in applications like burglar alarms, or water level indicators or such similar projects.Circuit DiagramAs you can see, the circuit diagram is quite straightforward. You need to connect the buzzer’s ... Read More

Getting data from temperature and humidity sensor using Arduino

Yash Sanghvi

Yash Sanghvi

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

In this tutorial, we will interface Arduino DHT-22 Temperature and Humidity Sensor and print the obtained temperature and humidity values on the Serial Monitor.Circuit DiagramWhen the DHT-22 is facing you, the first pin from the left, the VCC pin is connected to 5V, the next pin is the DATA pin, ... Read More

Getting data from Vibration sensor using Arduino

Yash Sanghvi

Yash Sanghvi

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

In this tutorial, we will interface Arduino with the MPU6050 Vibration sensor.Circuit DiagramAs you can see, we connect Vcc to 3.3V, GND to GND, SDA to A4 and SCL to A5. A4 and A5 also serve as SDA and SCL on Arduino Uno.Code WalkthroughThe code is given below −#include<Wire.h> ... Read More

Displaying data on OLED Screen using Arduino

Yash Sanghvi

Yash Sanghvi

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

In this tutorial, we will interface Arduino with the SSD 1306 OLED Display.Circuit DiagramAs you can see, we connect Vcc to 3.3V, GND to GND, SDA to A4 and SCL to A5. A4 and A5 also serve as SDA and SCL on Arduino Uno.Required LibrariesThe following libraries will be required ... Read More

Interfacing GNSS receiver with Arduino to get speed

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:45:34

In this tutorial, we will interface Arduino with a GNSS Receiver and obtain the speed. If possible, you can run this code in a moving vehicle, because otherwise you will get 0 speed if your GNSS receiver is stationary. Any GNSS receiver generally uses UART for communication. We will be ... Read More

Map a 10-bit number to 8-bit in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:45:03

Mappings often have to be performed in Arduino for a variety of reasons. One example would be mapping the 10-bit ADC output to 8-bit to save on storage. A 10-bit number would occupy 2-bytes for storage, whereas an 8-bit number would occupy just one byte and still preserve most of ... Read More

Check if a character is printable in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 31-May-2021 14:43:23

Through various operations, you may come across characters which are not printable. After all, a char is an 8-bit number, and if you look at the ASCII table (https://www.cs.cmu.edu/~pattis/15-1XX/common/handouts/ascii.html), only the values from 32 to 127, or a total of 96 values out of 127 are printable (see http://facweb.cs.depaul.edu/sjost/it212/documents/ascii-pr.htm).  ASCII ... Read More

Enable and disable interrupts in Arduino

Yash Sanghvi

Yash Sanghvi

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

If you wish to disable interrupts (when executing some critical piece of code, especially one which should be completed within a given time period), you can do that with the help of the noInterrupts() function.Once your critical code has executed and you wish to re-enable the interrupts, you can do ... Read More

Advertisements