Bar Graph Circuit using Arduino Uno R3 – Tutorial 4

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
1Arduino board
2Breadboard
3Jumper wires
49 x LED
550 K Potentiometer
69 x 220 ohm Resistor
7Arduino Uno cable.
8POWER 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);
 }
 }
Author: kits4ublog

Leave a Reply

Your email address will not be published.