<?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.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>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>
    <item>
      <title>Top Arduino Uno Projects for Beginners and Engineering Students</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Tue, 21 May 2024 13:05:10 +0000</pubDate>
      <link>https://dev.to/akshay_jain/top-25-arduino-uno-projects-for-beginners-and-engineering-students-19n1</link>
      <guid>https://dev.to/akshay_jain/top-25-arduino-uno-projects-for-beginners-and-engineering-students-19n1</guid>
      <description>&lt;p&gt;Are you looking for some exciting Arduino project ideas? Look no further! We've compiled a list of innovative projects that you can build using an Arduino board. From automating your home and developing smart gardening systems to constructing robots and designing IoT devices, these projects cater to a variety of interests and skill levels. Whether you're just starting out or are a seasoned maker, you'll find plenty of good project ideas to kickstart your next Arduino adventure. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Smart Home Automation System&lt;/strong&gt;&lt;br&gt;
This project is used to automate home appliances like lights, fans, and other devices using a smartphone. It uses various sensors such as temperature, humidity, and motion detectors to monitor environmental conditions. When a significant change is detected, the Arduino processes the data and controls the connected appliances through relay modules, making your home smart and energy-efficient.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Bluetooth Controlled Robot&lt;/strong&gt;&lt;br&gt;
This project is used to create a small robot controlled via a Bluetooth-enabled smartphone app. The robot's movement is managed using motors, while the Bluetooth module (like HC-05) handles wireless communication. This project teaches motor control, Bluetooth communication, and basic app development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Weather Station&lt;/strong&gt;&lt;br&gt;
This project is used to measure and display weather parameters such as temperature, humidity, and atmospheric pressure. It employs sensors like the DHT11 for temperature and humidity, and BMP180 for pressure. The collected data is displayed on an LCD screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Obstacle Avoiding Robot&lt;/strong&gt;&lt;br&gt;
This project is used to build a robot that navigates around obstacles using ultrasonic sensors. When an obstacle is detected, the robot changes its path to avoid collisions. This project enhances your understanding of robotics, sensor integration, and obstacle avoidance algorithms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Digital Thermometer&lt;/strong&gt;&lt;br&gt;
This project is used to create a digital thermometer using an LM35 temperature sensor. The temperature readings are displayed on a 16x2 LCD screen. This beginner-friendly project helps you understand how to read analog sensor data and display it using an LCD.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Smart Irrigation System&lt;/strong&gt;&lt;br&gt;
This project is used to automate the watering of plants based on soil moisture levels. It uses soil moisture sensors to monitor the soil's water content and controls a water pump accordingly. This project introduces environmental monitoring and automated control systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Home Security System&lt;/strong&gt;&lt;br&gt;
This project is used to create a home security system using PIR sensors to detect motion. When motion is detected, an alarm is triggered to alert of an intrusion. Optionally, a GSM module can be integrated to send SMS alerts, enhancing remote monitoring capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Voice Recognition Home Automation&lt;/strong&gt;&lt;br&gt;
This project is used to control home appliances with voice commands using a voice recognition module. The module processes the voice input, and the Arduino controls the appliances accordingly. This project introduces you to speech processing and smart home automation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. Automatic Street Light&lt;/strong&gt;&lt;br&gt;
This project is used to create a street light system that automatically turns on when it gets dark using an LDR sensor. The system is controlled by an Arduino, which reads the light level and triggers a relay to switch the light on or off. This project is ideal for beginners, teaching light sensor integration and relay control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. Heartbeat Monitoring System&lt;/strong&gt;&lt;br&gt;
This project is used to monitor and display heart rate using a pulse sensor. The sensor detects heartbeats, and the Arduino processes this data to calculate the heart rate, which is then displayed on an LCD screen. This project provides insights into bio-sensor integration and biometric data processing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;11. Voice Controlled LED&lt;/strong&gt;&lt;br&gt;
This project is used to control LEDs using voice commands via a Bluetooth-enabled Android app. The Bluetooth module receives voice commands, and the Arduino processes these commands to turn LEDs on or off. This project demonstrates integrating voice recognition with Arduino, offering an interesting introduction to voice control technology.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;12. Ultrasonic Range Finder&lt;/strong&gt;&lt;br&gt;
This project is used to measure the distance to an object using an ultrasonic sensor. The sensor emits ultrasonic waves and measures the time it takes for the echo to return. The distance is calculated and displayed on an LCD screen, providing practical experience with sonar technology and distance measurement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;13. RFID Door Lock&lt;/strong&gt;&lt;br&gt;
This project is used to create a door lock system that uses RFID tags for authentication. When a valid RFID tag is scanned, the Arduino unlocks the door by activating a servo motor. This project introduces you to RFID technology and its integration with Arduino.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;14. Smart Parking System&lt;/strong&gt;&lt;br&gt;
This project is used to detect and display the availability of parking spots using ultrasonic sensors. The sensors monitor the presence of vehicles in parking spots, and the Arduino processes this data to display the occupancy status. This project enhances your understanding of sensor networks and real-time data processing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15. Smart Dustbin&lt;/strong&gt;&lt;br&gt;
This project is used to create a dustbin that opens automatically when someone approaches it using an ultrasonic sensor. The sensor detects proximity, and the Arduino controls a servo motor to open the lid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;16. Energy Monitoring System&lt;/strong&gt;&lt;br&gt;
This project is used to measure and display the power consumption of household appliances. It employs current sensors to gather data and an LCD to display the results, helping you understand how to measure and monitor electrical power usage.&lt;br&gt;
Project Guide&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;17. Remote Controlled Car&lt;/strong&gt;&lt;br&gt;
This project is used to build a remote-controlled car using an Arduino and an infrared (IR) remote. The car's movement is controlled by decoding IR signals and managing motors through an H-bridge. This project enhances your understanding of IR communication and motor control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;18. Temperature Controlled Fan&lt;/strong&gt;&lt;br&gt;
This project is used to create a fan that adjusts its speed based on the ambient temperature using a temperature sensor like LM35. The sensor data is processed by the Arduino to control the speed of a fan via a PWM signal. This project is excellent for learning about temperature sensing and motor control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;19. Fingerprint Attendance System&lt;/strong&gt;&lt;br&gt;
This project is used to create an attendance system that uses fingerprint recognition. When a user scans their fingerprint, the sensor sends data to the Arduino, which verifies the identity and logs the attendance. This project introduces biometric authentication and data management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;20. Intruder Alarm System&lt;/strong&gt;&lt;br&gt;
This project is used to detect motion using PIR sensors and trigger an alarm to alert of intrusions. The Arduino processes the sensor data and activates a buzzer when motion is detected. This project provides practical experience with motion detection and security systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;21. Remote Weather Monitoring Station&lt;/strong&gt;&lt;br&gt;
This project is used to send temperature and humidity data to a smartphone using an ESP8266 Wi-Fi module. The Arduino collects data from sensors and sends it to the cloud, where it can be accessed remotely. This project is a great introduction to IoT and remote monitoring.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;22. Gesture Controlled Robot&lt;/strong&gt;&lt;br&gt;
This project is used to control a robot using hand gestures detected by an accelerometer sensor. The sensor data is processed by the Arduino to determine the direction of movement and control the motors accordingly. This project combines accelerometer sensing with robotic control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Useful Resources&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.playwithcircuit.com/"&gt;Play with Circuit&lt;/a&gt;:&lt;/strong&gt; is a website dedicated to providing tutorials, circuits, and projects for electronics enthusiasts, particularly those interested in Arduino. Here you can find DIY Arduino Project and Programming Tutorial.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.instructables.com/"&gt;Instructables&lt;/a&gt;:&lt;/strong&gt; Instructables is a platform where you can find projects with detailed instructions, photos, videos, and sometimes even downloadable code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://create.arduino.cc/projecthub"&gt;Arduino Project Hub&lt;/a&gt;:&lt;/strong&gt; Arduino Project Hub is an official platform provided by Arduino for sharing projects created by the Arduino community. You can find a diverse range of projects categorized by difficulty level, type, and theme. Each project includes a detailed description, code, schematics, and sometimes even video tutorials.&lt;/p&gt;

