<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Akshay Jain</title>
    <description>The latest articles on DEV Community by Akshay Jain (@akshay_jain).</description>
    <link>https://dev.to/akshay_jain</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1489699%2F54ac2f6b-a1e3-47e2-a897-11bf89afa477.png</url>
      <title>DEV Community: Akshay Jain</title>
      <link>https://dev.to/akshay_jain</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akshay_jain"/>
    <language>en</language>
    <item>
      <title>Building a UWB Distance Monitoring and Alert System with Arduino</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Mon, 19 Oct 2026 07:28:27 +0000</pubDate>
      <link>https://dev.to/akshay_jain/building-a-uwb-distance-monitoring-and-alert-system-with-arduino-eb3</link>
      <guid>https://dev.to/akshay_jain/building-a-uwb-distance-monitoring-and-alert-system-with-arduino-eb3</guid>
      <description>&lt;p&gt;Measuring the distance between two points wirelessly can be useful in proximity detection, object monitoring, and embedded automation projects. While ultrasonic sensors and infrared sensors are common choices for short-range distance measurement, Ultra-Wideband (UWB) technology offers another approach for applications that require wireless ranging.&lt;/p&gt;

&lt;p&gt;In this project, I built a UWB-based distance monitoring and alert system using an Arduino UNO and two REYAX RYUW122_Lite UWB modules. The system measures the distance between an Anchor and a Tag, displays the reading on a 16×2 I2C LCD, and activates a buzzer when the distance exceeds a predefined threshold.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;The project consists of two UWB modules, an Arduino UNO, an LCD, and a buzzer.&lt;/p&gt;

&lt;p&gt;One RYUW122_Lite module operates as the Anchor and connects to the Arduino through UART communication. The second module operates as the Tag. The Anchor requests a distance measurement and receives the ranging result from the Tag.&lt;/p&gt;

&lt;p&gt;The Arduino processes the returned distance, displays it in centimeters, and checks whether it exceeds the configured threshold of 200 cm. If the distance crosses that limit, the buzzer activates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Components Required
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Arduino UNO&lt;/li&gt;
&lt;li&gt;2 × REYAX RYUW122_Lite UWB modules&lt;/li&gt;
&lt;li&gt;16×2 I2C LCD&lt;/li&gt;
&lt;li&gt;Active-low buzzer module&lt;/li&gt;
&lt;li&gt;Logic-level shifter for UART communication&lt;/li&gt;
&lt;li&gt;Regulated 3.3 V power supply for the UWB modules&lt;/li&gt;
&lt;li&gt;Jumper wires and breadboard&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Understanding REYAX RYUW122_Lite UWB Module
&lt;/h2&gt;

&lt;p&gt;The REYAX RYUW122_Lite is a UWB antenna transceiver module. The module can be configured using UART AT commands, making it suitable for microcontroller-based projects. It supports distance measurement between an Anchor and a Tag and can achieve approximately 10 cm accuracy under suitable conditions. Actual performance depends on the environment, antenna placement, and obstacles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hardware Connections
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Connecting the Anchor to Arduino UNO
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo5zrmjq7brvhlzp8etrl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo5zrmjq7brvhlzp8etrl.png" alt=" " width="655" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Anchor communicates with the Arduino using UART. Since the RYUW122_Lite operates at 3.3 V and the Arduino UNO uses 5 V logic, a suitable logic-level shifter should be used for the UART signal connections.&lt;/p&gt;

&lt;p&gt;Connect the Anchor's TXD pin through the level shifter to Arduino D9, configured as the software serial RX pin. Connect Arduino D10, configured as the software serial TX pin, through the level shifter to the Anchor's RXD pin.&lt;/p&gt;

&lt;p&gt;Power the Anchor using a regulated 3.3 V supply and connect its ground to Arduino GND.&lt;/p&gt;

&lt;h3&gt;
  
  
  Connecting the LCD
&lt;/h3&gt;

&lt;p&gt;The 16×2 I2C LCD uses four connections. Connect VCC to 5 V, GND to GND, SDA to Arduino A4, and SCL to Arduino A5. If the LCD's A0, A1, and A2 address jumpers are open, its I2C address is &lt;code&gt;0x27&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Connecting the Buzzer
&lt;/h3&gt;

&lt;p&gt;For the active-low buzzer module used in this setup, connect its positive terminal to the 5 V supply and its control/negative terminal to Arduino D2. The buzzer activates when D2 is driven LOW. Use a suitable transistor driver if the buzzer's current requirements exceed what an Arduino pin can safely handle.&lt;/p&gt;

&lt;h3&gt;
  
  
  Connecting the Tag
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0htkngncq73eokbwmr05.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0htkngncq73eokbwmr05.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The second UWB module is configured as the Tag and powered from a regulated 3.3 V supply. Connect its GND to ground. The Tag does not require a direct UART connection to the Arduino in this configuration.&lt;/p&gt;

&lt;p&gt;Never apply 5 V or 12 V directly to the module's 3.3 V power input.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring the UWB Modules
&lt;/h2&gt;

&lt;p&gt;Before running the Arduino sketch, configure the modules using a UART terminal that supports AT commands.&lt;/p&gt;

&lt;p&gt;Set the Anchor to Anchor mode using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AT+MODE=1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set the Tag to Tag mode using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AT+MODE=0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configure both modules with the same network ID. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AT+NETWORKID=1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the Arduino sketch uses a software serial baud rate of 9600, configure the Anchor's UART baud rate accordingly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AT+IPR=9600
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure the module addresses, network configuration, baud rate, and ranging command match the actual firmware and Arduino sketch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Arduino Software
&lt;/h2&gt;

&lt;p&gt;The Arduino sketch handles UART communication with the Anchor, receives the ranging response, extracts the distance, updates the LCD, and controls the buzzer.&lt;/p&gt;

&lt;p&gt;The project uses the SoftwareSerial library and the LiquidCrystal_I2C library by Frank de Brabander. The sketch should send a valid ranging request to the Anchor and parse the response returned by the module.&lt;/p&gt;

&lt;p&gt;For example, a ranging command may look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AT+ANCHOR_SEND=TAG,2,Hi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A response can look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+ANCHOR_RCV=TAG,2,Hi,50 cm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exact command and response format must match the module configuration and firmware. The Arduino code should also handle missing or invalid responses instead of interpreting them as valid distance measurements.&lt;/p&gt;

&lt;p&gt;Once the distance has been extracted, the program compares it with the 200 cm threshold. If the distance exceeds the limit, it activates the buzzer; otherwise, the alert remains inactive.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing the Project
&lt;/h2&gt;

&lt;p&gt;After completing the wiring and configuring both modules, upload the Arduino sketch and power on the system. The LCD should display the measured distance between the Anchor and Tag.&lt;/p&gt;

&lt;p&gt;Move the modules closer together and farther apart to check whether the displayed readings change accordingly. When the distance exceeds 200 cm, the buzzer should activate.&lt;/p&gt;

&lt;p&gt;Repeat the test in different positions and environments. Walls, obstacles, antenna orientation, and the surrounding environment can affect ranging performance, so it is worth observing how the readings behave under different conditions.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Could Be Improved?
&lt;/h2&gt;

&lt;p&gt;This project is a useful starting point, but there are several ways to extend it.&lt;/p&gt;

&lt;p&gt;Push buttons could be added to adjust the alert threshold without modifying the code. LEDs could indicate safe, warning, and alert states. Measurement filtering and separate trigger/reset thresholds could reduce repeated buzzer switching when readings fluctuate near the limit.&lt;/p&gt;

&lt;p&gt;Another extension would be to connect an ESP32 to a monitoring dashboard and record distance measurements over time. For a more advanced project, multiple Anchors could be explored for indoor positioning, provided the hardware configuration and ranging protocol support the intended positioning method.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Building this project provided a practical way to explore UWB ranging, UART communication, and Arduino-based alert systems. It demonstrates how two wireless modules can be used to measure distance and trigger an action when a predefined limit is crossed.&lt;/p&gt;

&lt;p&gt;For the complete project tutorial, including the hardware setup and implementation details, see &lt;a href="https://playwithcircuit.com/distance-monitoring-and-alert-system-using-ryuw122_lite-uwb-modules-and-arduino/" rel="noopener noreferrer"&gt;Distance Monitoring and Alert System Using RYUW122_Lite UWB Modules and Arduino&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Have you worked with UWB modules in an Arduino or ESP32 project? What applications or improvements would you explore next?&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>electronics</category>
      <category>tutorial</category>
      <category>devchallenge</category>
    </item>
    <item>
      <title>Ultrasonic Sensor HC-SR04 Ultrasonic Sensor HC-SR04 with Arduino: A Beginner's Guide to Distance Measurement</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Tue, 21 Jul 2026 09:16:14 +0000</pubDate>
      <link>https://dev.to/akshay_jain/ultrasonic-sensor-hc-sr04-ultrasonic-sensor-hc-sr04-with-arduino-a-beginners-guide-to-distance-4624</link>
      <guid>https://dev.to/akshay_jain/ultrasonic-sensor-hc-sr04-ultrasonic-sensor-hc-sr04-with-arduino-a-beginners-guide-to-distance-4624</guid>
      <description>&lt;p&gt;HC-SR04 ultrasonic sensor is one of the most popular sensors in the Arduino ecosystem because it makes measuring distance incredibly simple.&lt;/p&gt;

&lt;p&gt;The HC-SR04 uses ultrasonic sound waves (40 kHz) to determine how far an object is from the sensor. It works by transmitting sound waves, waiting for them to bounce back from an object, and calculating the distance based on the time taken for the echo to return.&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll learn what the HC-SR04 sensor is, how it works, its key specifications, real-world applications, and how to interface it with an Arduino UNO.&lt;/p&gt;

&lt;p&gt;This article is adapted from a project published on Play with Circuit, where we regularly share Arduino, ESP32, IoT, and embedded systems tutorials.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the HC-SR04 Ultrasonic Sensor?
&lt;/h2&gt;

&lt;p&gt;The HC-SR04 is a non-contact distance measurement sensor widely used in electronics and robotics projects. Since it uses ultrasonic waves instead of light, it performs reliably in different lighting conditions.&lt;/p&gt;

&lt;p&gt;The module contains an ultrasonic transmitter, an ultrasonic receiver, and onboard control circuitry. Whenever the Trigger pin receives a pulse, the sensor emits ultrasonic waves. These waves travel through the air, hit an object, and return to the receiver. The sensor then calculates the distance by measuring the travel time of the sound.&lt;/p&gt;

&lt;p&gt;One of the biggest advantages of the HC-SR04 is its simplicity. It requires only four pins and can be connected to an Arduino in just a few minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Features of HC-SR04
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Operating voltage: 5V DC&lt;/li&gt;
&lt;li&gt;Operating current: Approximately 15 mA&lt;/li&gt;
&lt;li&gt;Operating frequency: 40 kHz&lt;/li&gt;
&lt;li&gt;Measurement range: 3 cm to 300 cm&lt;/li&gt;
&lt;li&gt;Accuracy: Approximately ±3 mm&lt;/li&gt;
&lt;li&gt;Measuring angle: Less than 15 degrees&lt;/li&gt;
&lt;li&gt;Dimensions: 45 mm × 20 mm × 15 mm&lt;/li&gt;
&lt;li&gt;Supports non-contact distance measurement&lt;/li&gt;
&lt;li&gt;Low power consumption&lt;/li&gt;
&lt;li&gt;Easy interfacing with Arduino and other microcontrollers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These specifications make the HC-SR04 suitable for both beginner and advanced electronics projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  HC-SR04 Pinout
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fde3ljyccg1r6dmdpavgh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fde3ljyccg1r6dmdpavgh.jpg" alt=" " width="500" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The HC-SR04 has four pins:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;VCC: Provides power to the sensor and should be connected to 5V.&lt;/li&gt;
&lt;li&gt;Trig: Receives a 10-microsecond pulse to initiate distance measurement.&lt;/li&gt;
&lt;li&gt;Echo: Outputs a pulse whose width represents the distance to the object.&lt;/li&gt;
&lt;li&gt;GND: Connected to the ground of the Arduino.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because there are only four connections, the sensor is ideal for beginners learning about sensor interfacing.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does the HC-SR04 Work?
&lt;/h2&gt;

&lt;p&gt;The HC-SR04 operates using the principle of echolocation, which is similar to how bats and dolphins navigate.&lt;/p&gt;

&lt;p&gt;The process works as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Arduino sends a 10-microsecond pulse to the Trigger pin.&lt;/li&gt;
&lt;li&gt;The sensor emits ultrasonic waves at a frequency of 40 kHz.&lt;/li&gt;
&lt;li&gt;These sound waves travel through the air until they encounter an object.&lt;/li&gt;
&lt;li&gt;The waves reflect back toward the sensor.&lt;/li&gt;
&lt;li&gt;The Echo pin remains HIGH until the reflected signal is received.&lt;/li&gt;
&lt;li&gt;Arduino measures the pulse duration and calculates the distance.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The formula used to calculate distance is:&lt;/p&gt;

&lt;p&gt;Distance = (Time × Speed of Sound) ÷ 2&lt;/p&gt;

&lt;p&gt;For Arduino projects, a simplified equation is commonly used:&lt;/p&gt;

&lt;p&gt;Distance (cm) = Echo Time (µs) ÷ 58.3&lt;/p&gt;

&lt;p&gt;For example, if the Echo pulse duration is 1000 microseconds, the calculated distance is approximately 17 centimeters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Applications of HC-SR04
&lt;/h2&gt;

&lt;p&gt;The HC-SR04 is used in countless electronics projects. Some popular applications include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Obstacle avoiding robots&lt;/li&gt;
&lt;li&gt;Smart parking systems&lt;/li&gt;
&lt;li&gt;Water and liquid level monitoring&lt;/li&gt;
&lt;li&gt;Automatic door systems&lt;/li&gt;
&lt;li&gt;Home automation projects&lt;/li&gt;
&lt;li&gt;Security and alarm systems&lt;/li&gt;
&lt;li&gt;Drone navigation&lt;/li&gt;
&lt;li&gt;Object detection systems&lt;/li&gt;
&lt;li&gt;Smart dustbins&lt;/li&gt;
&lt;li&gt;Industrial automation solutions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Its versatility makes it one of the first sensors many makers add to their toolkit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hardware Required
&lt;/h2&gt;

