Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript

LED

Bar graph

By: Alexia Campbell

What is an LED bar graph?

An LED Bar Graph is a series of LEDs in a line; It's a (common) hardware display for analog sensors. It is made up of a series of LEDs in a row and an analog input. (like a potentiometer).

How Does an LED Bar graph work?

LED bar graphs are very useful as indicators for displaying levels of something (i.e. sound volume). They can

also vary in color

and number of LEDs

in the array.

. . .

In my example, the bars of the bar graph will light up incrementally as the potentiometer turns.

History Of The LED

Made in: The 1960s (October of 1962)

Created by: Nick Holonyak

Context: The LED was created

because Holonyak wanted to find a way to create a laser directly

with a semiconductor instead

of producing light with an

incandescent bulb and

amplifying it.

Nick Holonyak

. . .

LED BAR GRAPH Modification

For my modification, I have modified the coding of an LED bar graph by adding a speaker that will emit a sound, and it's frequency will increase as the bars light up.

Base Code

- "serial.begin" command starts serial communication so that

Arduino can send out

commands through

the USB connection.

- "analogRead()"

command reads

the value

specified.

int sensorPin = A0;

const int LED1 = 12;

const int LED2 = 11;

const int LED3 = 10;

const int LED4 = 9;

const int LED5 = 8;

const int LED6 = 7;

const int LED7 = 6;

const int LED8 = 5;

const int LED9 = 4;

const int LED10 = 3;

void setup()

{

Serial.begin(9600);

pinMode(LED1, OUTPUT);

pinMode(LED2, OUTPUT);

pinMode(LED3, OUTPUT);

pinMode(LED4, OUTPUT);

pinMode(LED5, OUTPUT);

pinMode(LED6, OUTPUT);

pinMode(LED7, OUTPUT);

pinMode(LED8, OUTPUT);

pinMode(LED9, OUTPUT);

pinMode(LED10, OUTPUT);

}

if (sensorValue <100)

{digitalWrite(LED10, LOW);

delay(10);}

if (sensorValue <200)

{digitalWrite(LED9, LOW);

delay(10);}

if (sensorValue <300)

{digitalWrite(LED8, LOW);

delay(10);}

if (sensorValue <400)

{digitalWrite(LED7, LOW);

delay(10);}

if (sensorValue <500)

{digitalWrite(LED6, LOW);

delay(10);}

if (sensorValue <600)

{digitalWrite(LED5, LOW);

delay(10);}

if (sensorValue <700)

{digitalWrite(LED4, LOW);

delay(10);}

if (sensorValue <800)

{digitalWrite(LED3, LOW);

delay(10);}

if (sensorValue <900)

{digitalWrite(LED2, LOW);

delay(10);}

if (sensorValue <1023

)

{digitalWrite(LED1, LOW);

delay(10);}

}

