<?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: Play with Circuit</title>
    <description>The latest articles on DEV Community by Play with Circuit (@play_withcircuit_241ef87).</description>
    <link>https://dev.to/play_withcircuit_241ef87</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%2F3015801%2Fb43108d4-24c1-491c-9ced-9c27b9020370.jpg</url>
      <title>DEV Community: Play with Circuit</title>
      <link>https://dev.to/play_withcircuit_241ef87</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/play_withcircuit_241ef87"/>
    <language>en</language>
    <item>
      <title>Arduino Servo Motor Control</title>
      <dc:creator>Play with Circuit</dc:creator>
      <pubDate>Wed, 15 Apr 2026 09:38:35 +0000</pubDate>
      <link>https://dev.to/play_withcircuit_241ef87/arduino-servo-motor-control-53k0</link>
      <guid>https://dev.to/play_withcircuit_241ef87/arduino-servo-motor-control-53k0</guid>
      <description>&lt;p&gt;When working on robotics or automation projects, one of the most commonly used components is the servo motor. Unlike regular DC motors, servo motors are designed for precise position control, making them ideal for applications like robotic arms, camera positioning systems, and mechanical linkages.&lt;/p&gt;

&lt;p&gt;In this project, we will first understand how to interface a servo motor with the Arduino Uno and control its movement. Along with that, we will also build a simple servo tester, which is extremely useful for checking whether a servo is functioning correctly before using it in a larger system.&lt;/p&gt;

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

&lt;p&gt;Arduino Uno&lt;br&gt;
SG90 Micro Servo Motor&lt;br&gt;
Breadboard&lt;br&gt;
Jumper wires&lt;br&gt;
10kΩ Potentiometer&lt;br&gt;
16x2 LCD (optional but useful)&lt;br&gt;
220Ω resistor&lt;br&gt;
USB cable or 5V supply&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Servo Motor
&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%2Fd10idifymdro5ikpskh1.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%2Fd10idifymdro5ikpskh1.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
A servo motor is a compact device that combines a DC motor, a gear mechanism, and a feedback system. This feedback system continuously monitors the position of the output shaft and adjusts it to match the desired angle. Because of this closed-loop control, servo motors can move to a specific position and hold it steadily.&lt;/p&gt;

&lt;p&gt;Most hobby servo motors, such as the popular SG90, can rotate approximately from 0° to 180°. They are controlled using a PWM (Pulse Width Modulation) signal. Instead of changing voltage, the control is achieved by varying the width of the pulse sent to the signal pin. The internal electronics interpret this pulse width and rotate the shaft accordingly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working Principle of Servo Control
&lt;/h2&gt;

&lt;p&gt;The core concept behind controlling a servo motor is PWM. The Arduino generates a series of pulses, and the duration of each pulse determines the position of the servo shaft. For example, a shorter pulse corresponds to one extreme position (around 0 degrees), a medium pulse places the servo at the center (around 90 degrees), and a longer pulse moves it to the other extreme (around 180 degrees).&lt;/p&gt;

&lt;p&gt;The servo’s internal control circuit continuously compares the received signal with its current position using feedback from the internal potentiometer. If there is a difference, it drives the motor until the desired position is reached. This is why servo motors are highly accurate and stable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Circuit Diagram
&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%2Fc3nmfa1x3zetcbl3deik.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%2Fc3nmfa1x3zetcbl3deik.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
The circuit for interfacing a servo motor with Arduino is quite simple. The power wire of the servo is connected to the 5V pin of the Arduino, while the ground wire is connected to the GND pin. The control wire is connected to one of the PWM-enabled digital pins, commonly pin 10.&lt;/p&gt;

&lt;p&gt;Once the connections are made, the Arduino sends PWM signals through the control pin, and the servo rotates according to the signal timing. This setup is sufficient for basic control and experimentation.&lt;/p&gt;

&lt;p&gt;However, if you are using multiple servos or require more stable performance, it is often recommended to use an external power supply instead of relying solely on the Arduino’s 5V output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building a Servo Tester Using Arduino
&lt;/h2&gt;