&lt;p&gt;To build this project, you'll need the following components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arduino UNO (1)&lt;/li&gt;
&lt;li&gt;HC-SR04 Ultrasonic Sensor (1)&lt;/li&gt;
&lt;li&gt;16×2 LCD Display (1)&lt;/li&gt;
&lt;li&gt;10k Potentiometer (1)&lt;/li&gt;
&lt;li&gt;1k Resistor (1)&lt;/li&gt;
&lt;li&gt;Breadboard (1)&lt;/li&gt;
&lt;li&gt;Jumper Wires&lt;/li&gt;
&lt;li&gt;USB Cable for programming the Arduino&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Circuit Connections
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiwswj94tg567gr4ws8kt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiwswj94tg567gr4ws8kt.jpg" alt=" " width="800" height="504"&gt;&lt;/a&gt;&lt;br&gt;
Connect the HC-SR04 sensor as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;VCC → Arduino 5V&lt;/li&gt;
&lt;li&gt;Trig → Arduino Pin 6&lt;/li&gt;
&lt;li&gt;Echo → Arduino Pin 7&lt;/li&gt;
&lt;li&gt;GND → Arduino GND&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the LCD connections:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RS → Pin 12&lt;/li&gt;
&lt;li&gt;Enable → Pin 11&lt;/li&gt;
&lt;li&gt;D4 → Pin 5&lt;/li&gt;
&lt;li&gt;D5 → Pin 4&lt;/li&gt;
&lt;li&gt;D6 → Pin 3&lt;/li&gt;
&lt;li&gt;D7 → Pin 2&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Arduino continuously reads the distance from the HC-SR04 and displays it on the LCD in centimeters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips for Stable Readings
&lt;/h2&gt;

&lt;p&gt;Ultrasonic sensors can occasionally produce unstable values. To improve accuracy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the NewPing library.&lt;/li&gt;
&lt;li&gt;Average multiple readings.&lt;/li&gt;
&lt;li&gt;Ensure the sensor is firmly mounted.&lt;/li&gt;
&lt;li&gt;Avoid measuring soft or absorbent materials.&lt;/li&gt;
&lt;li&gt;Keep objects within the recommended measurement angle.&lt;/li&gt;
&lt;li&gt;Minimize electrical interference.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For most projects, averaging five to ten readings produces excellent results.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;The HC-SR04 remains one of the best sensors for learning Arduino and embedded systems. It introduces important concepts such as timing, sensor interfacing, signal processing, and real-time measurements while being inexpensive and easy to use.&lt;/p&gt;

&lt;p&gt;Whether you're building a robot, a parking assistant, or a liquid level monitoring system, the HC-SR04 is an excellent addition to your electronics toolbox.&lt;/p&gt;

&lt;p&gt;For the complete tutorial, including LCD integration, additional examples, and more Arduino projects, visit Play with Circuit:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://playwithcircuit.com/ultrasonic-sensor-hc-sr04-interfacing-with-arduino/" rel="noopener noreferrer"&gt;https://playwithcircuit.com/ultrasonic-sensor-hc-sr04-interfacing-with-arduino/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>electronics</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Long-Range Appliance Control System Using Arduino and LoRa</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Sun, 21 Jun 2026 15:28:51 +0000</pubDate>
      <link>https://dev.to/akshay_jain/long-range-appliance-control-system-using-arduino-and-lora-3jah</link>
      <guid>https://dev.to/akshay_jain/long-range-appliance-control-system-using-arduino-and-lora-3jah</guid>
      <description>&lt;p&gt;Most IoT projects depend on Wi-Fi and cloud services. But what if the device you want to control is located far away from your router, or internet connectivity isn't available at all?&lt;/p&gt;

&lt;p&gt;That's the question that led me to experiment with a long-range appliance control system using Arduino Nano and the Reyax RYLR999 LoRa module.&lt;/p&gt;

&lt;p&gt;The idea was simple:&lt;/p&gt;

&lt;p&gt;Can a smartphone control electrical appliances located hundreds of meters—or even kilometers—away without using Wi-Fi?&lt;/p&gt;

&lt;p&gt;The answer turned out to be yes.&lt;/p&gt;

&lt;p&gt;In this project, I combined Bluetooth Low Energy (BLE) and LoRa communication to create a wireless system capable of controlling a lamp and a fan remotely.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why LoRa?
&lt;/h2&gt;

&lt;p&gt;LoRa (Long Range Radio) is a wireless communication technology designed specifically for transmitting data over very large distances while consuming very little power.&lt;/p&gt;

&lt;p&gt;Unlike Bluetooth or Wi-Fi, LoRa is not intended for high-speed data transfer. Instead, it focuses on:&lt;/p&gt;

&lt;p&gt;Long communication range&lt;br&gt;
Low power consumption&lt;br&gt;
Reliable transmission&lt;br&gt;
Simple infrastructure&lt;/p&gt;

&lt;p&gt;The system consists of two separate nodes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Controller Node&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The controller node acts as the bridge between the smartphone and the LoRa network.&lt;/p&gt;

&lt;p&gt;A smartphone connects to the Reyax RYLR999 module using Bluetooth Low Energy through the LightBlue mobile application. Commands received from the phone are processed by an Arduino Nano and then transmitted over LoRa.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Target Node&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A second RYLR999 module receives the LoRa message and passes it to another Arduino Nano.&lt;/p&gt;

&lt;p&gt;The Arduino interprets the command and controls relay outputs connected to appliances.&lt;/p&gt;

&lt;p&gt;Relay channel 1 controls a 240V AC bulb.&lt;br&gt;
Relay channel 2 controls a 12V DC fan.&lt;/p&gt;

&lt;p&gt;After executing the command, the receiver sends a response back to the controller node, providing confirmation that the operation was successful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hardware Used&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Arduino Nano ×2&lt;br&gt;
Reyax RYLR999 LoRa + BLE Module ×2&lt;br&gt;
Bidirectional voltage level shifter ×2&lt;br&gt;
16×2 I2C LCD display ×2&lt;br&gt;
Two-channel relay module&lt;br&gt;
Jumper wires&lt;br&gt;
12V power supply&lt;br&gt;
12V DC fan&lt;br&gt;
240V AC bulb&lt;br&gt;
Why Use the RYLR999 Module?&lt;/p&gt;

&lt;p&gt;One thing I really liked about the Reyax RYLR999 module is that it combines two communication technologies inside a single module:&lt;/p&gt;

&lt;p&gt;Bluetooth Low Energy&lt;br&gt;
LoRa&lt;/p&gt;

&lt;p&gt;This allows the smartphone to communicate locally through BLE, while LoRa handles long-distance communication.&lt;/p&gt;

&lt;p&gt;Essentially, the module transforms short-range Bluetooth commands into long-range LoRa transmissions.&lt;/p&gt;

&lt;p&gt;Understanding the Communication Flow&lt;/p&gt;

&lt;p&gt;The sequence is fairly straightforward:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The smartphone sends a command through Bluetooth.&lt;/li&gt;
&lt;li&gt;The controller node receives the command.&lt;/li&gt;
&lt;li&gt;Arduino processes the message.&lt;/li&gt;
&lt;li&gt;The LoRa module transmits the command.&lt;/li&gt;
&lt;li&gt;The target node receives the message.&lt;/li&gt;
&lt;li&gt;Arduino activates the appropriate relay.&lt;/li&gt;
&lt;li&gt;The appliance switches ON or OFF.&lt;/li&gt;
&lt;li&gt;A confirmation response is sent back.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This creates a simple but reliable two-way communication system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Controller Connections
&lt;/h2&gt;

&lt;p&gt;The controller setup consists of:&lt;/p&gt;

&lt;p&gt;Arduino Nano&lt;br&gt;
RYLR999 Module&lt;br&gt;
Voltage Level Shifter&lt;br&gt;
I2C LCD&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foe34fizyoieh3nnl9ksp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foe34fizyoieh3nnl9ksp.png" alt=" " width="668" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Because the RYLR999 module operates with 3.3V logic while the Arduino uses 5V logic, a bidirectional level shifter is placed between them.&lt;/p&gt;

&lt;p&gt;The module's LoRa TX pin connects to the Arduino RX pin through the level shifter, and the Arduino TX pin connects back to the module's LoRa RX pin.&lt;/p&gt;

&lt;p&gt;SoftwareSerial communication is used for Bluetooth communication:&lt;/p&gt;

&lt;p&gt;D2 → BLE Transmit&lt;br&gt;
D3 → BLE Receive&lt;/p&gt;

&lt;p&gt;The I2C LCD uses:&lt;/p&gt;

&lt;p&gt;SDA → A4&lt;br&gt;
SCL → A5&lt;/p&gt;

&lt;p&gt;The display shows command and communication status information.&lt;/p&gt;

&lt;h2&gt;
  
  
  Target Connections
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frzwsse99689i3coin35r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frzwsse99689i3coin35r.png" alt=" " width="700" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The target node also uses an Arduino Nano and an RYLR999 module.&lt;/p&gt;

&lt;p&gt;This node continuously listens for LoRa packets.&lt;/p&gt;

&lt;p&gt;A two-channel relay module is connected to:&lt;/p&gt;

&lt;p&gt;D11 → Bulb control&lt;br&gt;
D12 → Fan control&lt;/p&gt;

&lt;p&gt;The relay module allows the Arduino to safely switch both AC and DC loads.&lt;/p&gt;

&lt;p&gt;A second I2C LCD provides feedback about received commands and appliance status.&lt;/p&gt;

&lt;p&gt;⚠️ Be careful when working with mains voltage. Disconnect power before wiring the AC bulb circuit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Is a Voltage Level Shifter Needed?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Arduino Nano uses 5V logic levels, while the RYLR999 module operates with 3.3V logic. Directly connecting them can damage the module.&lt;/p&gt;

&lt;p&gt;To safely interface both devices, a bidirectional voltage level shifter is used between the Arduino and the RYLR999.&lt;/p&gt;

&lt;p&gt;This ensures reliable serial communication without risking the hardware.&lt;/p&gt;

&lt;p&gt;Relays: Connecting the Digital World to Real Appliances&lt;/p&gt;

&lt;p&gt;Microcontrollers cannot directly control high-voltage devices.&lt;/p&gt;

&lt;p&gt;That's where relays come in.&lt;/p&gt;

&lt;p&gt;A relay acts as an electrically controlled switch. It allows a low-voltage signal from the Arduino to safely control:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AC loads such as bulbs&lt;/li&gt;
&lt;li&gt;DC loads such as fans and motors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This isolation makes the system much safer and more practical.&lt;/p&gt;

&lt;p&gt;Real-Time Feedback Using LCD Displays&lt;/p&gt;

&lt;p&gt;Both nodes include 16×2 I2C LCD displays.&lt;/p&gt;

&lt;p&gt;These displays show:&lt;/p&gt;

&lt;p&gt;System initialization&lt;br&gt;
Received commands&lt;br&gt;
LoRa transmission status&lt;br&gt;
Response messages&lt;/p&gt;

&lt;p&gt;Having visual feedback makes debugging and troubleshooting much easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  Commands Used
&lt;/h2&gt;

&lt;p&gt;The smartphone sends commands using the LightBlue BLE application.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;p&gt;*L1# → Turn bulb ON&lt;br&gt;
*L0# → Turn bulb OFF&lt;br&gt;
*F1# → Turn fan ON&lt;br&gt;
*F0# → Turn fan OFF&lt;/p&gt;

&lt;p&gt;After successful execution, the target node sends back:&lt;/p&gt;

&lt;p&gt;DONE&lt;/p&gt;

&lt;h2&gt;
  
  
  Potential Applications
&lt;/h2&gt;

&lt;p&gt;This architecture can easily be expanded for:&lt;/p&gt;

&lt;p&gt;Irrigation systems&lt;br&gt;
Warehouse automation&lt;br&gt;
Remote lighting&lt;br&gt;
Industrial control&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;I documented the complete project, including wiring diagrams, source code, and configuration steps, on &lt;strong&gt;Play with Circuit&lt;/strong&gt;, where I share tutorials on Arduino, embedded systems, and practical electronics projects.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>arduino</category>
      <category>iot</category>
    </item>
    <item>
      <title>Building a Smart Weather Monitoring System with ESP32-S3 and LVGL</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Fri, 19 Jun 2026 06:13:31 +0000</pubDate>
      <link>https://dev.to/akshay_jain/building-a-smart-weather-monitoring-system-with-esp32-s3-and-lvgl-1l1j</link>
      <guid>https://dev.to/akshay_jain/building-a-smart-weather-monitoring-system-with-esp32-s3-and-lvgl-1l1j</guid>
      <description>&lt;p&gt;In this project, I built a weather monitoring system using an ESP32-S3 Smart Display, a BME280 sensor, a rain sensor, and an LDR module. The system continuously measures environmental conditions and presents the information through a graphical interface created with LVGL.&lt;/p&gt;

&lt;p&gt;Besides providing live weather information, this project serves as a great example of combining sensor interfacing with embedded GUI development.&lt;/p&gt;




&lt;h1&gt;
  
  
  System Overview
&lt;/h1&gt;

&lt;p&gt;The weather station performs three major tasks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Acquiring environmental measurements.&lt;/li&gt;
&lt;li&gt;Processing sensor data.&lt;/li&gt;
&lt;li&gt;Displaying information on a graphical dashboard.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The ESP32-S3 acts as the processing unit while LVGL provides the user interface.&lt;/p&gt;




&lt;h1&gt;
  
  
  How the System Works
&lt;/h1&gt;

&lt;p&gt;The sensors continuously collect information from the environment. The ESP32-S3 processes the measurements and updates the dashboard in real time.&lt;/p&gt;

&lt;p&gt;The complete workflow consists of:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Environmental data acquisition.&lt;/li&gt;
&lt;li&gt;Sensor processing.&lt;/li&gt;
&lt;li&gt;Graphical visualization.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Acquiring Environmental Data
&lt;/h2&gt;

&lt;p&gt;Three sensors are used to monitor weather conditions.&lt;/p&gt;

&lt;h3&gt;
  
  
  BME280 Sensor
&lt;/h3&gt;