void loop() {

int sensorValue;

sensorValue = analogRead(sensorPin);

Serial.println(sensorValue);

if (sensorValue >= 100)

{digitalWrite(LED10, HIGH);

delay(10);}

if (sensorValue >=200)

{digitalWrite(LED9, HIGH);

delay(10);}

if (sensorValue >=300)

{digitalWrite(LED8, HIGH);

delay(10);}

if (sensorValue >=400)

{digitalWrite(LED7, HIGH);

delay(10);}

if (sensorValue >=500)

{digitalWrite(LED6, HIGH);

delay(10);}

if (sensorValue >=600)

{digitalWrite(LED5, HIGH);

delay(10);}

if (sensorValue >=700)

{digitalWrite(LED4, HIGH);

delay(10);}

if (sensorValue >=800)

{digitalWrite(LED3, HIGH);

delay(10);}

if (sensorValue >=900)

{digitalWrite(LED2, HIGH);

delay(10);}

if (sensorValue >=1023)

{digitalWrite(LED1, HIGH);

delay(10);}

- "delay" command will pause the program for the amount of time specified (in miliseconds).

Modified Code

int sensorPin = A0;

int SPEAKER = 2;

int freq = 200;

const int LED1 = 12;

const int LED2 = 11;

const int LED3 = 10;

const int LED4 = 9;

const int LED5 = 8;

const int LED6 = 7;

const int LED7 = 6;

const int LED8 = 5;

const int LED9 = 4;

const int LED10 = 3;

void setup() {

Serial.begin(9600);

pinMode(SPEAKER, OUTPUT);

pinMode(LED1, OUTPUT);

pinMode(LED2, OUTPUT);

pinMode(LED3, OUTPUT);

pinMode(LED4, OUTPUT);

pinMode(LED5, OUTPUT);

pinMode(LED6, OUTPUT);

pinMode(LED7, OUTPUT);

pinMode(LED8, OUTPUT);

pinMode(LED9, OUTPUT);

pinMode(LED10, OUTPUT);

}

What was added?

A speaker was added into circuit. With this modified code, the speaker will constantly beep and the frequency will increase as the bars on the LED bar graph begin to light up.

- "tone()" command generates a wave of the frequency specified in your code on a pin.

- "noTone()" command discontinues the "tone()" command when called.

void loop() {

int sensorValue;

sensorValue = analogRead(sensorPin);

Serial.println(sensorValue);

if (sensorValue >= 100)

{digitalWrite(LED10, HIGH);

tone(SPEAKER,freq);

delay(10);}

if (sensorValue >=200)

{digitalWrite(LED9, HIGH);

tone(SPEAKER,freq);

delay(10);}

if (sensorValue >=300)

{digitalWrite(LED8, HIGH);

tone(SPEAKER,freq);

delay(10);}

if (sensorValue >=400)

{digitalWrite(LED7, HIGH);

tone(SPEAKER,freq);

delay(10);}

if (sensorValue >=500)

{digitalWrite(LED6, HIGH);

tone(SPEAKER,freq);

delay(10);}

if (sensorValue >=600)

{digitalWrite(LED5, HIGH);

tone(SPEAKER,freq);

delay(10);}

if (sensorValue >=700)

{digitalWrite(LED4, HIGH);

tone(SPEAKER,freq);

delay(10);}

if (sensorValue >=800)

{digitalWrite(LED3, HIGH);

tone(SPEAKER,freq);

delay(10);}

if (sensorValue >=900)

{digitalWrite(LED2, HIGH);

tone(SPEAKER,freq);

delay(10);}

if (sensorValue >=1023)

{digitalWrite(LED1, HIGH);

tone(SPEAKER,freq);

delay(10);}

if (sensorValue <100)

{digitalWrite(LED10, LOW);

noTone(SPEAKER);

delay(10);}

if (sensorValue <200)

{digitalWrite(LED9, LOW);

noTone(SPEAKER);

delay(10);}

if (sensorValue <300)

{digitalWrite(LED8, LOW);

noTone(SPEAKER);

delay(10);}

if (sensorValue <400)

{digitalWrite(LED7, LOW);

noTone(SPEAKER);

delay(10);}

if (sensorValue <500)

{digitalWrite(LED6, LOW);

noTone(SPEAKER);

delay(10);}

if (sensorValue <600)

{digitalWrite(LED5, LOW);

noTone(SPEAKER);

delay(10);}

if (sensorValue <700)

{digitalWrite(LED4, LOW);

noTone(SPEAKER);

delay(10);}

if (sensorValue <800)

{digitalWrite(LED3, LOW);

noTone(SPEAKER);

delay(10);}

if (sensorValue <900)

{digitalWrite(LED2, LOW);

noTone(SPEAKER);

delay(10);}

if (sensorValue <1023)

{digitalWrite(LED1, LOW);

delay(10);}

}

LED Bar Graph Appliances

Some appliances you could find an LED bar graph

would be in a (digital) gauge meter, control panels, audio equipment, and a battery level indicator.

Programming the graph to, not only light up at certain

measurment increments but also display a different color as the graph's bars progressively light up (depending on the bar graph used) would allow these appliances to function with their respective purposes.

CITATIONS

- https://docs.arduino.cc/built-in-examples/display/BarGraph

- https://www.instructables.com/Controlling-simple-LED-Bar-Graph-with-Arduino/#:~:text=LED%20Bar%20graphs%20is%20basically,of%20LEDs%20in%20the%20array.&text=So%2010%20LED%20Bar%20Graph%20will%20have%2020%20pins.

- https://cleanpowerplanet.com/renewable-energy-stories/who-invented-the-led/

Learn more about creating dynamic, engaging presentations with Prezi