&lt;p&gt;A servo tester is a simple yet powerful tool that allows you to manually control and verify the performance of a servo motor. Instead of writing different code snippets repeatedly, a tester provides an intuitive way to check whether the servo responds correctly.&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%2F1xbq625ol7yn9zul4qme.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%2F1xbq625ol7yn9zul4qme.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this setup, a 10k potentiometer is used as an input device. The middle pin of the potentiometer is connected to the analog pin A0 of the Arduino. As you rotate the knob, the analog value changes, and the Arduino maps this value to a corresponding servo angle.&lt;/p&gt;

&lt;p&gt;The servo motor is connected in the same way as before, with its signal pin connected to pin 10. When the potentiometer is turned, the servo rotates smoothly, following the input. This gives you direct control over the servo position.&lt;/p&gt;

&lt;p&gt;If you add a 16x2 LCD display, the system becomes even more informative. The Arduino can display the current angle of the servo in real time. This allows you to verify whether the physical movement of the servo matches the expected angle. If the movement is inconsistent or unresponsive, it may indicate a faulty servo.&lt;/p&gt;

&lt;p&gt;This type of tester is particularly useful when working on larger projects where multiple servos are involved, as it helps ensure reliability before integration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This project introduces you to both controlling and testing servo motors, which are essential skills in embedded systems and robotics. Understanding how PWM signals translate into physical motion gives you a strong foundation for more advanced designs.&lt;/p&gt;

&lt;p&gt;By building a simple servo tester, you also learn how to validate components efficiently—something that becomes increasingly important as your projects grow in complexity.&lt;/p&gt;

&lt;p&gt;As you move forward, you can expand this concept into multi-servo systems, robotic mechanisms, or even custom-designed hardware using professional PCB services like PCBWay.&lt;/p&gt;

&lt;p&gt;For complete step-by-step instructions, Arduino code, and a detailed servo motor testing setup, check the full guide here:&lt;br&gt;
&lt;a href="https://playwithcircuit.com/how-to-interface-servo-motor-with-arduino/" rel="noopener noreferrer"&gt;https://playwithcircuit.com/how-to-interface-servo-motor-with-arduino/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>arduino</category>
    </item>
    <item>
      <title>Water Level Sensor with Arduino</title>
      <dc:creator>Play with Circuit</dc:creator>
      <pubDate>Fri, 04 Apr 2025 11:21:56 +0000</pubDate>
      <link>https://dev.to/play_withcircuit_241ef87/water-level-sensor-with-arduino-1ic8</link>
      <guid>https://dev.to/play_withcircuit_241ef87/water-level-sensor-with-arduino-1ic8</guid>
      <description>&lt;p&gt;Water wastage due to tank overflow is a common issue faced in many homes and buildings. Fortunately, this problem can be effectively addressed with a simple and affordable solution: a Water Level Sensor. By integrating this sensor with an Arduino, we can monitor the water level inside a tank in real-time and trigger alerts—such as turning on an LED or buzzer—when the tank is about to overflow.&lt;br&gt;
In this tutorial, you'll learn how water level sensors work, how to connect them to an Arduino.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does a Water Level Sensor Work?
&lt;/h2&gt;

&lt;p&gt;A water level sensor detects the presence or height of water in a container by measuring the electrical resistance between exposed conductive traces. When water comes into contact with the sensor, it changes the resistance between these traces, which in turn alters the output voltage.&lt;/p&gt;

&lt;p&gt;Here's how it works:&lt;br&gt;
More water → more conductivity → lower resistance → higher output voltage&lt;br&gt;
Less water → less conductivity → higher resistance → lower output voltage&lt;br&gt;
This analog voltage output is then read by an Arduino analog pin and mapped to represent the water level. The deeper the water covers the sensor, the higher the voltage output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Water Level Sensor Specifications
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Operating voltage: 3 to 5V, &amp;lt; 20mA&lt;/li&gt;
&lt;li&gt;Humidity: 10%-90% non-condensing&lt;/li&gt;
&lt;li&gt;Operating Temperature: 10℃-30℃&lt;/li&gt;
&lt;li&gt;Sensor Type: Analog&lt;/li&gt;
&lt;li&gt;Output Voltage Range: 0 to 3.85V&lt;/li&gt;
&lt;li&gt;Detection Area: 40mm (height) x 16mm (width)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Water Level Sensor Hardware Overview
&lt;/h2&gt;

