--> Project I - 5. Digital Voltmeter (5V) with 7-Segment Display Based on Arduino | basic arduino tutorial

Thursday, August 24, 2017

Project I - 5. Digital Voltmeter (5V) with 7-Segment Display Based on Arduino

| Thursday, August 24, 2017
Digital Voltmeter (Max : 5V) with 7-Segment Display


Analog input data from voltage to be measured is ADC data which will convert into Voltage data. The result of the voltage reading is shown on seven segment with 3 digits. Input voltage connected to pin A0 of Arduino. There is a hold button in the form of ON / OFF switch, if the switch is ON condition then the display on the seven segment does not change even though the input voltage is changed.

Hardware Requirement
  • Arduino Uno Board
  • Potentio Meter
  • 3 Digit of 7-Segment with Common Anode
  • 2 Push Button
  • Power supply +5 Volt
  • Jumper


7-Segment | Source

Block Diagram

  
Schematic




7-Segment CA Wiring | Source

Arduino - 7 Segment Wiring


Arduino - Components Wiring


Source Code/Sketch

word miliVolt;
byte seven_seg_digits[10][7] = { { 0,0,0,0,0,0,1 }, // = 0
{ 1,0,0,1,1,1,1 }, // = 1
{ 0,0,1,0,0,1,0 }, // = 2
{ 0,0,0,0,1,1,0 }, // = 3
{ 1,0,0,1,1,0,0 }, // = 4
{ 0,1,0,0,1,0,0 }, // = 5
{ 0,1,0,0,0,0,0 }, // = 6
{ 0,0,0,1,1,1,1 }, // = 7
{ 0,0,0,0,0,0,0 }, // = 8
{ 0,0,0,0,1,0,0 } // = 9
};
void setup(){
for(char i=2; i<13; i++){
pinMode(i,OUTPUT);
}
pinMode(13,INPUT);
digitalWrite(13,HIGH);
}
void loop(){
int adc=(analogRead(A0));
float vin = adc * (5.0 / 1023.0);
miliVolt = vin*100;
displaySeg();
if (digitalRead(13)==0){
byte hold=1;
do{
displaySeg();
if (digitalRead(13)==1){
hold=0;
}
}
while(hold);
}
}
void displaySeg(){
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
digitalWrite(12,HIGH);
digitalWrite(9,0);
sevenSegWrite(miliVolt/100);
delay(7);
digitalWrite(9,1);
digitalWrite(10,HIGH);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
sevenSegWrite((miliVolt%100)/10);
delay(7);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(12,LOW);
sevenSegWrite((miliVolt%100)%10);
delay(7);
}
void sevenSegWrite(byte segment) {
byte pin = 2;
for (byte segCount = 0; segCount < 7; ++segCount) {
digitalWrite(pin, seven_seg_digits[segment][segCount]);
++pin;
}
}

How it Works

1. Connect the Arduino with Peripherals needed.
2. Plug in the Power Source on the device.

3. Add some library if needed
4. Compile and upload the script program above to your arduino.
5. On the seven segment will display data value of A0 pin which connected to Vin



6. Turn the potentiometer to get different data value of Vin
7. If the hold button is pressed it will hold the display of 7-segment although you change the value
    data of Vin
6. Press the hold key again to return to normal view.

Video for Project I - 5. Digital Voltmeter (5V) with 7-Segment Display Based on Arduino




Required file

Related Posts

No comments:

Post a Comment