Found 112 Articles for Arduino Programming Language

Read a specific bit of a number with Arduino

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 are reading, index is the bit to read. 0 corresponds to least significant (right-most) bit, and so on.This function returns either 0 or 1 depending on the value of that bit in that number.ExampleThe following example will illustrate the use of this function −void setup() {    // put your setup ... Read More

Interfacing an ultrasonic sensor with Arduino

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 pin to pin 6 of Arduino. You can actually choose any GPIO instead of pins 7 and 6. You just have to make sure that the definitions in the code are proper.Working of HC-SR04The HC-SR04 emits ultrasonic waves at 40, 000 Hz. In order to make it emit waves, we ... Read More

Interfacing a speaker with Arduino

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 GND to Arduino’s GND, and the other wire to one GPIO of the Arduino (we have chosen pin 7). You can optionally add a small resistor (~100 Ohm), between the GPIO and the buzzer.Code WalkthroughThe entire code is given below −#define buzzerPin 7               ... Read More

Getting data from temperature and humidity sensor using Arduino

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, and it is connected to pin 2 on Arduino Uno. The third pin is Not Connected. The 4th pin, GND, is connected to GND on Arduino. A 10K resistor is to be connected between the DATA pin and the Vcc pin of DHT22, as you can see in the above ... Read More

Getting data from Vibration sensor using Arduino

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 const int MPU_ADDR = 0x68; // I2C address of the MPU-6050 int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ; void setup() {    Serial.begin(9600);    Wire.begin();    Wire.beginTransmission(MPU_ADDR);    Wire.write(0x6B); // PWR_MGMT_1 register    Wire.write(0); // set to zero (wakes up the MPU-6050)    Wire.endTransmission(true);    Serial.println("Setup complete"); } ... Read More

Displaying data on OLED Screen using Arduino

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 for interfacing Arduino Uno with the OLED Display −Adafruit SSD1306Adafruit GFXAdafruit BusIO (required by Adafruit GFX)Go to Tools → Manage Libraries, search for these libraries and click Install.ExampleThe code is given below −#include #include #include #define WIDTH 128 // OLED width (pixels) #define HEIGHT 64 // ... Read More

Interfacing GNSS receiver with Arduino to get speed

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 using the ublox Neo-6M GNSS module for thisCircuit DiagramAs you can see, we connect Vcc to 5V, GND to GND, RX of the Neo 6M to pin 3 of Arduino Uno, and TX of Neo 6M to pin 4 of Arduino Uno.Required LibrariesTinyGPS library will be required for interfacing Arduino ... Read More

Interfacing GNSS receiver with Arduino to get location

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 Neo 6M to pin 3 of Arduino Uno, and TX of Neo 6M to pin 4 of Arduino Uno.Required LibrariesTinyGPS library will be required for interfacing Arduino Uno with the OLED Display −Go to Tools → Manage Libraries, search for this library, and click Install.Code WalkthroughWe will walkthrough an example ... Read More

Controlling a Servo Motor with Arduino

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 Vcc of the Servo (typically red) is connected to 5V, GND (typically black) to GND, and the signal pin (white in the above image, typically white or yellow or orange) is connected to pin 9 of the Arduino.Code WalkthroughWe will be walking through an example code that comes in with ... Read More

Controlling a Stepper Motor with Arduino

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 discretely, in step angles.Circuit DiagramThe circuit diagram and the required components for both Unipolar and Bipolar stepper motors can be found here − https://www.arduino.cc/en/Tutorial/LibraryExamples/StepperOneRevolutionNote that the stepper motor is connected to pins 8-11 of Arduino Uno, via a Darlington Array (for unipolar stepper) or H-bridge (for bipolar stepper). The stepper ... Read More
1 2 3 4 5 6 7 ... 12 Next
Advertisements