&lt;p&gt;These websites are great resources for finding inspiration, learning new skills, and discovering exciting projects to build with Arduino.&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>electronics</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to Interface TTP223B Touch Sensor with Arduino</title>
      <dc:creator>Akshay Jain</dc:creator>
      <pubDate>Wed, 15 May 2024 11:23:33 +0000</pubDate>
      <link>https://dev.to/akshay_jain/how-to-interface-ttp223b-touch-sensor-with-arduino-1co5</link>
      <guid>https://dev.to/akshay_jain/how-to-interface-ttp223b-touch-sensor-with-arduino-1co5</guid>
      <description>&lt;p&gt;The capacitive TTP223B Touch Sensor is an electronic component used to detect touch or proximity. It operates based on changes in capacitance when a conductive object, like a finger, comes into contact with or near the sensor. &lt;br&gt;
The TTP223B sensor is a popular choice due to its low power consumption, simple interface, and reliability. It can be easily interfaced with Arduino. &lt;/p&gt;

&lt;p&gt;In this project, we will learn how to interface the TTP223B capacitive touch sensor switch with an Arduino. &lt;/p&gt;
&lt;h2&gt;
  
  
  What is TTP223B Capacitive Touch Sensor?
&lt;/h2&gt;

&lt;p&gt;The TTP223B is1-channel capacitive touch sensor module that detects touch input through a capacitive touch pad. It operates on low power consumption and is sensitive to even slight touch. The module includes a built-in power-on reset circuit, eliminating the need for an external power-on reset. &lt;br&gt;
It also features a toggle mode, where touching the pad toggles the output between high and low states, and a momentary mode, where the output remains high only as long as the pad is touched. With its simple interface and reliable performance, the TTP223B is commonly used in various electronic applications such as touch-sensitive controls for lamps, appliances, and interactive displays.&lt;/p&gt;
&lt;h2&gt;
  
  
  Working of TTP223B Capacitive Touch Sensor