&lt;p&gt;The water level sensor consists of 10 parallel conductive traces:&lt;br&gt;
5 Power Traces (connected to VCC)&lt;br&gt;
5 Sense Traces (connected to signal output)&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%2F3i97hin6soznhg8b7kc9.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%2F3i97hin6soznhg8b7kc9.PNG" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
These traces are arranged alternately so that each sensing trace is placed between two power traces. When water bridges the traces, it allows current to flow, which is interpreted by the internal circuit as an increase in water level.&lt;br&gt;
The module also contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A power LED to indicate the sensor is powered.&lt;/li&gt;
&lt;li&gt;An NPN transistor for switching behavior.&lt;/li&gt;
&lt;li&gt;Multiple resistors to limit current and protect the components.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pinout of Water Level 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%2F2y78aebl3p17h2seyy66.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%2F2y78aebl3p17h2seyy66.PNG" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;VCC:&lt;/strong&gt; Power supply pin (connect to 5V on Arduino)&lt;br&gt;
&lt;strong&gt;GND:&lt;/strong&gt; Ground connection&lt;br&gt;
&lt;strong&gt;OUT:&lt;/strong&gt; Analog output (connect to Arduino analog pin)&lt;/p&gt;

&lt;h2&gt;
  
  
  Schematic Diagram
&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%2Fz34w3a62agx7emezf5k3.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%2Fz34w3a62agx7emezf5k3.PNG" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The internal working of the sensor module can be broken down into these parts:&lt;br&gt;
&lt;strong&gt;NPN Transistor (Q1):&lt;/strong&gt; Acts as a switch, turning on when the sensor detects water.&lt;br&gt;
&lt;strong&gt;Resistors (R1, R2, R3):&lt;/strong&gt; Limit the current and protect the components.&lt;br&gt;
&lt;strong&gt;Copper Traces:&lt;/strong&gt; The power traces are connected to VCC through resistors, and sense traces go to the transistor's base.&lt;/p&gt;

&lt;p&gt;**Working Principle: **When water bridges the traces, it creates a voltage at the transistor’s base. This allows current to flow from collector to emitter, effectively turning the transistor ON. As a result, the signal pin provides an analog voltage output that increases with water level.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wiring a Water Level Sensor to Arduino
&lt;/h2&gt;

&lt;p&gt;The circuit diagram is shown as follows:&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%2Fh2s2yzllmk6hfoe0b590.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%2Fh2s2yzllmk6hfoe0b590.PNG" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wiring:&lt;/strong&gt;&lt;br&gt;
Sensor VCC → Arduino 5V&lt;br&gt;
Sensor GND → Arduino GND&lt;br&gt;
Sensor OUT → Arduino A0 (analog pin)&lt;br&gt;
SCK and SDA pins of LCD → I2C pin of the Arduino&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 Water Level Sensor with Arduino UNO using Analog Output pin of Module
by www.playwithcircuit.com
Using this code we will know the Analog Value when water level is very low and when it is very high.
*/
#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;  // Library to Run I2C LCD
// define the size of filter array
#define FILTER_SIZE 20
// 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 soil moisture sensor
const int WaterSensorPin = A0;
// 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();
  // Print a message to the LCD
  lcd.setCursor(0, 0);
  lcd.print("Analog Value:");
}
void loop() {
  // Variable to store sensor values
  int sensorValue;
  // Variable to store filtered values
  int filteredValue;
  // Read the value from the soil moisture sensor
  sensorValue = analogRead(WaterSensorPin);
  filteredValue = Filter(sensorValue);
  // Display the filtered Analog Value on the LCD
  lcd.setCursor(0, 1);
  lcd.print(filteredValue);
  // Clear Previous Data
  lcd.print("   ");
  // Wait for 50ms before the next loop
  delay(50);
}
// Averaging filter to filter Analog Values
int Filter(int sensorValue) {
  static int analogArray[FILTER_SIZE] = { 0 };
  int filteredValue = 0;
  int i;
  // Shift the Elemnent 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 how to create a water level indicator checkout: &lt;a href="https://playwithcircuit.com/water-level-sensor-arduino-tutorial/" rel="noopener noreferrer"&gt;https://playwithcircuit.com/water-level-sensor-arduino-tutorial/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>arduino</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
