In this tutorial, you will come to learn about Bar Graph circuit. This tutorial is based on previous project that we have done . An LED Bar graph can control with potentiometer.

To complete this project we require following component :-
S.no. | Component |
---|---|
1 | Arduino board |
2 | Breadboard |
3 | Jumper wires |
4 | 9 x LED |
5 | 50 K Potentiometer |
6 | 9 x 220 ohm Resistor |
7 | Arduino Uno cable. |
8 | POWER SUPPLY |

Circuit Diagram

How its Work :-

Bargraph is series of LED line. Its is made up of led with a analog input like a potentiometer or microphone. we take analog signal from potentiometer and rotate potentiometer in one way then led will glow one by one.
Project code :-
//www.kits4utech.com//
//welcome to kits4u tech blog//
const int analogPin = A0; // Pin connected to the potentiometer
const int ledCount = 9; // Number of LEDs
int ledPins[] = {2,3,4,5,6,7,8,9,10}; // Pins connected to the LEDs
void setup() {
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT); // Set the LED pins as output
}
}
// Start a loop
void loop() {
int sensorReading = analogRead(analogPin); // Analog input
int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
if (thisLed < ledLevel) { // Turn on LEDs in sequence
digitalWrite(ledPins[thisLed], HIGH);
}
else { // Turn off LEDs in sequence
digitalWrite(ledPins[thisLed], LOW);
}
}