&lt;/h2&gt;

&lt;p&gt;The TTP223B capacitive touch sensor operates based on the principle of capacitance change upon touch. When no touch is detected, the sensor's internal circuitry maintains a stable state. However, when a conductive object, such as a finger, comes into close proximity to the touch pad, it creates a change in capacitance. This change is detected by the sensor's circuitry, causing it to trigger an output signal. The output signal can be configured to behave in different ways depending on the mode selected, such as toggling between high and low states upon touch or remaining high only as long as the touch is present. &lt;/p&gt;
&lt;h2&gt;
  
  
  TTP223B Touch Sensor Pinout
&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%2Fxgyqh3gla8q19wcsif03.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%2Fxgyqh3gla8q19wcsif03.JPG" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's the pinout of the TTP223B touch sensor:&lt;br&gt;
&lt;strong&gt;VCC:&lt;/strong&gt; This pin is the power supply input for the sensor. It is typically connected to a voltage source such as 3.3V or 5V.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Signal:&lt;/strong&gt; This pin is the digital output signal of the sensor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GND:&lt;/strong&gt; This pin is the ground connection for the sensor. It is connected to the ground of the circuit.&lt;/p&gt;
&lt;h2&gt;
  
  
  Interfacing TTP223B Touch Sensor with Arduino
&lt;/h2&gt;

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

