1. Introduction
A variable smart power supply allows continuous adjustment of voltage for electronics experiments, testing, and prototyping. By using a DC-DC buck converter, this supply is highly efficient, generates minimal heat, and can handle higher currents than linear regulators like LM317.
Integrating Arduino allows real-time monitoring of voltage and current on an LCD, software protection, and optional digital voltage control, making it ideal for labs, DIY electronics, and robotics projects.
2. Components
| Component | Quantity | Description |
|---|---|---|
| Arduino Uno | 1 | Microcontroller to control and monitor the system |
| DC-DC Buck Converter (LM2596) | 1 | Adjustable step-down voltage module |
| ACS712 Current Sensor (5A/20A) | 1 | Measures load current |
| 16x2 I2C LCD Display | 1 | Displays voltage and current |
| 10k Potentiometer | 1 | Sets desired output voltage |
| Push Buttons | 2 (optional) | Increment/decrement voltage digitally |
| Wires & Breadboard/PCB | As required | Connections |
| 12–24V DC Power Supply | 1 | Input to buck converter |
| Heatsink | Optional | For high-current loads |
3. Circuit and Connections
| Pinout ACS712 |
| Pinout Diagram LM2596 |
Circuit Overview:
- Power Input: Connect 12–24V DC to the buck converter module.
- Voltage Adjustment: Arduino reads a potentiometer for voltage setpoint. Optional buttons can increment/decrement output.
- Current Sensing: ACS712 senses current and sends analog voltage to Arduino.
- Display: LCD shows live voltage and current values.
Pin Connections:
| Component | Arduino Pin | Notes |
|---|---|---|
| LCD I2C 16x2 | SDA → A4, SCL → A5 | 5V & GND connected |
| ACS712 Sensor | A0 | Analog voltage proportional to current |
| Potentiometer | A1 | Analog voltage input for desired output |
| Buck Converter PWM/Control | D9 | Optional, for PWM-based voltage control |
| Push Buttons | D2 & D3 | Optional voltage increment/decrement |
Note: If your buck converter does not support PWM input, adjust the onboard potentiometer manually; Arduino will still monitor voltage/current.
4. Detailed Step by Step Circuit Working
-
Voltage Regulation:
The DC-DC buck converter efficiently steps down input voltage (12–24V) to the desired output. Arduino reads the potentiometer (analog input) to determine the desired output voltage. If the module supports analog control or PWM input, Arduino can adjust the voltage digitally. -
Current Monitoring:
The ACS712 sensor detects current drawn by the load. Its analog output is proportional to the current, which Arduino reads to calculate the actual current in amperes. -
Display & Feedback:
The 16x2 LCD displays real-time voltage and current. Users can monitor the load and adjust voltage for different devices safely. -
Protection:
Arduino software can limit maximum voltage or current to prevent overload or short circuits, making it a smart, protected supply.
5. Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
int currentPin = A0; // ACS712 current sensor
int potPin = A1; // Potentiometer for voltage
int pwmPin = 9; // Optional PWM control for buck converter
float voltageSet;
float currentValue;
void setup() {
lcd.init();
lcd.backlight();
pinMode(pwmPin, OUTPUT);
}
void loop() {
// Read potentiometer
int potValue = analogRead(potPin);
voltageSet = map(potValue, 0, 1023, 0, 120)/10.0; // 0-12V output
// Read current from ACS712
int currentAnalog = analogRead(currentPin);
currentValue = ((currentAnalog - 512) * 5.0 / 1023) / 0.185; // 5A sensor
// Output voltage control using PWM (if module supports)
int pwmValue = map(voltageSet, 0, 12, 0, 255);
analogWrite(pwmPin, pwmValue);
// Display on LCD
lcd.setCursor(0,0);
lcd.print("V: ");
lcd.print(voltageSet,2);
lcd.print("V ");
lcd.setCursor(0,1);
lcd.print("I: ");
lcd.print(currentValue,2);
lcd.print("A ");
delay(200);
}
6. Detailed Step by Step Code Working
-
Libraries Initialization:
LiquidCrystal_I2Clibrary initializes the LCD display for voltage and current readings. -
Analog Inputs:
-
A1reads potentiometer for desired voltage setpoint. -
A0reads ACS712 sensor analog output to measure current.
-
-
Voltage Mapping:
The potentiometer analog value (0–1023) is mapped to the output voltage range (0–12V). -
Current Calculation:
ACS712 analog output is converted to current using the sensor formula: -
PWM Output:
If buck converter supports PWM voltage control, Arduino outputs a PWM signal proportional to the desired voltage. -
LCD Display:
-
Top row shows voltage (
V: xx.xx V) -
Bottom row shows current (
I: xx.xx A) - Updated every 200 ms
-
Top row shows voltage (
-
Delay:
Small delay ensures stable readings without flickering the display.
7. Tips
- Ensure input voltage is always higher than desired output (at least 2–3V higher) for proper buck converter operation.
- Add heatsink for high-current loads to prevent overheating.
- If you want smoother voltage adjustment, use a larger potentiometer (10k–50k).
- For digital adjustment, use push buttons for incremental changes.
- Double-check ACS712 orientation; connecting it backwards will give negative readings.
8. Uses
- Electronics prototyping and testing
- Battery charging with adjustable current
- Robotics and IoT projects
- LED, motor, and sensor testing
- Educational electronics lab experiments
9. Conclusion
This Arduino-based variable smart power supply combines efficiency, flexibility, and safety. Using a DC-DC buck converter ensures minimal heat and higher output current. Arduino adds intelligence, allowing real-time monitoring, software protections, and optional digital voltage control. This project is ideal for electronics labs, robotics, and DIY experimentation.