Arduino Compatible 15 Bar-Segments Voltmeter ( Range 0-5V)

I am here with New Project>>> 15 Segments Voltmeter, this project is Arduino compatible, The project reads 0-5V DC on analog input  A1 of Arduino and drives 15 segments of 5MM LED’s mounted linearly , measuring range of the circuit is 0-5V DC, I have used potentiometer as 0-5V power source for testing purpose, remove potentiometer and apply 0-5V dc on analog pin A1 of Arduino and see the magic. Operating voltage 5V DC. Each LED indicates 0.34V. Gerber file is available on request. A LED bar graph can be defined as a visual representation of information received on analog input of Arduino.

 


Arduino Pins

LED 1-15>> DO, D1, D2, D3, D4, D5, D7, D8, D9, D10, D11, D12, D13, A0

Potentiometer >> Analog Pin A1


Arduino Code


/*
* 15 LED Bargraph Volt Meter
*visit https//www.twovolt.com for code, schematic, PCB layout

*/

// these constants won’t change:
const int analogPin = A1; // the pin that the potentiometer is attached to
const int ledCount = 15; // the number of LEDs in the bar graph

int ledPins[] = {
0,1,2,3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, A0
}; // an array of pin numbers to which LEDs are attached

void setup() {
// loop over the pin array and set them all to output:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
}

void loop() {
// read the potentiometer:
int sensorReading = analogRead(analogPin);
// map the result to a range from 0 to the number of LEDs:
int ledLevel = map(sensorReading, 0, 1023, 0, ledCount);

// loop over the LED array:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
// if the array element’s index is less than ledLevel,
// turn the pin for this element on:
if (thisLed < ledLevel) {
digitalWrite(ledPins[thisLed], HIGH);
}
// turn off all pins higher than the ledLevel:
else {
digitalWrite(ledPins[thisLed], LOW);
}
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *