Previously, we have discussed about LED Bar Display. If you do not have LED Bar Display, you can use common LEDs for testing purpose. Here is Circuit and Code to Create LED Bar Graph Progress Test Project. We Will Shown the Project With Arduino and Als Only With Components Like Transistors. Basic matter of this project is that – we are using a potentiometer as analog input. When we rotate the knob of the potentiometer, the analog value changes. Depending on the rotational position (and thereby the value), the number of LEDs remains glowing. Most common application of this principle is in battery status meter and LED VU meter.
LED Bar Graph Progress Test : Arduino
We will need breadboard, Arduino Uno, potentiometer, few jumpers, 5 to 8 LED or LED bar graph display. First create the connection and make sure that all LEDs glows with 5V supply (with resistors). If jumpers or pins are defective, code will falsely appear as not working. Your setup will be like this with Arduino :
This is the code, we use the Arduino pins 5, 7, 10, 11, 12 so our third line is int ledPins[] = {5, 7, 10, 11, 12}
:
---
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | const int analogPin = A0; const int ledCount = 5; int ledPins[] = {5, 7, 10, 11, 12}; void setup() { for (int thisLed = 0; thisLed < ledCount; thisLed++) { pinMode(ledPins[thisLed], OUTPUT); } } void loop() { int sensorReading = analogRead(analogPin); int ledLevel = map(sensorReading, 0, 1023, 0, ledCount); for (int thisLed = 0; thisLed < ledCount; thisLed++) { if (thisLed < ledLevel) { digitalWrite(ledPins[thisLed], HIGH); }else { digitalWrite(ledPins[thisLed], LOW); } } } |
const int analogPin = A0: A0 is the pin which the potentiometer is attached
const int ledCount = 5: 5 is the number of LEDs in the bar graph or LEDs
int ledPins[] = {5, 7, 10, 11, 12}: the array of pin numbers of Arduino to which LEDs are attached
for (int thisLed = 0; thisLed < ledCount; thisLed++): loop over the pin array
{ pinMode(ledPins[thisLed], OUTPUT); }: set pin array to output.
int sensorReading = analogRead(analogPin): read the potentiometer.
This will be the result after uploading the code and rotating the potentiometer :
LED Bar Graph Progress Test : Transistor
We just want to touch the topic as it itself too big. LM3914 used as LED Bar Graph IC. It is actually the miniature of the big circuit. It is cheap and easy to setup :
LM3915 and the LM3916 are two varients of LM3914. You can read this kind of guide for using all components. Essentially using components needs more grasp on theoritical part of electronics.
As conclusion, we can use Arduino for bar graph display for complex projects while for easy electronic projects, we can use either the basic components or LM3914/LM3915/LM3916 IC.
Tagged With led bar graph code , arduino potentiometer vu display , arduino temperaturanzeige LED bargraph , https://thecustomizewindows com/2019/02/led-bar-graph-progress-test-arduino-transistors/ , Lm3914 индикатор уровня сигнала схема , Lm3915n Arduino bar diagram , schémas testeur de led , индикатор заряда акб 4 2в схема