&lt;p&gt;The BME280 provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Temperature&lt;/li&gt;
&lt;li&gt;Relative humidity&lt;/li&gt;
&lt;li&gt;Atmospheric pressure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pressure measurements are also used to estimate altitude.&lt;/p&gt;

&lt;p&gt;Communication with the controller takes place through the I2C interface.&lt;/p&gt;




&lt;h3&gt;
  
  
  Rain Sensor
&lt;/h3&gt;

&lt;p&gt;Rain detection is performed using a conductive rain sensor.&lt;/p&gt;

&lt;p&gt;Water droplets modify the conductivity of the sensor plate, producing changes in the output voltage. By monitoring these changes, the system determines whether rainfall is present.&lt;/p&gt;




&lt;h3&gt;
  
  
  Light Sensor
&lt;/h3&gt;

&lt;p&gt;An LDR module is used to detect ambient light conditions.&lt;/p&gt;

&lt;p&gt;Since the resistance of the photoresistor changes with illumination intensity, the controller can distinguish between daytime and nighttime conditions.&lt;/p&gt;




&lt;h1&gt;
  
  
  Sensor Processing
&lt;/h1&gt;

&lt;p&gt;The ESP32-S3 performs several tasks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reading BME280 measurements.&lt;/li&gt;
&lt;li&gt;Acquiring analog values from the rain sensor.&lt;/li&gt;
&lt;li&gt;Measuring ambient light intensity.&lt;/li&gt;
&lt;li&gt;Calculating altitude from pressure values.&lt;/li&gt;
&lt;li&gt;Determining rain status.&lt;/li&gt;
&lt;li&gt;Detecting day and night conditions.&lt;/li&gt;
&lt;li&gt;Updating the graphical interface.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Continuous processing ensures that the dashboard always reflects current environmental conditions.&lt;/p&gt;




&lt;h1&gt;
  
  
  Visualizing Data with LVGL
&lt;/h1&gt;

&lt;p&gt;Instead of showing plain numerical values, the project uses LVGL to create a more user-friendly interface.&lt;/p&gt;

&lt;p&gt;The dashboard displays:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Temperature&lt;/li&gt;
&lt;li&gt;Humidity&lt;/li&gt;
&lt;li&gt;Pressure&lt;/li&gt;
&lt;li&gt;Altitude&lt;/li&gt;
&lt;li&gt;Rain status&lt;/li&gt;
&lt;li&gt;Day/night indication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Icons and labels make the information easier to interpret and provide a more polished user experience.&lt;/p&gt;




&lt;h1&gt;
  
  
  Hardware Requirements
&lt;/h1&gt;

&lt;p&gt;The project uses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ESP32-S3 Smart Display&lt;/li&gt;
&lt;li&gt;BME280 Sensor&lt;/li&gt;
&lt;li&gt;Rain Sensor&lt;/li&gt;
&lt;li&gt;LDR Module&lt;/li&gt;
&lt;li&gt;Breadboard&lt;/li&gt;
&lt;li&gt;Jumper Wires&lt;/li&gt;
&lt;li&gt;USB Cable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since the display module contains both the controller and the screen, the overall hardware remains compact.&lt;/p&gt;




&lt;h1&gt;
  
  
  Software Requirements
&lt;/h1&gt;

&lt;p&gt;Development is performed using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visual Studio Code&lt;/li&gt;
&lt;li&gt;ESP-IDF Extension&lt;/li&gt;
&lt;li&gt;ESP-IDF v5.3.5&lt;/li&gt;
&lt;li&gt;Python 3.11&lt;/li&gt;
&lt;li&gt;Bosch BME280 Library&lt;/li&gt;
&lt;li&gt;LVGL v8&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These components provide support for sensor communication and graphical rendering.&lt;/p&gt;




&lt;h1&gt;
  
  
  Circuit Connections
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdlon4jzq4febygjzyixx.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdlon4jzq4febygjzyixx.jpg" alt=" " width="700" height="600"&gt;&lt;/a&gt;&lt;br&gt;
The BME280 communicates with the ESP32-S3 over the I2C bus.&lt;/p&gt;

&lt;p&gt;Connections:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;VCC → 3.3 V&lt;/li&gt;
&lt;li&gt;GND → GND&lt;/li&gt;
&lt;li&gt;SDA → GPIO9&lt;/li&gt;
&lt;li&gt;SCL → GPIO10&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The rain sensor uses an analog output connected to GPIO7.&lt;/p&gt;

&lt;p&gt;Connections:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;VCC → 3.3 V&lt;/li&gt;
&lt;li&gt;GND → GND&lt;/li&gt;
&lt;li&gt;AO → GPIO7&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The LDR module is connected to GPIO6.&lt;/p&gt;

&lt;p&gt;Connections:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;VCC → 3.3 V&lt;/li&gt;
&lt;li&gt;GND → GND&lt;/li&gt;
&lt;li&gt;AO → GPIO6&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All sensors share the same 3.3 V supply and common ground.&lt;/p&gt;




&lt;h1&gt;
  
  
  Software Architecture
&lt;/h1&gt;

&lt;p&gt;Although ESP-IDF contains many framework files, only a few modules are directly related to the application.&lt;/p&gt;

&lt;h2&gt;
  
  
  main.cpp
&lt;/h2&gt;

&lt;p&gt;This file acts as the application entry point.&lt;/p&gt;

&lt;p&gt;Responsibilities include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Display initialization.&lt;/li&gt;
&lt;li&gt;LVGL configuration.&lt;/li&gt;
&lt;li&gt;Sensor initialization.&lt;/li&gt;
&lt;li&gt;Dashboard creation.&lt;/li&gt;
&lt;li&gt;Real-time screen updates.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  sensors.c
&lt;/h2&gt;

&lt;p&gt;This module serves as the sensor abstraction layer.&lt;/p&gt;

&lt;p&gt;Functions include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reading BME280 measurements.&lt;/li&gt;
&lt;li&gt;Pressure-based altitude estimation.&lt;/li&gt;
&lt;li&gt;Rain sensor acquisition.&lt;/li&gt;
&lt;li&gt;Light intensity measurements.&lt;/li&gt;
&lt;li&gt;Environmental condition classification.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Separating sensor management from UI logic improves maintainability and simplifies future expansion.&lt;/p&gt;




&lt;h1&gt;
  
  
  Applications
&lt;/h1&gt;

&lt;p&gt;The same architecture can be extended for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smart home systems&lt;/li&gt;
&lt;li&gt;Greenhouse monitoring&lt;/li&gt;
&lt;li&gt;IoT dashboards&lt;/li&gt;
&lt;li&gt;Data logging&lt;/li&gt;
&lt;li&gt;Industrial monitoring&lt;/li&gt;
&lt;li&gt;Environmental sensing projects&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Video&lt;/p&gt;

&lt;h2&gt;
  
  
    &lt;iframe src="https://www.youtube.com/embed/od5DNXViYqA"&gt;
  &lt;/iframe&gt;

&lt;/h2&gt;

&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Combining an ESP32-S3 Smart Display with environmental sensors and LVGL makes it possible to build a compact and interactive weather station.&lt;/p&gt;

&lt;p&gt;Beyond simply displaying sensor values, the project demonstrates how embedded hardware and graphical interfaces can work together to create practical IoT applications.&lt;/p&gt;




&lt;h1&gt;
  
  
  Complete Project Resources
&lt;/h1&gt;

&lt;p&gt;Full project is available at &lt;strong&gt;&lt;em&gt;Play with Circuit&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Build a Weather Monitoring System Using ESP32-S3 Smart Display and LVGL&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://playwithcircuit.com/how-to-build-a-weather-monitoring-system-using-esp32-s3-smart-display-and-lvgl/" rel="noopener noreferrer"&gt;https://playwithcircuit.com/how-to-build-a-weather-monitoring-system-using-esp32-s3-smart-display-and-lvgl/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>iot</category>
      <category>showdev</category>
      <category>tutorial</category>
      <category>ui</category>
    </item>
    <item>
      <title>Controlling DC, Servo, and Stepper Motors Using L293D Motor Driver Shield with Arduino</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Fri, 13 Feb 2026 15:47:33 +0000</pubDate>
      <link>https://dev.to/akshay_jain/controlling-dc-servo-and-stepper-motors-using-l293d-motor-driver-shield-with-arduino-5hip</link>
      <guid>https://dev.to/akshay_jain/controlling-dc-servo-and-stepper-motors-using-l293d-motor-driver-shield-with-arduino-5hip</guid>
      <description>&lt;p&gt;Motor control is one of the most common requirements in robotics and automation projects. The L293D Motor Driver Shield makes this process simple by allowing an Arduino board to control multiple DC motors, stepper motors, and servo motors simultaneously — without complex wiring.&lt;/p&gt;

&lt;p&gt;In this overview, we’ll understand how the shield works and how it can be used to control speed and direction efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is L293D Motor Driver Shield?
&lt;/h2&gt;

&lt;p&gt;The L293D Motor Driver Shield is an expansion board designed to simplify motor interfacing with an Arduino Uno. It uses two L293D H-bridge driver ICs and a 74HC595 shift register to efficiently control multiple motors using limited Arduino pins.&lt;/p&gt;

&lt;p&gt;Each L293D IC can control:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Two DC motors&lt;/li&gt;
&lt;li&gt;Or one stepper motor&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since the shield includes two L293D ICs, it can control:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Up to 4 DC motors&lt;/li&gt;
&lt;li&gt;Or 2 stepper motors&lt;/li&gt;
&lt;li&gt;Plus 2 servo motors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each motor channel supports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Motor voltage: 4.5V to 24V&lt;/li&gt;
&lt;li&gt;Continuous current: 600mA per channel (1.2A peak)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Features&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drives up to 4 bidirectional DC motors&lt;/li&gt;
&lt;li&gt;Supports 2 unipolar or bipolar stepper motors&lt;/li&gt;
&lt;li&gt;Two dedicated servo headers&lt;/li&gt;
&lt;li&gt;5V logic compatible&lt;/li&gt;
&lt;li&gt;Pull-down resistor network for safe startup&lt;/li&gt;
&lt;li&gt;Power selection jumper for flexible supply options&lt;/li&gt;
&lt;li&gt;External motor power terminal (EXT_PWR)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  L293D Motor Driver Shield Hardware Overview
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fotdg59rbdc9ehim1tsg0.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fotdg59rbdc9ehim1tsg0.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pin Usage on Arduino UNO
&lt;/h2&gt;

&lt;p&gt;The shield occupies the following digital pins:&lt;/p&gt;

&lt;p&gt;D3, D4, D5, D6, D7, D8, D9, D10, D11, D12&lt;/p&gt;

&lt;p&gt;That leaves limited digital I/O, so analog pins (A0–A5) can be used as digital inputs when required.&lt;/p&gt;

&lt;h2&gt;
  
  
  Power Configuration Options
&lt;/h2&gt;

&lt;p&gt;The shield allows two powering methods:&lt;br&gt;
1️⃣ &lt;strong&gt;Single Supply Mode&lt;/strong&gt;&lt;br&gt;
If motors operate within 12V range, you can power both Arduino and shield from a single adapter via Arduino’s DC jack.&lt;br&gt;
(Keep the PWR jumper connected.)&lt;/p&gt;

&lt;p&gt;2️⃣ &lt;strong&gt;Separate Supply Mode&lt;/strong&gt;&lt;br&gt;
Remove the power jumper.&lt;br&gt;
Power Arduino via USB and motors via external supply connected to EXT_PWR terminal.&lt;/p&gt;

&lt;p&gt;⚠ &lt;strong&gt;Important:&lt;/strong&gt; Never keep the jumper installed when using external motor supply — it may cause a short circuit.&lt;/p&gt;
&lt;h2&gt;
  
  
  Wiring of DC motor with L293D shield and Arduino UNO
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmtus951123jy59i3fj6w.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmtus951123jy59i3fj6w.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pin Connections&lt;/strong&gt;&lt;br&gt;
5V - Vcc pin of LCD and pin 1 of POT&lt;br&gt;
Gnd - Gnd pin of LCD and pin 3 of POT&lt;br&gt;
A0 - pin 2 of POT&lt;br&gt;
A1 - Clockwise rotation Button&lt;br&gt;
A2 - Anti-Clockwise rotation Button&lt;br&gt;
A3 - Stop Button&lt;br&gt;
SCL - SCL pin of LCD&lt;br&gt;
SDA - SDA pin of LCD&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* 
Interfacing DC Motor with Arduino UNO using L293D motor Driver shield
by www.playwithcircuit.com 
*/
#include &amp;lt;AFMotor.h&amp;gt;
  // Library to run DC Motor Using Motor Driver Shield  
#include &amp;lt;LiquidCrystal_I2C.h&amp;gt; 
  // Library to Run I2C LCD
