To begin with, this DIY Variable Power Supply Circuit using Arduino makes changeable power, as it uses transistor and resistors to change 9V output from IC 7809 regulator.
Also, one 100uF capacitor help clean the output voltage, then two pushbuttons can change the voltage by hand and after that LCD screen show real output voltage.
Arduino Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int button1 = 7;
int button2 = 8;
int pwmPin = 9;
int dutyCycle = 0;
void setup() {
lcd.begin(16, 2);
lcd.print("Variable Power Supply");
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(pwmPin, OUTPUT);
}
void loop() {
if (digitalRead(button1) == HIGH) {
dutyCycle++;
if (dutyCycle > 255) {
dutyCycle = 255;
}
} else if (digitalRead(button2) == HIGH) {
dutyCycle--;
if (dutyCycle < 0) {
dutyCycle = 0;
}
}
analogWrite(pwmPin, dutyCycle);
lcd.setCursor(0, 1);
lcd.print("Voltage: ");
lcd.print(dutyCycle * 9 / 255);
lcd.print("V");
delay(100);
}
Code Explanation:
- Include Liquid Crystal library to control LCD.
- In setup, print welcome, start LCD and set input/output pins.
- In loop check push buttons always.
- Press Button 1, the duty cycle increases, similarly, when the user presses Button 2, the duty cycle decreases.
- Duty cycle change PWM output and so voltage also changes and then LCD will show voltage at that time.
Circuit Working:

Parts List:
| Components | Quantity |
|---|---|
| Resistors | |
| 1k 1/4 watt | 1 |
| 100k 1/4 watt | 2 |
| Capacitor | |
| 100µF 25V | 1 |
| Semiconductors | |
| Arduino Uno Board | 1 |
| LCD 16X2 | 1 |
| IC 7809 | 1 |
| Tactile switches | 2 |
| Transistor 2N2222 | 1 |
Arduino Uno give power to this variable power supply circuit and then IC 7809 give fixed 9V output if input is more than 9V then it does not changes.
After that voltage divider bring down voltage to 0 to 5V so Arduino can read it, then pin 9 of Arduino send PWM signal and PWM drive transistor like a switch.
Arduino read the small voltage and show it on LCD and then Arduino uses voltage divider calculation to find real output voltage.
Furthermore, 1k resistor control transistor base current so it control how much it work, then 100µF capacitor connect between 0 to 5V output and ground to make voltage stable and clean.
Finally, capacitor also reduces the noise and then LCD show the voltage at that time.
How to Build:
To build a DIY Variable Power Supply Circuit using Arduino follow the below mentioned steps for connections:
- First, collect all parts like in circuit diagram.
- Next, connect IC 7809 to give fixed 9V DC to Arduino.
- After that, connect button1 with one leg to pin 7 and other leg to ground then connect button2 with one leg to pin 8 and other leg to ground.
- Now put 100k resistor between pin 7 and 5V on Arduino and then put another 100k resistor between pin 8 and 5V on Arduino.
- Then connect LCD R/W pin to ground of Arduino.
Connect 2N2222 transistor:
- Now collector goes to 5V power, base goes to pin 9 through 1k resistor and then emitter goes to 0 to 5V output.
Connect 100µF capacitor:
- Also, positive leg goes to 0 to 5V output and then negative leg goes to ground from negative of output.
LCD Connections to Arduino Uno Board:
| Arduino Pin | LCD Pin | Function |
|---|---|---|
| 2 | RS | Register Select |
| 3 | EN | Enable |
| 4 | D4 | Data Bit 4 |
| 5 | D5 | Data Bit 5 |
| 6 | D6 | Data Bit 6 |
| 7 | D7 | Data Bit 7 |
| 11 | Backlight+ | Positive supply for backlight |
| 12 | Backlight- | Negative supply for backlight |
| 5V | VCC | Positive supply for LCD |
| GND | GND | Ground for LCD |
Conclusion:
Overall, this project for DIY Variable Power Supply Circuit using Arduino show how make simple and easy variable power source.
Moreover, PWM duty cycle changes so output voltage also change in a set range and then LCD give feedback to check output voltage.
Therefore, we can improve the project by adding automatic voltage control or implementing more accurate voltage measurement.