Call Us Now
0242159130 | 0546096840
Up to 2% reward

For new all Customers

Delevery schedule

We deliver  the same day through VIP bus parcel Service in Ghana

Discount on order gift

Save ¢10.00 when you spend ¢600+! 

how to control LED Bar Graph Display

how to control LED Bar Graph Display

Experiment 7

In this tutorial, we will learn how to control an LED bar graph by programming the Arduino.

Hardware required

1 * Arduino UNO

1 * USB Cable

1 * 10kΩ Potentiometer

10 * 220Ω Resistor

1 * LED Bar Graph

1 * Breadboard

Several jumper wires

Principle of operation

The bar graph - a series of LEDs in a line, as you can see on an audio display, is a common hardware display for analog sensors. It's made up of a series of LEDs in a row, an analog input like a potentiometer, and a little code in between.Youcanbuymulti-LEDbargraphdisplaysfairly cheaply.Thistutorial demonstrates how to control a series of LEDs in a row, but can be applied to any series of digital outputs. 

The sketch works like this: first read the input. Map the input to the output rangewhich is 0-10in this casesince tenLEDsareused.Thenyousetupa f o r loop to iterate over the outputs. If the number in the array of the output is lower than the mapped input minimum, it is turned on. If not, it's off

A potentiometer, informally a pot, is a three-terminal resistor with a sliding or rotating contact that forms an adjustable voltage divider. If only twoterminals are used, one end and the wiper, it acts as a variable resistor or rheostat. 

Experiment code

//File name:   Experiment 7

//Description:  LED Bar Graph Display  .

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/06/08 

int pin1 = 1;
int pin2 = 2;
int pin3 = 3;
int pin4 = 4;
int pin5 = 5;
int pin6 = 6;
int pin7 = 7;
int pin8 = 8;
int pin9 = 9;
int pin10 = 10;           //definition digital 10 pins as pin to control the LED

int potentiometerPin = 0; // potentiometer connected to analog pin 3

void setup()
{
  pinMode(pin1,OUTPUT);    //Set the digital 1 port mode, OUTPUT: Output mode
  pinMode(pin2,OUTPUT);    //Set the digital 2 port mode, OUTPUT: Output mode
  pinMode(pin3,OUTPUT);    //Set the digital 3 port mode, OUTPUT: Output mode
  pinMode(pin4,OUTPUT);    //Set the digital 4 port mode, OUTPUT: Output mode
  pinMode(pin5,OUTPUT);    //Set the digital 5 port mode, OUTPUT: Output mode
  pinMode(pin6,OUTPUT);    //Set the digital 6 port mode, OUTPUT: Output mode
  pinMode(pin7,OUTPUT);    //Set the digital 7 port mode, OUTPUT: Output mode
  pinMode(pin8,OUTPUT);    //Set the digital 8 port mode, OUTPUT: Output mode
  pinMode(pin9,OUTPUT);    //Set the digital 9 port mode, OUTPUT: Output mode
  pinMode(pin10,OUTPUT);    //Set the digital 10 port mode, OUTPUT: Output mode
}

void loop() 
{
   float a = analogRead(potentiometerPin);//Read the voltage photoresistance
   a = map(a,0,1023,0,11);    //Photoresistor voltage value converted from 0-1023 to 0-11
   for(int i=1;i<=a;i++){
      digitalWrite(i,LOW);    //HIGH is set to about 5V PIN8
   }
   for(int j=10;j>a;j--){
      digitalWrite(j,HIGH);   //HIGH is set to about 5V PIN8
   }   
   delay(50);                 //delay 50ms
}


Compile the program and upload to Arduino UNO board Now,turn the knob of the potentiometer,and you will see the number ofLEDs in the LED bar graph changed


Comments

John
19/10/2019
Hello, I really need some code to show me how to initialize and LED display and how to output data from it. Any help is much appreciated.

Add Comment