LiquidCrystal_I2C lcd(0x27, 16, 2);  // Format -&amp;gt; (Address,Columns,Rows )
// Create the motor object connected to M3
AF_DCMotor motor(3);
// Define button pins
const int forwardButtonPin = A1;
const int reverseButtonPin = A2;
const int stopButtonPin    = A3;
// Define potentiometer pin
const int potPin = A0;
// Variables to store motor state and direction
bool motorRunning  = false;
int motorDirection = BACKWARD;  // FORWARD or BACKWARD
// Read the potentiometer value
int potValue;
int motorSpeed;
// Variable to store button states
bool forwardButtonState;
bool stopButtonState;
bool reverseButtonState;
// Inline function to check if button is pressed packed with debouncing logic
inline bool chkButtonState(int pinNum, int checkState, int debounceDelay) {
  if (((digitalRead(pinNum) == checkState) ? true : false) == true) {
    delay(debounceDelay);
    return (((digitalRead(pinNum) == checkState) ? (true) : (false)) == true);
  } else {
    return false;
  }
}
void setup() {
  // initialize the lcd
  lcd.init();
  // Turn on the Backlight
  lcd.backlight();
  // Clear the display buffer
  lcd.clear();
  // Set cursor (Column, Row)
  lcd.setCursor(0, 0);
  lcd.print("DC Motor using");
  lcd.setCursor(0, 1);
  lcd.print("L293D Shield");
  // Set button pins as inputs
  pinMode(forwardButtonPin, INPUT_PULLUP);
  pinMode(stopButtonPin   , INPUT_PULLUP);
  pinMode(reverseButtonPin, INPUT_PULLUP);
  // Start with motor off
  motor.setSpeed(0);
  motor.run(RELEASE);
  delay(2000);
  // Clear the display buffer
  lcd.clear();
  // Set cursor (Column, Row)
  lcd.setCursor(0, 0);
  lcd.print("Motor Direction:");
  lcd.setCursor(0, 1);
  lcd.print("Stopped   ");
}
void loop() {
  // Read the potentiometer value for changing speed as per Analog input
  potValue   = analogRead(potPin);
  motorSpeed = map(potValue, 0, 1023, 0, 255);
  // Read the button states
  forwardButtonState = chkButtonState(forwardButtonPin, LOW, 20);
  reverseButtonState = chkButtonState(reverseButtonPin, LOW, 20);
  stopButtonState    = chkButtonState(stopButtonPin,    LOW, 20);
  // check for Forward run
  if (forwardButtonState &amp;amp;&amp;amp; (!motorRunning || motorDirection == BACKWARD)) {
    // Set cursor (Column, Row)
    lcd.setCursor(0, 1);
    lcd.print("Clock   ");
    if (motorDirection == BACKWARD) {
      motor.setSpeed(0);
      motor.run(RELEASE);
      delay(1000);
    }
    motorRunning = true;
    motorDirection = FORWARD;
    motor.setSpeed(motorSpeed);
    motor.run(FORWARD);
  }

  // check for Reverse run
  else if (reverseButtonState &amp;amp;&amp;amp; (!motorRunning || motorDirection == FORWARD)) {
    // Set cursor (Column, Row)
    lcd.setCursor(0, 1);
    lcd.print("Anti-Clk");
    if (motorDirection == FORWARD) {
      motor.setSpeed(0);
      motor.run(RELEASE);
      delay(1000);
    }
    motorRunning = true;
    motorDirection = BACKWARD;
    motor.setSpeed(motorSpeed);
    motor.run(BACKWARD);
  }

  // Stop motor
  else if (stopButtonState &amp;amp;&amp;amp; motorRunning) {
    // Set cursor (Column, Row)
    lcd.setCursor(0, 1);
    lcd.print("Stopped         ");
    motorRunning = false;
    motor.setSpeed(0);
    motor.run(RELEASE);
  }

  // Adjust motor speed if running and display speed on LCD
  if (motorRunning) {
    motor.setSpeed(motorSpeed);
    // Set cursor (Column, Row)
    lcd.setCursor(9, 1);
    lcd.print("SPD:");
    lcd.print(((motorSpeed*100)/255));
    lcd.print("%  ");
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For complete details on how to control servo and stepper motor including wiring diagrams, code examples, and detailed explanations, you can read the full step-by-step tutorial at &lt;strong&gt;&lt;em&gt;Play with Circuit&lt;/em&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://playwithcircuit.com/l293d-motor-driver-shield-arduino-tutorial/" rel="noopener noreferrer"&gt;https://playwithcircuit.com/l293d-motor-driver-shield-arduino-tutorial/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>arduino</category>
    </item>
    <item>
      <title>Micro SD Card Module with Arduino</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Tue, 16 Sep 2025 05:12:53 +0000</pubDate>
      <link>https://dev.to/akshay_jain/micro-sd-card-module-with-arduino-51kc</link>
      <guid>https://dev.to/akshay_jain/micro-sd-card-module-with-arduino-51kc</guid>
      <description>&lt;p&gt;Ever wanted to log real-time sensor data with your Arduino?&lt;br&gt;
Think of a weather station recording temperature and humidity every 10 seconds, or a smart irrigation system storing soil moisture levels throughout the day. Pretty soon, you’ll realize Arduino’s built-in memory just isn’t enough.&lt;/p&gt;

&lt;p&gt;So what’s the solution?&lt;br&gt;
👉 A Micro SD card module—the same tiny storage cards you use in cameras and phones. With this simple module, your Arduino projects get access to megabytes (even gigabytes!) of external storage. Perfect for projects that need data logging, tracking, or saving files.&lt;/p&gt;

&lt;p&gt;In this guide, we’ll walk you through how to interface a Micro SD card module with Arduino step by step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Micro SD Card Module Hardware Overview
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3z03d0qb27oci4z593b6.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3z03d0qb27oci4z593b6.PNG" alt=" " width="607" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A Micro SD card module is more than just a card slot. It includes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Micro SD Card Socket&lt;/strong&gt; – Where you insert the card. Most modules have clear markings to avoid wrong insertion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.3V LDO Voltage Regulator&lt;/strong&gt; – Since SD cards work at 3.3V, the regulator safely steps down Arduino’s 5V to 3.3V. This prevents damage while keeping voltage stable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Logic Level Shifter (74LVC125A)&lt;/strong&gt; – Acts as a translator that converts Arduino’s 5V logic signals to 3.3V for the SD card, ensuring safe and reliable communication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Micro SD Card Module Pinout&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here’s the pin configuration you’ll use while wiring it with Arduino:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frnif8bm6uuz9aw7raux6.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frnif8bm6uuz9aw7raux6.PNG" alt=" " width="573" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GND&lt;/strong&gt; → Connect to Arduino GND&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VCC&lt;/strong&gt; → Connect to 5V pin on Arduino&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MISO (Master In Slave Out)&lt;/strong&gt; → Sends data from SD card to Arduino&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MOSI (Master Out Slave In)&lt;/strong&gt; → Sends data from Arduino to SD card&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SCK (Serial Clock)&lt;/strong&gt; → Provides clock pulses from Arduino&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CS (Chip Select / Slave Select)&lt;/strong&gt; → Activates or deactivates the module on the SPI bus&lt;/p&gt;

&lt;h2&gt;
  
  
  Interfacing Micro SD Card Module with Arduino
&lt;/h2&gt;

&lt;p&gt;Now that you understand the module and its pins, let’s put it into action. We’ll interface the Micro SD card module with Arduino UNO and use an I2C LCD to display information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hardware Requirements&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arduino UNO R3&lt;/li&gt;
&lt;li&gt;LCD 16x2 (with I2C)&lt;/li&gt;
&lt;li&gt;Micro SD Card Module&lt;/li&gt;
&lt;li&gt;Micro SD Card&lt;/li&gt;
&lt;li&gt;Jumper Wires &lt;/li&gt;
&lt;li&gt;USB Cable Type A to B&lt;/li&gt;
&lt;li&gt;12V Adapter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Wiring Connections&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd05qrrtntw18xynomydy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd05qrrtntw18xynomydy.png" alt=" " width="641" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Micro SD card module communicates with Arduino using the SPI protocol. This means it relies on dedicated SPI pins—MOSI, MISO, SCK, and CS—to exchange data. While SD cards can also work over SDIO (Secure Digital Input Output), this tutorial focuses only on the SPI-based interface.&lt;/p&gt;

&lt;p&gt;Along with these communication pins, the module also needs power connections:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VCC (5V)&lt;/strong&gt; – to power the module&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GND&lt;/strong&gt; – to complete the circuit&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wiring Between Arduino UNO and SD Card Reader&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2zoz2nrgfmcpwykcuy2d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2zoz2nrgfmcpwykcuy2d.png" alt=" " width="457" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connecting the I2C LCD with Arduino&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Wiring the I2C LCD to Arduino is straightforward.&lt;/p&gt;

&lt;p&gt;Connect VCC and GND of the LCD to the respective VCC and GND pins on the Arduino.&lt;/p&gt;

&lt;p&gt;The two communication lines are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SCL (Clock)&lt;/strong&gt; → Connects to Arduino’s SCL pin (Analog pin A5)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SDA (Data)&lt;/strong&gt; → Connects to Arduino’s SDA pin (Analog pin A4)&lt;/p&gt;

&lt;p&gt;On the LCD’s back panel, these SCL and SDA pins are also marked and internally connected to A5 and A4 of the Arduino. In the provided wiring diagram, the pink wire is used for SCL and the blue wire for SDA.&lt;/p&gt;

&lt;p&gt;⚠️ &lt;strong&gt;Important Note:&lt;/strong&gt; Ensure that the A0, A1, and A2 address jumpers on the I2C LCD are not shorted. This is necessary because in the code we’ll be using the I2C address 0x27, which only works when these jumpers remain open.&lt;/p&gt;

&lt;h2&gt;
  
  
  Arduino Code for checking Micro SD card Information
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*
Code to get info about SD card and for testing if its working or not
by platwithcircuit.com
*/
#include &amp;lt;SPI.h&amp;gt;                
  // include SPI library header
#include &amp;lt;SD.h&amp;gt;                 
  // include the SD library header
#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;  
  // include I2C LCD library header
// set up variables using the SD utility library functions
Sd2Card card;
SdVolume volume;
SdFile root;
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int chipSelect = 10;
void setup() {
  // initialize the LCD
  lcd.init();
  // Turn ON the Backlight
  lcd.backlight();
  // Clear the display buffer
  lcd.clear();
  // Print a message to the LCD
  lcd.setCursor(0, 0);
  lcd.print("Initializing");
  lcd.setCursor(0, 1);
  lcd.print("SD Card...");
  // Open serial communications and wait for port to open
  Serial.begin(9600);
  while (!Serial) {
    ;  // wait for serial port to connect
  }
  Serial.print("\nInitializing SD card...");
  delay(1000);
  // we'll use the initialization code from the utility libraries
  // since we're just testing if the card is working!
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card inserted?");
    Serial.println("* is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Initialization");
    lcd.setCursor(0, 1);
    lcd.print("Failed");
    while (1)
      ;
  } else {
    Serial.println("Wiring is correct and a card is present.");
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Initialization");
    lcd.setCursor(0, 1);
    lcd.print("Successfull");
    delay(2000);
  }
  // print the type of card
  Serial.println();
  Serial.print("Card type:         ");
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Card Type:");
  lcd.setCursor(0, 1);
  switch (card.type()) {
    case SD_CARD_TYPE_SD1:
      Serial.println("SD1");
      lcd.print("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      lcd.print("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      lcd.print("SDHC");
      break;
    default:
      Serial.println("Unknown");
      lcd.print("Unknown");
  }
  delay(2000);
  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    while (1)
      ;
  }
  Serial.print("Clusters:          ");
  Serial.println(volume.clusterCount());

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Clusters:");
  lcd.setCursor(0, 1);
  lcd.print(volume.clusterCount()); 
  delay(2000);
  Serial.print("Blocks per Cluster:  ");
  Serial.println(volume.blocksPerCluster());
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Block per Clster");
  lcd.setCursor(0, 1);
  lcd.print(volume.blocksPerCluster()); 
  delay(2000);
  Serial.print("Total Blocks:      ");
  Serial.println(volume.blocksPerCluster() * volume.clusterCount());
  Serial.println();
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Total Blocks:");
  lcd.setCursor(0, 1);
  lcd.print(volume.blocksPerCluster() * volume.clusterCount()); 
  delay(2000);
  // print the type and size of the first FAT-type volume
  uint32_t volumesize;
  Serial.print("Volume type is:    FAT");
  Serial.println(volume.fatType(), DEC);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Volume type is:");
  lcd.setCursor(0, 1);
  lcd.print("FAT");
  lcd.print(volume.fatType(), DEC); 
  delay(2000);

  volumesize = volume.blocksPerCluster();  // clusters are collections of blocks
  volumesize *= volume.clusterCount();     // we'll have a lot of clusters
  volumesize /= 2;                         // SD card blocks are always 512 bytes (2 blocks are 1KB)
  Serial.print("Volume size (KB):  ");
  Serial.println(volumesize);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Volume size (KB):");
  lcd.setCursor(0, 1);
  lcd.print(volumesize); 
  delay(2000);
  Serial.print("Volume size (MB):  ");
  volumesize /= 1024;
  Serial.println(volumesize);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Volume size (MB):");
  lcd.setCursor(0, 1);
  lcd.print(volumesize); 
  delay(2000);
  Serial.print("Volume size (GB):  ");
  Serial.println((float)volumesize / 1024.0);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Volume size (GB):");
  lcd.setCursor(0, 1);
  lcd.print((float)volumesize / 1024.0); 
  delay(2000);
  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);
  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);
}
void loop(void) {
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Checkout this article to learn how to: &lt;a href="https://playwithcircuit.com/micro-sd-card-module-arduino-tutorial/" rel="noopener noreferrer"&gt;Read-Write Data on Micro SD Card&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>sdcard</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to use Flame Sensor Module with Arduino</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Fri, 13 Jun 2025 05:24:59 +0000</pubDate>
      <link>https://dev.to/akshay_jain/how-to-use-flame-sensor-module-with-arduino-4a67</link>
      <guid>https://dev.to/akshay_jain/how-to-use-flame-sensor-module-with-arduino-4a67</guid>
      <description>&lt;p&gt;In this tutorial, you’ll learn how to interface a flame sensor module with an Arduino to build a simple fire detection system. This system will monitor the presence of flames and trigger an alert using an alarm—ideal for DIY home safety or educational projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does a Flame Sensor Module Work?
&lt;/h2&gt;

&lt;p&gt;The flame sensor module operates by detecting infrared (IR) light—a type of thermal radiation emitted by flames and hot objects. At its core is a photodiode, which is sensitive to IR wavelengths. When a flame is present, the photodiode picks up the IR radiation.&lt;/p&gt;

&lt;p&gt;An onboard LM393 comparator IC processes this signal and compares it to a threshold value, which you can adjust using the module’s potentiometer. If the incoming IR signal exceeds the threshold, the digital output (DO) pin changes its state, indicating the presence of a flame.&lt;/p&gt;

&lt;p&gt;You can also use the analog output (AO) pin to measure how intense the IR radiation is. An onboard Signal LED lights up to visually indicate flame detection, and you can fine-tune the sensor’s response using the adjustable potentiometer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flame Sensor Module Specifications
&lt;/h2&gt;

&lt;p&gt;Here’s a quick look at the key specifications of the module:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operating Voltage:&lt;/strong&gt; 3.3V to 5V (compatible with Arduino and other MCUs)&lt;br&gt;
&lt;strong&gt;Detection Angle:&lt;/strong&gt; ~60°, suitable for focused flame detection&lt;br&gt;
&lt;strong&gt;Detection Range:&lt;/strong&gt; 1–2 meters depending on the flame size&lt;br&gt;
&lt;strong&gt;Sensitivity:&lt;/strong&gt; Adjustable via onboard potentiometer&lt;br&gt;
&lt;strong&gt;Form Factor:&lt;/strong&gt; Small and compact for easy integration&lt;/p&gt;
&lt;h2&gt;
  
  
  Hardware Overview of Flame Sensor Module
&lt;/h2&gt;

&lt;p&gt;Here’s what makes up the module:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwpbaas6385mv2usuycc5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwpbaas6385mv2usuycc5.png" alt=" "&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Photodiode:&lt;/strong&gt; Detects infrared light from flames.&lt;br&gt;
&lt;strong&gt;LM393 Comparator IC:&lt;/strong&gt; Converts the IR signal to a digital output based on a threshold.&lt;br&gt;
&lt;strong&gt;Potentiometer:&lt;/strong&gt; Adjusts the sensor’s sensitivity to suit your environment.&lt;br&gt;
&lt;strong&gt;Power LED:&lt;/strong&gt; Lights up when the module is powered.&lt;br&gt;
&lt;strong&gt;Signal LED:&lt;/strong&gt; Indicates flame detection (typically turns off when a flame is detected).&lt;/p&gt;
&lt;h2&gt;
  
  
  Flame Sensor Module Pinout
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx0bx457dokrgpagv0dzc.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx0bx457dokrgpagv0dzc.PNG" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VCC:&lt;/strong&gt; Power supply input (3.3V to 5V)&lt;br&gt;
&lt;strong&gt;GND:&lt;/strong&gt; Ground connection&lt;br&gt;
&lt;strong&gt;DO(Digital Output):&lt;/strong&gt; Outputs HIGH or LOW based on flame presence&lt;br&gt;
&lt;strong&gt;AO(Analog Output):&lt;/strong&gt; Outputs analog signal proportional to IR intensity&lt;/p&gt;
&lt;h2&gt;
  
  
  Wiring diagram when using Analog Output pin of Flame Sensor
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2d6ae0yovj5t2y5z5lwo.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2d6ae0yovj5t2y5z5lwo.PNG" alt=" "&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* 
Interfacing Flame Sensor with Arduino UNO using Analog input pin of Arduino and displaying fire detected on I2C LCD.
code by www.playwithcircuit.com
*/
#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;  // Library to Run I2C LCD
// Buzzer pin
#define BUZZER_PIN 11
// Maximum counts to detect the flame
#define FLAME_DETECT_COUNTS 300
// define the size of filter array
#define FILTER_SIZE 30
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Define the analog input pin, for the flame sensor's analog output
const int FlameSensorAnalogPin = A0;
// Variable to store the Analog count from flame sensor
int FlameCounts;
// Variable to store the Filtered Analog count from flame sensor
int filteredFlameCounts;
// Analog value filter
int Filter(int sensorValue);
void setup() {
  // initialize the LCD
  lcd.init();
  // Turn ON the Backlight
  lcd.backlight();
  // Clear the display buffer
  lcd.clear();
  // Make buzzer pin as output
  pinMode(BUZZER_PIN, OUTPUT);
  // Turn OFF buzzer pin
  digitalWrite(BUZZER_PIN, LOW);
  // Print a message to the LCD
  lcd.setCursor(0, 0);
  lcd.print("Initializing");
  // Print a message to the LCD
  lcd.setCursor(0, 1);
  lcd.print("Please Wait...");
  // flush out the first 100 values AND give time to flame sensor counts to be stable
  for (int i = 0; i &amp;lt; 100; i++) {
    // Read the value from the flame sensor
    FlameCounts = analogRead(FlameSensorAnalogPin);
    // Filter the input counts
    filteredFlameCounts = Filter(FlameCounts);
    delay(10);
  }
  // Clear the display buffer
  lcd.clear();
  // Print a message to the LCD
  lcd.setCursor(0, 0);
  lcd.print("Fire Detected:  ");
  // Print a message to the LCD
  lcd.setCursor(0, 1);
  lcd.print("                ");
}
void loop() {
  // Read the value from the flame sensor
  FlameCounts = analogRead(FlameSensorAnalogPin);
  // Filter the input counts
  filteredFlameCounts = Filter(FlameCounts);
  // if the counts are less than flame_detect_counts, the buzzer is activated
  // for this sensor when the flame is detected, the Analog counts decreases
  if (filteredFlameCounts &amp;lt; FLAME_DETECT_COUNTS) {
    lcd.setCursor(0, 1);
    lcd.print("YES");
    digitalWrite(BUZZER_PIN, !digitalRead(BUZZER_PIN));
    delay(100);
  } else {
    lcd.setCursor(0, 1);
    lcd.print("NO ");
    // Turn OFF buzzer pin
    digitalWrite(BUZZER_PIN, LOW);
    // Wait for 10ms before the next loop
    delay(10);
  }
}
// Averaging filter to filter Analog values
int Filter(int sensorValue) {
  static int analogArray[FILTER_SIZE] = { 0 };
  unsigned long int filteredValue = 0;
  int i;
  // Shift the element removing the oldest value stored at index 0
  for (i = 0; i &amp;lt; (FILTER_SIZE - 1); i++) {
    analogArray[i] = analogArray[i + 1];
  }
  // Put the current value in the last element of Array i.e. at index FILTER_SIZE-1
  analogArray[FILTER_SIZE - 1] = sensorValue;
  for (i = 0; i &amp;lt; FILTER_SIZE; i++) {
    filteredValue += analogArray[i];
  }
  // Return Filtered Analog value
  return (filteredValue / FILTER_SIZE);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;To learn more checkout: &lt;strong&gt;&lt;a href="https://playwithcircuit.com/flame-sensor-module-arduino-tutorial/" rel="noopener noreferrer"&gt;Flame Sensor Module with Arduino&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Output
&lt;/h2&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
      &lt;div class="c-embed__body flex items-center justify-between"&gt;
        &lt;a href="https://playwithcircuit.com/wp-content/uploads/2025/05/Interfacing-Flame-Sensor-Module-with-Arduino.mp4" rel="noopener noreferrer" class="c-link fw-bold flex items-center"&gt;
          &lt;span class="mr-2"&gt;playwithcircuit.com&lt;/span&gt;
          

        &lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



</description>
      <category>programming</category>
      <category>arduino</category>
      <category>beginners</category>
      <category>coding</category>
    </item>
    <item>
      <title>LM35 Temperature Sensor with Arduino</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Thu, 05 Jun 2025 16:07:43 +0000</pubDate>
      <link>https://dev.to/akshay_jain/lm35-temperature-sensor-with-arduino-4671</link>
      <guid>https://dev.to/akshay_jain/lm35-temperature-sensor-with-arduino-4671</guid>
      <description>&lt;p&gt;The LM35 is a popular temperature sensor known for its accuracy, and low cost. It provides a linear voltage output directly proportional to temperature and doesn't require any external calibration or signal conditioning, making it ideal for Arduino projects.&lt;/p&gt;

&lt;p&gt;In this tutorial, you'll learn how to interface the LM35 sensor with an Arduino UNO. We'll build a simple temperature monitoring system that measures the temperature and displays it in both Celsius and Fahrenheit. The temperature readings will be shown in real-time and shown on a 16×2 LCD display.&lt;/p&gt;

&lt;h2&gt;
  
  
  LM35 Temperature Sensor Overview
&lt;/h2&gt;

&lt;p&gt;The LM35 is a precision analog temperature sensor that provides a voltage output linearly proportional to temperature in degrees Celsius (°C). One of the biggest advantages of the LM35 is its 10 mV/°C linear output, making it easy to interface with ADCs or microcontrollers like the Arduino. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LM35 Sensor Specifications&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Operating Voltage: 4V to 30V&lt;/li&gt;
&lt;li&gt;Temperature Range: -55°C to +150°C&lt;/li&gt;
&lt;li&gt;Current Consumption: 60 μA (typical)&lt;/li&gt;
&lt;li&gt;Output Type: Analog&lt;/li&gt;
&lt;li&gt;Accuracy: ±0.5°C (typical)&lt;/li&gt;
&lt;li&gt;Output Impedance: 0.1Ω for 1 mA load&lt;/li&gt;
&lt;li&gt;Linearity: ±0.25°C&lt;/li&gt;
&lt;li&gt;Sensitivity: 10 mV/°C&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  LM35 Temperature Sensor Pinout
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftfqg7xda296ypnvzwft3.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftfqg7xda296ypnvzwft3.PNG" alt="Image description" width="324" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VCC:&lt;/strong&gt; Power supply pin of the LM35. &lt;br&gt;
&lt;strong&gt;GND:&lt;/strong&gt; Ground pin.&lt;br&gt;
&lt;strong&gt;Out:&lt;/strong&gt; Analog output pin of the sensor. &lt;/p&gt;

&lt;h2&gt;
  
  
  Interfacing LM35 Temperature Sensor with an Arduino
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Component Required&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arduino UNO R3&lt;/li&gt;
&lt;li&gt;LM35 Temperature Sensor&lt;/li&gt;
&lt;li&gt;RGB LED (Common Cathode)&lt;/li&gt;
&lt;li&gt;Resistor (220Ω)&lt;/li&gt;
&lt;li&gt;Breadboard&lt;/li&gt;
&lt;li&gt;Jumper Wires&lt;/li&gt;
&lt;li&gt;USB Type A to B Cable&lt;/li&gt;
&lt;li&gt;12V Adapter&lt;/li&gt;
&lt;li&gt;PCF8574 I2C LCD Module&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Wiring Connections&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu73g9f0v4sk7bcxtw5vc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu73g9f0v4sk7bcxtw5vc.png" alt="Image description" width="800" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Arduino Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* 
Interfacing temperature Sensor with Arduino UNO using Analog input pin of Arduino and 
display temperature in Fahrenheit and in degree Celsius on I2C LCD. Here RGB LED turns Blue at LOW temperature, Red at HIGH temperature and Green when the temperature is between LOW and HIGH limit.
by www.playwithcircuit.com
*/
#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;  // Library to Run I2C LCD
#define RED_PIN 10
#define BLUE_PIN 9
#define GREEN_PIN 8
#define LOW_TEMP    10
#define HIGH_TEMP   50
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Define the analog pin for the temperature sensor
const int TemperatureSensorPin = A0;
// Variable to store the Analog count from temperature sensor
int temperatureCounts;
// Variable to store Voltage values
float voltageValue;
// Variable to store Temperature in Degree Celsius
float temperatureDegreeCelsius;
// Variable to store Temperature in Fahrenheit
float temperatureFahrenheit;
void setup() {
  // initialize the lcd
  lcd.init();
  // Turn on the Backlight
  lcd.backlight();
  // Clear the display buffer
  lcd.clear();
  // Make LED pins and Buzzer pin as output
  pinMode(RED_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);
  pinMode(GREEN_PIN, OUTPUT);
  // Turn off all the pins
  digitalWrite(RED_PIN, LOW);
  digitalWrite(BLUE_PIN, LOW);
  digitalWrite(GREEN_PIN, LOW);
  // Print a message to the LCD
  lcd.setCursor(0, 0);
  lcd.print("Initializing");
  // Print a message to the LCD
  lcd.setCursor(0, 1);
  lcd.print("Please Wait...");
  // flush out the first hundred values give time to temperature sensor to be stable
  for (int i = 0; i &amp;lt; 100; i++) {
    // Read the value from the temperature sensor
    temperatureCounts = analogRead(TemperatureSensorPin);
    delay(10);
  }
  // Clear the display buffer
  lcd.clear();
  // Print a message to the LCD
  lcd.setCursor(0, 0);
  lcd.print("Temp in C:");
  // Print a message to the LCD
  lcd.setCursor(0, 1);
  lcd.print("Temp in F:");
}
void loop() {
  // Static variables to save the last temperature
  static float lastTemp = 0xFF;
  // Read the value from the temperature sensor
  temperatureCounts = analogRead(TemperatureSensorPin);
  // convert the counts 0 to 1023 into voltage values 0 to 5V
  voltageValue = (5.0/1023) * temperatureCounts;
  // Convert voltage to temperature in Celsius
  temperatureDegreeCelsius = voltageValue * 100;
  // Convert Celsius to Fahrenheit
  temperatureFahrenheit = (temperatureDegreeCelsius * 9.0 / 5.0) + 32.0;
  // If current temperature is not equal to last temperature value in degree celsius
  if (lastTemp !
= temperatureDegreeCelsius) {
    // Print a temp to the LCD
    lcd.setCursor(10, 0);
    lcd.print("      ");
    lcd.setCursor(10, 0);
    lcd.print((int)temperatureDegreeCelsius);
    // Print a message to the LCD
    lcd.setCursor(10, 1);
    lcd.print("      ");
    lcd.setCursor(10, 1);
    lcd.print((int)temperatureFahrenheit);
  }
  // Save the current temperature value in the static variable to use it later
  lastTemp = temperatureDegreeCelsius;
  // Change the color of LED as per temperature level
  if (temperatureDegreeCelsius &amp;gt; HIGH_TEMP) {
    digitalWrite(RED_PIN, HIGH);
    digitalWrite(BLUE_PIN, LOW);
    digitalWrite(GREEN_PIN, LOW);
  } else if (temperatureDegreeCelsius &amp;gt;= LOW_TEMP &amp;amp;&amp;amp; temperatureDegreeCelsius &amp;lt;= HIGH_TEMP) {
    digitalWrite(RED_PIN, LOW);
    digitalWrite(BLUE_PIN, LOW);
    digitalWrite(GREEN_PIN, HIGH);
  } else if (temperatureDegreeCelsius &amp;lt; LOW_TEMP) {
    digitalWrite(RED_PIN, LOW);
    digitalWrite(BLUE_PIN, HIGH);
    digitalWrite(GREEN_PIN, LOW);
  }
  // Wait for 1000 ms before the next loop
  delay(1000);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To learn more checkout: &lt;a href="https://playwithcircuit.com/lm35-temperature-sensor-arduino-tutorial/" rel="noopener noreferrer"&gt;Interfacing LM35 Temperature Sensor with Arduino&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>arduino</category>
      <category>electronics</category>
    </item>
    <item>
      <title>74HC595 Shift Register with Arduino UNO</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Mon, 12 May 2025 11:31:21 +0000</pubDate>
      <link>https://dev.to/akshay_jain/74hc595-shift-register-with-arduino-uno-26kh</link>
      <guid>https://dev.to/akshay_jain/74hc595-shift-register-with-arduino-uno-26kh</guid>
      <description>&lt;p&gt;When working with Arduino, you may often need to control multiple devices like LEDs, sensors, or modules. However, as the number of connected peripherals grows, you can quickly run out of available GPIO pins. So, how can you expand your Arduino’s I/O capabilities? The solution is to use a shift register, which can effectively increase the number of input or output pins.&lt;/p&gt;

&lt;p&gt;Shift registers come in two main types:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SIPO (Serial-In Parallel-Out)&lt;/strong&gt; – used to expand outputs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PISO (Parallel-In Serial-Out)&lt;/strong&gt; – used to expand inputs.&lt;/p&gt;

&lt;p&gt;One of the most commonly used SIPO shift register ICs is the 74HC595. It enables you to control 8 output devices using just 3 digital pins from the Arduino. Even better, you can daisy-chain multiple 74HC595 ICs to control a large number of devices using the same 3 pins.&lt;/p&gt;

&lt;p&gt;Whether you're designing an LED matrix, a multiplexed display, or any project requiring efficient serial-to-parallel output control, the 74HC595 is an excellent choice. In this tutorial, we’ll take a closer look at how the 74HC595 works and how to interface it with an Arduino.&lt;/p&gt;

&lt;p&gt;Let’s dive in!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Shift Register and Why Use It?
&lt;/h2&gt;

&lt;p&gt;The 74HC595 is an 8-bit Serial-In Parallel-Out (SIPO) shift register with a built-in D-type latch. It offers three output states: HIGH, LOW, and High-Impedance (Hi-Z). The high-impedance state allows multiple devices to share the same output lines without interference.&lt;/p&gt;

&lt;p&gt;Let’s look at a practical example. Suppose you want to create light patterns on an 8×8 LED matrix. This matrix has 64 LEDs, and ideally, each LED requires a separate control line. Controlling all 64 LEDs directly would need 64 I/O pins, which isn’t feasible with most microcontrollers like the Arduino Uno (which only has 14 digital I/O pins).&lt;/p&gt;

&lt;p&gt;By using two 74HC595 shift registers—one for controlling rows and one for columns—you can control all 64 LEDs using just 6 pins from your Arduino. This makes shift registers extremely valuable when working with projects that need many digital outputs.&lt;/p&gt;

&lt;p&gt;It’s important to note that shift registers like the 74HC595 provide digital outputs only, meaning they can turn connected devices ON or OFF (logic HIGH or LOW). While they don't support analog output natively (like PWM for dimming LEDs), workarounds such as software-based PWM can be used to simulate brightness control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features of the 74HC595&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;8-bit parallel output&lt;/li&gt;
&lt;li&gt;Serial-to-parallel data conversion&lt;/li&gt;
&lt;li&gt;Cascade capability to expand outputs&lt;/li&gt;
&lt;li&gt;Low power consumption&lt;/li&gt;
&lt;li&gt;Operates with 2.0V to 6.0V supply voltage&lt;/li&gt;
&lt;li&gt;Compatible with 5V logic systems&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How Does the 74HC595 Shift Register Work?
&lt;/h2&gt;

&lt;p&gt;The 74HC595 IC contains two main components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shift Register&lt;/li&gt;
&lt;li&gt;Storage Register (Latch)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Here’s how it works:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Data is sent one bit at a time to the Data (DS) pin. On every rising edge of the Shift Register Clock (SRCLK), the bits shift from LSB to MSB inside the shift register. After all 8 bits are loaded, a pulse is sent to the Latch Clock (RCLK) pin. This transfers the data from the shift register to the storage register, which then drives the output pins (QA to QH). This process ensures that the outputs only update after all data bits have been shifted in, avoiding flicker or glitches.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhoefbw07cuduzx98drxi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhoefbw07cuduzx98drxi.png" alt="Image description" width="500" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmj8xwv09wlhfqjrcmx79.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmj8xwv09wlhfqjrcmx79.png" alt="Image description" width="500" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  74HC595 Pinout
&lt;/h2&gt;

&lt;p&gt;The 74HC595 is a widely used 8-bit shift register IC. Below is a description of its pin configuration and functionality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffcnvkdo2jspteghaakpn.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffcnvkdo2jspteghaakpn.webp" alt="Image description" width="800" height="555"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Output Pins (QA to QH)&lt;/strong&gt;&lt;br&gt;
These are the eight output pins of the storage register, labeled QA to QH (also referred to as Q0 to Q7). Each pin corresponds to one bit of the stored data. The pin numbers on the IC are as follows:&lt;br&gt;
QA – Pin 15&lt;br&gt;
QB – Pin 1&lt;br&gt;
QC– Pin 2&lt;br&gt;
QD – Pin 3&lt;br&gt;
QE – Pin 4&lt;br&gt;
QF – Pin 5&lt;br&gt;
QG – Pin 6&lt;br&gt;
QH – Pin 7&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Serial Data Input (SER)&lt;/strong&gt;&lt;br&gt;
This pin is used to input data serially (bit by bit) into the shift register.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shift Register Clock (SRCLK)&lt;/strong&gt;&lt;br&gt;
Each rising edge (LOW to HIGH transition) of the clock signal shifts the bits in the shift register one position to the left, making room for a new bit at the LSB. Timing on this pin is critical for accurate data loading.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Storage Register Clock / Latch (RCLK)&lt;/strong&gt;&lt;br&gt;
This pin latches the data from the shift register into the storage register. When it transitions from LOW to HIGH, the output pins (QA to QH) are updated to reflect the new data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cascade Output (QH′)&lt;/strong&gt;&lt;br&gt;
Also called the serial out, this pin outputs the last bit (bit 7 or QH) of the shift register. It is used to cascade multiple 74HC595 ICs. By connecting this pin to the SER pin of another shift register and sharing the same clock signals, you can expand the number of outputs to 16, 24, or more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output Enable (OE)&lt;/strong&gt;&lt;br&gt;
This is an active LOW pin. Pulling it LOW enables all output pins (QA to QH); pulling it HIGH puts the outputs in a high-impedance (Hi-Z) state, effectively disconnecting them. This is useful when multiple devices share output lines. Additionally, you can use a PWM signal on this pin to control LED brightness.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shift Register Clear (SRCLR)&lt;/strong&gt;&lt;br&gt;
This is an active LOW pin used to clear the shift register (reset all bits to 0). Note that this action does not affect the storage register. Typically, this pin is connected to VCC for normal operation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VCC&lt;/strong&gt;&lt;br&gt;
This is the power supply pin and should be connected to +5V.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GND&lt;/strong&gt;&lt;br&gt;
This is the ground pin and should be connected to the Arduino’s GND.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wiring a 74HC595 Shift Register to an Arduino
&lt;/h2&gt;

&lt;p&gt;In this project, we’ll control 8 red LEDs using a 74HC595 shift register. The LEDs will be connected to the output pins QA to QH of the IC.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-by-Step Instructions:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Place the 74HC595 on the Breadboard&lt;/strong&gt;&lt;br&gt;
Start by inserting the 74HC595 IC onto the breadboard so that the pins on each side are placed in separate rows (opposite halves of the breadboard).&lt;br&gt;
To identify Pin 1, look for the small notch or dot on the IC — Pin 1 is to the left of the notch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Power the Shift Register&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Connect Pin 16 (VCC) to the 5V pin of the Arduino.&lt;/li&gt;
&lt;li&gt;Connect Pin 8 (GND) to the GND of the Arduino.&lt;/li&gt;
&lt;li&gt;Connect Pin 10 (SRCLR) to 5V to keep the shift register enabled.&lt;/li&gt;
&lt;li&gt;Connect Pin 13 (OE) to Arduino pin 9 — this allows you to control output enable (active LOW). If you don’t plan to toggle outputs dynamically, you can also tie it to GND directly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Connect the Control Pins&lt;/strong&gt;&lt;br&gt;
The 74HC595 uses three Arduino pins for control:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pin 11 (SRCLK) → Connect to Arduino pin 12 (Shift register clock).&lt;/li&gt;
&lt;li&gt;Pin 12 (RCLK) → Connect to Arduino pin 10 (Latch pin to transfer data to outputs).&lt;/li&gt;
&lt;li&gt;Pin 14 (SER) → Connect to Arduino pin 11 (Serial data input).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Connect the LEDs&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Connect the anodes (positive legs) of the 8 LEDs to the output pins QA to QH (Pins 15, 1, 2, 3, 4, 5, 6, 7 respectively).&lt;/li&gt;
&lt;li&gt;Connect a 220Ω resistor in series with each LED to limit current and prevent damage.&lt;/li&gt;
&lt;li&gt;Connect the cathodes (negative legs) of the LEDs to GND on the Arduino.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnrvpwwuozgiavoe6olip.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnrvpwwuozgiavoe6olip.JPG" alt="Image description" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Arduino Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* 
Code to interface 74HC595 SIPO shift register using Arduino UNO
by www.playwithcircuit.com
*/
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
//Pin connected to DS of 74HC595
int dataPin = 11;
//Pin connected to ST_CP of 74HC595
int latchPin = 10;
//Pin connected to OE of 74HC595     
int brightnessPin = 9;
//Brightness control variable
int PWM_Value = 0;
void setup() {
  //set pins to output so you can control the shift register  and initially they should be HIGH
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(brightnessPin, OUTPUT);
  digitalWrite(latchPin, HIGH);
  digitalWrite(clockPin, HIGH);
  digitalWrite(dataPin, HIGH);
  analogWrite(brightnessPin, 255);
}
void loop() {
  int led_byte = 0x00;
  //  turn ON all LEDs one by one 
  for (int i = 0; i &amp;lt; 8; i++) {
    // adjust the brightness of LEDs
    PWM_Value = (255 - (115 + (20*i)));
    analogWrite(brightnessPin, PWM_Value);
    led_byte |= (0x01 &amp;lt;&amp;lt; i);
    // take the latchPin low
    digitalWrite(latchPin, LOW);
    // shift out the bits:
    shiftOut(dataPin, clockPin, MSBFIRST, led_byte);
    //take the latch pin high so the LEDs will light up:
    digitalWrite(latchPin, HIGH);
    // pause before next value:
    delay(100);
  }
  //  turn OFF all LEDs one by one 
  for (int i = 0; i &amp;lt; 8; i++) {
    led_byte &amp;amp;= ~(0x01 &amp;lt;&amp;lt; i);
    // make the latchPin low
    digitalWrite(latchPin, LOW);
    // shift out the bits:
    shiftOut(dataPin, clockPin, MSBFIRST, led_byte);
    //make the latch pin high so the LEDs will light up:
    digitalWrite(latchPin, HIGH);
    // pause before next value
    delay(100);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To learn more checkout: &lt;strong&gt;&lt;a href="https://playwithcircuit.com/74hc595-shift-register-arduino-tutorial/" rel="noopener noreferrer"&gt;74HC595 Shift Register Interfacing with Arduino UNO&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>arduino</category>
      <category>electronics</category>
    </item>
    <item>
      <title>How to Build a Line Follower Robot with Arduino</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Wed, 27 Nov 2024 05:01:52 +0000</pubDate>
      <link>https://dev.to/akshay_jain/how-to-build-a-line-follower-robot-with-arduino-2j2a</link>
      <guid>https://dev.to/akshay_jain/how-to-build-a-line-follower-robot-with-arduino-2j2a</guid>
      <description>&lt;p&gt;Robotics is one of the most exciting fields in electronics, and building a Line Follower Robot is an excellent way to dive into this world. In this tutorial, we will guide you step by step to create a line follower robot using Arduino.&lt;/p&gt;

&lt;p&gt;A line follower robot is an autonomous robot designed to detect and follow a line, typically a black line on a white surface.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does It Work?
&lt;/h2&gt;

&lt;p&gt;To enable the line-following functionality in a robot, we need a mechanism to detect the line it will follow. This mechanism leverages a fundamental principle: black surfaces absorb most light, while white surfaces reflect nearly all the light. &lt;br&gt;
Many sensors, such as Light-Dependent Resistors (LDRs), IR sensors, or specialized line sensors, use this property to distinguish between black and white surfaces. In this project, we utilize line sensors for their high precision and reliable line detection capabilities.&lt;/p&gt;

&lt;p&gt;A typical line sensor comprises two key components: &lt;strong&gt;an IR emitter (LED) and an IR receiver (photodiode)&lt;/strong&gt;. The emitter continuously emits infrared light, while the receiver detects the light reflected from the surface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s how it works:&lt;/strong&gt;&lt;br&gt;
When the emitted IR light strikes a white surface, it reflects back and is captured by the photodiode.&lt;br&gt;
Conversely, when the light encounters a black line, it is absorbed rather than reflected, leaving the receiver with little or no signal.&lt;/p&gt;
&lt;h2&gt;
  
  
  Components Required
&lt;/h2&gt;

&lt;p&gt;To build this project, you will need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arduino UNO (or any compatible microcontroller board)&lt;/li&gt;
&lt;li&gt;IR Sensor Module (two sensors for detecting the line)&lt;/li&gt;
&lt;li&gt;L298N Motor Driver Module&lt;/li&gt;
&lt;li&gt;DC Motors (2 units for the robot wheels)&lt;/li&gt;
&lt;li&gt;Robot Chassis&lt;/li&gt;
&lt;li&gt;Wheels and Castor Wheel&lt;/li&gt;
&lt;li&gt;Battery (9V or 12V)&lt;/li&gt;
&lt;li&gt;Connecting Wires&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Assembling the robot
&lt;/h2&gt;

&lt;p&gt;Watch the following video to learn how to assemble the robot.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/IZGd8xvNkGE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Arduino Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* 
Library used: Adafruit Motor Shield library V1 version: 1.0.1
For this code to run as expected: 
1.The centre to centre distance between the Line sensors should be 11 to 11.5 cm
2. The width of black tape should be 4.8 to 5 cm
3. The distance of the sensor LED from the flat ground surface should be 2 cm.
*/
#include &amp;lt;AFMotor.h&amp;gt;
// MACROS for Debug print, while calibrating set its value to 1 else keep it 0
#define DEBUG_PRINT 0
// MACROS for Analog Input
#define LEFT_IR A0
#define RIGHT_IR A1
// MACROS to control the Robot
#define DETECT_LIMIT 300
#define FORWARD_SPEED 60
#define TURN_SHARP_SPEED 150
#define TURN_SLIGHT_SPEED 120
#define DELAY_AFTER_TURN 140
#define BEFORE_TURN_DELAY 10
// BO Motor control related data here
// Here motors are running using M3 and M4 of the shield and Left Motor is connected to M3 and Right Motor is connected to M4 using IC2 of the shield
AF_DCMotor motorL(3);  // Uses PWM0B pin of Arduino Pin 5 for Enable
AF_DCMotor motorR(4);  // Uses PWM0A pin of Arduino Pin 6 for Enable
// variables to store the analog values
int left_value;
int right_value;
// Set the last direction to Stop
char lastDirection = 'S';  
void setup() {
#if DEBUG_PRINT  
  Serial.begin(9600);
#endif  
  // Set the current speed of Left Motor to 0
  motorL.setSpeed(0);
  // turn on motor
  motorL.run(RELEASE);
  // Set the current speed of Right Motor to 0
  motorR.setSpeed(0);
  // turn off motor
  motorR.run(RELEASE);
  // To provide starting push to Robot these values are set
  motorR.run(FORWARD);
  motorL.run(FORWARD);
  motorL.setSpeed(255);
  motorR.setSpeed(255);
  delay(40);  // delay of 40 ms
}
void loop() {
  left_value = analogRead(LEFT_IR);
  right_value = analogRead(RIGHT_IR);
#if DEBUG_PRINT
  // This is for debugging. To check the analog inputs the DETECT_LIMIT MACRO value 300 is set by analysing the debug prints
  Serial.print(left_value);
  Serial.print(",");
  Serial.print(right_value);
  Serial.print(",");
  Serial.print(lastDirection);
  Serial.write(10);
#endif
  // Right Sensor detects black line and left does not detect
  if (right_value &amp;gt;= DETECT_LIMIT &amp;amp;&amp;amp; !(left_value &amp;gt;= DETECT_LIMIT)) {
    turnRight();
  }
  // Left Sensor detects black line and right does not detect
  else if ((left_value &amp;gt;= DETECT_LIMIT) &amp;amp;&amp;amp; !(right_value &amp;gt;= DETECT_LIMIT)) {
    turnLeft();
  }
  // both sensors doesn't detect black line
  else if (!(left_value &amp;gt;= DETECT_LIMIT) &amp;amp;&amp;amp; !(right_value &amp;gt;= DETECT_LIMIT)) {
    moveForward();
  }
  // both sensors detect black line
  else if ((left_value &amp;gt;= DETECT_LIMIT) &amp;amp;&amp;amp; (right_value &amp;gt;= DETECT_LIMIT)) {
    stop();
  }
}
void moveForward() {
  if (lastDirection != 'F') {
    // To provide starting push to Robot when last direction was not forward
    motorR.run(FORWARD);
    motorL.run(FORWARD);
    motorL.setSpeed(255);
    motorR.setSpeed(255);
    lastDirection = 'F';
    delay(20);
  } else {
    // If the last direction was forward
    motorR.run(FORWARD);
    motorL.run(FORWARD);
    motorL.setSpeed(FORWARD_SPEED);
    motorR.setSpeed(FORWARD_SPEED);
  }
}
void stop() {
  if (lastDirection != 'S') {
    // When stop is detected move further one time to check if its actual stop or not, needed when the robot turns
    motorR.run(FORWARD);
    motorL.run(FORWARD);
    motorL.setSpeed(255);
    motorR.setSpeed(255);
    lastDirection = 'S';
    delay(40);
  } else {
    // When stop is detected next time then stop the Robot
    motorL.setSpeed(0);
    motorR.setSpeed(0);
    motorL.run(RELEASE);
    motorR.run(RELEASE);
    lastDirection = 'S';
  }
}
void turnRight(void) {
  // If first time Right Turn is taken
  if (lastDirection != 'R') {
    lastDirection = 'R';
    // Stop the motor for some time
    motorL.setSpeed(0);
    motorR.setSpeed(0);
    delay(BEFORE_TURN_DELAY);
    // take Slight Right turn
    motorL.run(FORWARD);
    motorR.run(BACKWARD);
    motorL.setSpeed(TURN_SLIGHT_SPEED);
    motorR.setSpeed(TURN_SLIGHT_SPEED);
  } else {
    // take sharp Right turn
    motorL.run(FORWARD);
    motorR.run(BACKWARD);
    motorL.setSpeed(TURN_SHARP_SPEED);
    motorR.setSpeed(TURN_SHARP_SPEED);
  }
  delay(DELAY_AFTER_TURN);
}
void turnLeft() {
  // If first time Left Turn is taken
  if (lastDirection != 'L') {
    lastDirection = 'L';
    // Stop the motor for some time
    motorL.setSpeed(0);
    motorR.setSpeed(0);
    delay(BEFORE_TURN_DELAY);
    // take slight Left turn
    motorR.run(FORWARD);
    motorL.run(BACKWARD);
    motorL.setSpeed(TURN_SLIGHT_SPEED);
    motorR.setSpeed(TURN_SLIGHT_SPEED);
  } else {
    // take sharp Left turn
    motorR.run(FORWARD);
    motorL.run(BACKWARD);
    motorL.setSpeed(TURN_SHARP_SPEED);
    motorR.setSpeed(TURN_SHARP_SPEED);
  }
  delay(DELAY_AFTER_TURN);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To learn how to calibrate and troubleshoot line follower Robot checkout this detailed article: &lt;a href="https://playwithcircuit.com/line-follower-robot-using-arduino/" rel="noopener noreferrer"&gt;Line Follower Robot using Arduino&lt;/a&gt;&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>robotics</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Master-Slave Communication Between Two Arduino Boards</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Wed, 31 Jul 2024 09:15:21 +0000</pubDate>
      <link>https://dev.to/akshay_jain/master-slave-communication-between-two-arduino-boards-58hb</link>
      <guid>https://dev.to/akshay_jain/master-slave-communication-between-two-arduino-boards-58hb</guid>
      <description>&lt;p&gt;In this project, we'll explore how to set up master-slave communication between two Arduino boards using UART communication. &lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Master-Slave Communication
&lt;/h2&gt;

&lt;p&gt;In a master-slave communication setup between two Arduino boards, one board acts as the master, while the other functions as the slave.&lt;br&gt;
The master board sends commands to the slave board to perform specific tasks, and the slave board carries out these operations and sends a response back to the master.&lt;/p&gt;

&lt;p&gt;These tasks can include actions like turning on an LED, reading sensor values, or controlling the speed of a motor. While the master sends the commands, the slave processes them and executes the required tasks.&lt;br&gt;
The communication between the master and slave is established using Serial UART Communication, which utilises three pins: Rx (Receive), Tx (Transmit), and GND (Ground).&lt;/p&gt;

&lt;p&gt;In this project, the Master Arduino sends commands to the Slave Arduino through the Serial Tx Pin and receives responses from the Slave Arduino via the Serial Rx Pin.&lt;/p&gt;

&lt;p&gt;The master will send the following commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request the temperature reading from the Slave board.&lt;/li&gt;
&lt;li&gt;Request the humidity reading from the Slave board.&lt;/li&gt;
&lt;li&gt;Request the analog value read from the A0 input on the Slave board.&lt;/li&gt;
&lt;li&gt;Turn the LED ON/OFF based on the analog input value.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the master receives all the responses, it will display the data on an LCD.&lt;/p&gt;

&lt;p&gt;On the other side, the slave board listens for commands from the master and provides the appropriate response based on the command received.&lt;/p&gt;
&lt;h2&gt;
  
  
  Components Required
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;2 Arduino UNO R3
&lt;/li&gt;
&lt;li&gt;16 x 2 LCD
&lt;/li&gt;
&lt;li&gt;2, 10 kΩ Potentiometer
&lt;/li&gt;
&lt;li&gt;220 Ω Resistance
&lt;/li&gt;
&lt;li&gt;2 Breadboards &lt;/li&gt;
&lt;li&gt;Red LED
&lt;/li&gt;
&lt;li&gt;100 Ω Resistance
&lt;/li&gt;
&lt;li&gt;Temperature Sensor
&lt;/li&gt;
&lt;li&gt;L293D &lt;/li&gt;
&lt;li&gt;104 pf Ceramic Capacitor
&lt;/li&gt;
&lt;li&gt;multiple Connecting Wires &lt;/li&gt;
&lt;li&gt;5V DC Motor
&lt;/li&gt;
&lt;li&gt;DC Fan
&lt;/li&gt;
&lt;li&gt;USB A/B cable&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Circuit Diagram
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ftvh70h81w26wavm42p.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ftvh70h81w26wavm42p.JPG" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Master Code
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include "master.h"
#define MOTOR_PIN 3
void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // set the cursor to (column = 0,row = 0)
  lcd.setCursor(0, 0);
  lcd.print("Master Slave");
  lcd.setCursor(0, 1);
  // set the cursor to (column = 0,row = 1)
  lcd.print("Demo");
  // provide delay of 2 second
  delay(300);
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ;  // wait for serial port to connect. Needed for native USB
  }
  pinMode(MOTOR_PIN, OUTPUT);  // declare Motor pin to be an output
}
void loop() {
  getTempearture();
  getHumidity();
  getSpeed();
  setMotorSpeed();
  lcdUpdate();
}
void setMotorSpeed() {
  if (paramerters.Status[SPD_STA_INDX] == STATUS_OK) {
    analogWrite(MOTOR_PIN, map(paramerters.Speed,0,100,0,255));  // set the Speed of Motor
  }
}
// For temperture
// CMD : START_CHAR TEMP_CMD END_CHAR
// RESP: START_CHAR TEMP_RSP STATUS BYTE1 BYTE2 BYTE3 BYTE4 END_CHAR
void getTempearture() {
  float temp;
  float *ptemp = &amp;amp;temp;
  unsigned char cmdBuffer[3] = { START_CHAR, TEMP_CMD, END_CHAR };
  unsigned char rspBuffer[10] = { 0 };
  unsigned char rspIndex = 0;
  Serial.write(cmdBuffer, 3);
  while (Serial.available() == 0)
    ;
  do {
    rspBuffer[rspIndex++] = Serial.read();
    // this delay is provided because it takes approx 10 ms to receiev a new character at 9600 baurdrate
    delay(10);
  } while (Serial.available() != 0);
  if ((rspBuffer[0] == START_CHAR) &amp;amp;&amp;amp; (rspBuffer[1] == TEMP_RSP) &amp;amp;&amp;amp; (rspBuffer[7] == END_CHAR)) {
    if (rspBuffer[2] == STATUS_OK) {
      ptemp = (float *)(rspBuffer + 3);
      paramerters.Temperature = *ptemp;
    }
    paramerters.Status[TEM_STA_INDX] = rspBuffer[2];
  }
}
// For humidity
// CMD : START_CHAR HUMIDITY_CMD END_CHAR
// RESP: START_CHAR HUMIDITY_RSP STATUS BYTE1 BYTE2 BYTE3 BYTE4 END_CHAR
void getHumidity() {
  float hum;
  float *phum = &amp;amp;hum;
  unsigned char cmdBuffer[3] = { START_CHAR, HUMIDITY_CMD, END_CHAR };
  unsigned char rspBuffer[10] = { 0 };
  unsigned char rspIndex = 0;
  Serial.write(cmdBuffer, 3);
  while (Serial.available() == 0)
    ;
  do {
    rspBuffer[rspIndex++] = Serial.read();
    // this delay is provided because it takes approx 10 ms to receiev a new character at 9600 baurdrate
    delay(10);
  } while (Serial.available() != 0);
  if ((rspBuffer[0] == START_CHAR) &amp;amp;&amp;amp; (rspBuffer[1] == HUMIDITY_RSP) &amp;amp;&amp;amp; (rspBuffer[7] == END_CHAR)) {
    if (rspBuffer[2] == STATUS_OK) {
      phum = (float *)(rspBuffer + 3);
      paramerters.Humidity = *phum;
    }
    paramerters.Status[HUM_STA_INDX] = rspBuffer[2];
  }
}
// For speed
// CMD : START_CHAR SPEED_CMD END_CHAR
// RESP: START_CHAR SPEED_RSP STATUS BYTE1 END_CHAR
void getSpeed() {
  int spd;
  int *pspd = &amp;amp;spd;
  unsigned char cmdBuffer[3] = { START_CHAR, SPEED_CMD, END_CHAR };
  unsigned char rspBuffer[10] = { 0 };
  unsigned char rspIndex = 0;
  Serial.write(cmdBuffer, 3);
  while (Serial.available() == 0)
    ;
  do {
    rspBuffer[rspIndex++] = Serial.read();
    // this delay is provided because it takes approx 10 ms to receiev a new character at 9600 baurdrate
    delay(10);
  } while (Serial.available() != 0);
  if ((rspBuffer[0] == START_CHAR) &amp;amp;&amp;amp; (rspBuffer[1] == SPEED_RSP) &amp;amp;&amp;amp; (rspBuffer[5] == END_CHAR)) {
    if (rspBuffer[2] == STATUS_OK) {
      pspd = (int *)(rspBuffer + 3);
      paramerters.Speed = *pspd;
    }
    paramerters.Status[SPD_STA_INDX] = rspBuffer[2];
  }
  if (paramerters.Status[SPD_STA_INDX] == STATUS_OK) {
    if (paramerters.Speed &amp;gt;= 50) {
      //it indicates high speed
      setLEDON();
    } else {
      //it indicates low speed
      setLEDOff();
    }
  }
}
// For led ON
// CMD : START_CHAR LED_ON_CMD END_CHAR
// RESP: START_CHAR LED_ON_RSP STATUS END_CHAR
void setLEDON() {
  unsigned char cmdBuffer[3] = { START_CHAR, LED_ON_CMD, END_CHAR };
  unsigned char rspBuffer[10] = { 0 };
  unsigned char rspIndex = 0;
  Serial.write(cmdBuffer, 3);
  while (Serial.available() == 0);
  do {
    rspBuffer[rspIndex++] = Serial.read();
    // this delay is provided because it takes approx 10 ms to receiev a new character at 9600 baurdrate
    delay(10);
  } while (Serial.available() != 0);
  if ((rspBuffer[0] == START_CHAR) &amp;amp;&amp;amp; (rspBuffer[1] == LED_ON_RSP) &amp;amp;&amp;amp; (rspBuffer[3] == END_CHAR)) {
    if (rspBuffer[2] == STATUS_OK) {
      paramerters.Led_state = 1;
    }
    paramerters.Status[LED_STA_INDX] = rspBuffer[2];
  }
}
// For led OFF
// CMD : START_CHAR LED_OFF_CMD END_CHAR
// RESP: START_CHAR LED_OFF_RSP STATUS END_CHAR
void setLEDOff() {
  unsigned char cmdBuffer[3] = { START_CHAR, LED_OFF_CMD, END_CHAR };
  unsigned char rspBuffer[10] = { 0 };
  unsigned char rspIndex = 0;
  Serial.write(cmdBuffer, 3);
  while (Serial.available() == 0)
    ;
  do {
    rspBuffer[rspIndex++] = Serial.read();
    // this delay is provided because it takes approx 10 ms to receiev a new character at 9600 baurdrate
    delay(10);
  } while (Serial.available() != 0);
  if ((rspBuffer[0] == START_CHAR) &amp;amp;&amp;amp; (rspBuffer[1] == LED_OFF_RSP) &amp;amp;&amp;amp; (rspBuffer[3] == END_CHAR)) {
    if (rspBuffer[2] == STATUS_OK) {
      paramerters.Led_state = 0;
    }
    paramerters.Status[LED_STA_INDX] = rspBuffer[2];
  }
}
void lcdUpdate() {
  lcd.clear();
  // DisplaY Temperature
  // set the cursor to (column = 0,row = 0)
  lcd.setCursor(0, 0);
  lcd.print("Tem=");
  if (paramerters.Status[TEM_STA_INDX] == STATUS_OK) {
    lcd.print(paramerters.Temperature);
  } else {
    lcd.print("NOK");
  }
  // DisplaY LED Status
  lcd.print(" LED=");
  if (paramerters.Status[LED_STA_INDX] == STATUS_OK) {
    lcd.write(paramerters.Led_state | 0x30);
  } else {
    lcd.print("NOK");
  }
  // Display Humidity
  // set the cursor to (column = 0,row = 1)
  lcd.setCursor(0, 1);
  lcd.print("Hum=");
  if (paramerters.Status[HUM_STA_INDX] == STATUS_OK) {
    lcd.print(paramerters.Humidity);
  } else {
    lcd.print("NOK");
  }
  // Display Speed
  lcd.print(" SP=");
  if (paramerters.Status[HUM_STA_INDX] == STATUS_OK) {
    lcd.print(paramerters.Speed);
    lcd.print('%');
  } else {
    lcd.print("NOK");
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Slave Code
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include "slave.h"
#define ALARM_LED 8
#define LED_ON 0
#define LED_OFF 1
char serialInput;
int dataIndex = 0;
char databuffer[10] = { 0 };
bool dataRcvd = false;  // whether the string receiving is completed.
unsigned char rspBuffer[10];
void setup() {
  Serial.begin(9600);          // initialize serial port
  dht.begin();                 // Initialize the DHT sensor
  pinMode(ALARM_LED, OUTPUT);  // Initialize alarm LED
  digitalWrite(ALARM_LED, LED_OFF);
}
void loop() {
  getTemphumidity();
  getSpeed();
  if (dataRcvd == true) {
    // Check for start and end character
    if ((databuffer[0] = START_CHAR) &amp;amp;&amp;amp; (databuffer[2] = END_CHAR)) {
      // Check if its the temperature command
      // For temperture
      // CMD : START_CHAR TEMP_CMD END_CHAR
      // RESP: START_CHAR TEMP_RSP STATUS BYTE1 BYTE2 BYTE3 BYTE4 END_CHAR
      if (databuffer[1] == TEMP_CMD) {
        rspBuffer[0] = START_CHAR;
        rspBuffer[1] = TEMP_RSP;
        if (paramerters.Status[TEM_STA_INDX] == STATUS_OK) {
          rspBuffer[2] = STATUS_OK;
          memcpy((rspBuffer + 3), &amp;amp;(paramerters.Temperature), 4);
        } else {
          rspBuffer[2] = STATUS_NOT_OK;
          memset((rspBuffer + 3), 0x00, 4);
        }
        rspBuffer[7] = END_CHAR;
        Serial.write(rspBuffer, 8);
      }
      // Check if it is Humidity command
      // For humidity
      // CMD : START_CHAR HUMIDITY_CMD END_CHAR
      // RESP: START_CHAR HUMIDITY_RSP STATUS BYTE1 BYTE2 BYTE3 BYTE4 END_CHAR
      else if (databuffer[1] == HUMIDITY_CMD) {
        rspBuffer[0] = START_CHAR;
        rspBuffer[1] = HUMIDITY_RSP;
        if (paramerters.Status[HUM_STA_INDX] == STATUS_OK) {
          rspBuffer[2] = STATUS_OK;
          memcpy((rspBuffer + 3), &amp;amp;(paramerters.Humidity), 4);
        } else {
          rspBuffer[2] = STATUS_NOT_OK;
          memset((rspBuffer + 3), 0x00, 4);
        }
        rspBuffer[7] = END_CHAR;
        Serial.write(rspBuffer, 8);
      }
      // Check if it is Speed command
      // For speed
      // CMD : START_CHAR SPEED_CMD END_CHAR
      // RESP: START_CHAR SPEED_RSP STATUS BYTE1 END_CHAR
      else if (databuffer[1] == SPEED_CMD) {
        rspBuffer[0] = START_CHAR;
        rspBuffer[1] = SPEED_RSP;
        if (paramerters.Status[SPD_STA_INDX] == STATUS_OK) {
          rspBuffer[2] = STATUS_OK;
          memcpy((rspBuffer + 3), &amp;amp;(paramerters.Speed), 2);
        } else {
          rspBuffer[2] = STATUS_NOT_OK;
          memset((rspBuffer + 3), 0x00, 2);
        }
        rspBuffer[5] = END_CHAR;
        Serial.write(rspBuffer, 6);
      }
      // For led ON
      // CMD : START_CHAR LED_ON_CMD END_CHAR
      // RESP: START_CHAR LED_ON_RSP STATUS END_CHAR
      else if (databuffer[1] == LED_ON_CMD) {
        rspBuffer[0] = START_CHAR;
        rspBuffer[1] = LED_ON_RSP;
        digitalWrite(ALARM_LED, LED_ON);
        rspBuffer[2] = STATUS_OK;
        rspBuffer[3] = END_CHAR;
        Serial.write(rspBuffer, 4);
      }
      // For led OFF
      // CMD : START_CHAR LED_OFF_CMD END_CHAR
      // RESP: START_CHAR LED_OFF_RSP STATUS END_CHAR
      else if (databuffer[1] == LED_OFF_CMD) {
        rspBuffer[0] = START_CHAR;
        rspBuffer[1] = LED_OFF_RSP;
        digitalWrite(ALARM_LED, LED_OFF);
        rspBuffer[2] = STATUS_OK;
        rspBuffer[3] = END_CHAR;
        Serial.write(rspBuffer, 4);
      }
    }
    dataRcvd = false;
    memset(databuffer, 0x00, sizeof(databuffer));
  }
}
void getTemphumidity() {
  static unsigned long int previousTick = 0;
  static unsigned long int currentTick;
  float temperature;
  float humidity;
  currentTick = millis();
  if ((currentTick - previousTick) &amp;gt;= 100) {
    previousTick = currentTick;
    // Read temperature and humidity from the DHT sensor
    temperature = dht.readTemperature(false);
    humidity = dht.readHumidity();
    // Check if the sensor reading is valid (non-NaN)
    if (!isnan(temperature)) {
      paramerters.Temperature = temperature;
      paramerters.Status[TEM_STA_INDX] = STATUS_OK;
      // Serial.print("Temperature: ");
      // Serial.print(temperature);
    } else {
      paramerters.Status[TEM_STA_INDX] = STATUS_NOT_OK;
    }
    if (!isnan(humidity)) {
      paramerters.Humidity = humidity;
      paramerters.Status[HUM_STA_INDX] = STATUS_OK;
      // Serial.print(" °F, Humidity: ");
      // Serial.print(humidity);
      // Serial.println("%");
    } else {
      paramerters.Status[HUM_STA_INDX] = STATUS_NOT_OK;
    }
  }
}
void getSpeed() {
  int analogPin = A0;  // potentiometer wiper (middle terminal) is connected to analog pin 0
  int analogVal = 0;   // variable to store the value read
  analogVal = analogRead(analogPin);  // read the Analog input pin
  paramerters.Speed = map(analogVal, 0, 1023, 0, 100);
  paramerters.Status[SPD_STA_INDX] = STATUS_OK;
}
/*
  SerialEvent occurs whenever a new data comes in the hardware serial RX. This
  routine is run between each time loop() runs, so using delay inside loop can
  delay response. Multiple bytes of data may be available.
*/
void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    serialInput = Serial.read();
    databuffer[dataIndex++] = serialInput;
    // if the incoming character is a line feed character '\n', set a flag so the main loop can do something about it
    if (serialInput == END_CHAR) {
      dataRcvd = true;
      dataIndex = 0;
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This project demonstrates how to implement master-slave communication between two Arduino boards using Serial UART Communication. By utilizing simple commands, the master board can control the slave board to perform various tasks and display the results on an LCD. For a detailed step-by-step guide, visit our blog post on &lt;a href="https://playwithcircuit.com/master-slave-communication-between-two-arduino-boards/" rel="noopener noreferrer"&gt;Master-Slave Communication Between Two Arduino Boards&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Video
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/u2zKKJ_dehI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>electronics</category>
      <category>diyproject</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Controlling a 28BYJ-48 Stepper Motor with Arduino: A Step-by-Step Guide</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Wed, 10 Jul 2024 11:08:54 +0000</pubDate>
      <link>https://dev.to/akshay_jain/controlling-a-28byj-48-stepper-motor-with-arduino-a-step-by-step-guide-54h0</link>
      <guid>https://dev.to/akshay_jain/controlling-a-28byj-48-stepper-motor-with-arduino-a-step-by-step-guide-54h0</guid>
      <description>&lt;p&gt;In this guide, we will walk you through controlling a 28BYJ-48 stepper motor using an Arduino and a ULN2003 driver. This tutorial aims to provide a hands-on experience for enthusiasts and beginners in the field of electronics and robotics. For a detailed explanation and additional resources, visit my blog post at &lt;strong&gt;&lt;a href="https://playwithcircuit.com/28byj48-stepper-motor-arduino-tutorial/" rel="noopener noreferrer"&gt;Stepper Motor Control with Arduino&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Materials Needed&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Arduino UNO&lt;br&gt;
28BYJ-48 Stepper Motor&lt;br&gt;
ULN2003 Driver Module&lt;br&gt;
Jumper Wires&lt;br&gt;
Breadboard (optional)&lt;br&gt;
Power Supply (optional)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding the Components&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;28BYJ-48 Stepper Motor: This stepper motor is known for its low cost and reliability. It has a 5-wire interface that connects to the ULN2003 driver.&lt;br&gt;
ULN2003 Driver Module: The ULN2003 is a Darlington transistor array used to drive the stepper motor. It provides the necessary current and voltage to the motor from the Arduino signals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Circuit Connections&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fognvl9dmi7wx7599hsfc.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fognvl9dmi7wx7599hsfc.PNG" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connecting the Motor to the Driver&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Connect the 5-wire connector of the 28BYJ-48 stepper motor to the ULN2003 driver module.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connecting the Driver to the Arduino&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Connect the IN1 pin on the ULN2003 to the digital pin 7 on the Arduino.&lt;/li&gt;
&lt;li&gt;Connect the IN2 pin on the ULN2003 to the digital pin 6 on the Arduino.&lt;/li&gt;
&lt;li&gt;Connect the IN3 pin on the ULN2003 to the digital pin 5 on the Arduino.&lt;/li&gt;
&lt;li&gt;Connect the IN4 pin on the ULN2003 to the digital pin 4 on the Arduino.&lt;/li&gt;
&lt;li&gt;Connect the GND pin on the ULN2003 to a GND pin on the Arduino.&lt;/li&gt;
&lt;li&gt;Connect the VCC pin on the ULN2003 to the 5V pin on the Arduino.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Arduino Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Upload the following code to your Arduino&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;Stepper.h&amp;gt;
//define Input pins of the Motor
#define OUTPUT1   7                // Connected to the Blue coloured wire
#define OUTPUT2   6                // Connected to the Pink coloured wire
#define OUTPUT3   5                // Connected to the Yellow coloured wire
#define OUTPUT4   4                // Connected to the Orange coloured wire
// Define the number of steps per rotation
const int stepsPerRotation = 2048;  // 28BYJ-48 has 2048 steps per rotation in full step mode as given in data sheet
// Initialize the stepper motor with the sequence of control pins OUTPUT1, OUTPUT3, OUTPUT2, IN4
// OUTPUT1 and OUTPUT3 are connected to one coil and OUTPUT2 and OUTPUT4 are connected to one Coil
Stepper myStepper(stepsPerRotation, OUTPUT1, OUTPUT3, OUTPUT2, OUTPUT4);  
void setup() {
  // Set the speed of the motor in RPM (adjust as needed)
  myStepper.setSpeed(15);  // 15 RPM
}
void loop() {
  // Rotate in One Direction and complete one complete rotation i.e 2048 steps
  myStepper.step(stepsPerRotation);  
  delay(1000);  // Delay between rotations
  // For Rotation in opposite direction provide the variable to the parameter with negative Sign
  myStepper.step(-stepsPerRotation);  
  delay(1000);  // Delay between rotations
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>arduino</category>
      <category>electronics</category>
      <category>diyelectronics</category>
      <category>electronicsprojects</category>
    </item>
  </channel>
</rss>