&lt;ul&gt;
&lt;li&gt;1 Arduino UNO
&lt;/li&gt;
&lt;li&gt;1 Touch Sensor
&lt;/li&gt;
&lt;li&gt;1 LED
&lt;/li&gt;
&lt;li&gt;1 100 ohms Resistance
&lt;/li&gt;
&lt;li&gt;1 Small size Breadboard
&lt;/li&gt;
&lt;li&gt;5 Connection wires&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Software&lt;/strong&gt;&lt;br&gt;
Arduino IDE, Version 2.1.1 or above installed on your PC&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Circuit Diagram&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%2F977m1bah4l9gnz50yve8.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%2F977m1bah4l9gnz50yve8.JPG" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*
Interfacing TTP223B Touch Sensor with Arduino
by www.PlaywithCircuit.com
*/
// Define pin numbers
const int touchPin = 2;  // Define the pin number for touch sensor
const int ledPin = 4;    // Define the pin number for LED

void setup() {
 // Initialize serial communication at 9600 baud
 Serial.begin(9600);

 // Set pin modes
 pinMode(touchPin, INPUT);  // Set touchPin as input
 pinMode(ledPin, OUTPUT);   // Set ledPin as output
}

void loop() {
 // Read the state of the touch sensor
 int touchState = digitalRead(touchPin);

 // Check if touch is detected
 if (touchState == HIGH) {
   // Turn on LED
   digitalWrite(ledPin, HIGH);

   // Print touch detected message
   Serial.println("Touch detected!");
   // Staty in the below loop as long as touch is detected.
   while (digitalRead(touchPin) == HIGH);
 } else {
   // Turn off LED
   digitalWrite(ledPin, LOW);
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Code Explanation
&lt;/h2&gt;

&lt;p&gt;Here, two integer variables &lt;code&gt;touchPin&lt;/code&gt; and &lt;code&gt;ledPin&lt;/code&gt; are declared and assigned the pin numbers to which the touch sensor and LED are connected, respectively.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Define pin numbers
const int touchPin = 2;  // Define the pin number for touch sensor
const int ledPin = 4;    // Define the pin number for LED
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;setup()&lt;/code&gt; function is used to initialize the serial communication at a baud rate of 9600 and set the pin modes for &lt;code&gt;touchPin&lt;/code&gt; and &lt;code&gt;ledPin&lt;/code&gt;. &lt;code&gt;touchPin&lt;/code&gt; is configured as an input pin to read the state of the touch sensor, while &lt;code&gt;ledPin&lt;/code&gt; is configured as an output pin to control the LED.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void setup() {
  // Initialize serial communication at 9600 baud
  Serial.begin(9600);
  // Set pin modes
  pinMode(touchPin, INPUT);  // Set touchPin as input
  pinMode(ledPin, OUTPUT);   // Set ledPin as output
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;loop()&lt;/code&gt; function continuously reads the state of the touch sensor using digitalRead(touchPin). If touch is detected (i.e., the touchState is HIGH), the LED connected to &lt;code&gt;ledPin&lt;/code&gt; is turned on by setting it to HIGH using &lt;code&gt;digitalWrite(ledPin, HIGH)&lt;/code&gt;, and a message "Touch detected!" is printed to the serial monitor. Then, it enters a loop that continuously checks if the touch sensor is still being touched. Once the touch is released, the loop exits, and the LED is turned off. If no touch is detected, the LED remains off.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void loop() {
  // Read the state of the touch sensor
  int touchState = digitalRead(touchPin);
  // Check if touch is detected
  if (touchState == HIGH) {
    // Turn on LED
    digitalWrite(ledPin, HIGH);
    // Print touch detected message
    Serial.println("Touch detected!");
    // Stay in the below loop as long as touch is detected.
    while (digitalRead(touchPin) == HIGH);
  } else {
    // Turn off LED
    digitalWrite(ledPin, LOW);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Output
&lt;/h2&gt;

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

&lt;p&gt;For more indepth guide checkout &lt;strong&gt;&lt;a href="https://playwithcircuit.com/how-to-interface-ttp223b-touch-sensor-with-arduino/"&gt;How to Interface TTP223B Touch Sensor with Arduino&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>diy</category>
      <category>programming</category>
      <category>coding</category>
    </item>
  </channel>
</rss>
