Digital Voltmeter with 7 segment display

/*
Read me

Use all this information at your own risk, i hold no responsibility for any and all indirect or dicrect damage to your arduino, hardware and software of your pc, any electronic devices if you choose to use this information.

This meter only can measure up to 5V

This meter cannot measure negative voltage and make sure you connect the probes to the battery in the correct way (red probe(A0) to the positive side of the battery and black probe(GND) to the negative side of the battery)

*/
int a=13;
int b=12;
int c=11;
int d=10;
int e=9;
int f=8;
int g=7;
int deci = 3;
int gnd1=6;
int gnd2=5;
int gnd3=4;
int inp=A0;

float Reading;
int OneDigit, TenDigit, HundredDigit;

void mask(int num, int aa, int bb, int cc, int dd, int ee, int ff, int gg) 
{ 
switch (num) 
{ 
case 0 :
digitalWrite(aa, HIGH);
digitalWrite(bb, HIGH);
digitalWrite(cc, HIGH);
digitalWrite(dd, HIGH);
digitalWrite(ee, HIGH);
digitalWrite(ff, HIGH);
digitalWrite(gg, LOW);
break;

case 1 : 
digitalWrite(aa, LOW);
digitalWrite(bb, HIGH);
digitalWrite(cc, HIGH);
digitalWrite(dd, LOW);
digitalWrite(ee, LOW);
digitalWrite(ff, LOW);
digitalWrite(gg, LOW);
break;

case 2 : 
digitalWrite(aa, HIGH);
digitalWrite(bb, HIGH);
digitalWrite(cc, LOW);
digitalWrite(dd, HIGH);
digitalWrite(ee, HIGH);
digitalWrite(ff, LOW);
digitalWrite(gg, HIGH);
break;

case 3 : 
digitalWrite(aa, HIGH);
digitalWrite(bb, HIGH);
digitalWrite(cc, HIGH);
digitalWrite(dd, HIGH);
digitalWrite(ee, LOW);
digitalWrite(ff, LOW);
digitalWrite(gg, HIGH);
break;

case 4 : 
digitalWrite(aa, LOW);
digitalWrite(bb, HIGH);
digitalWrite(cc, HIGH);
digitalWrite(dd, LOW);
digitalWrite(ee, LOW);
digitalWrite(ff, HIGH);
digitalWrite(gg, HIGH);
break;

case 5 : 
digitalWrite(aa, HIGH);
digitalWrite(bb, LOW);
digitalWrite(cc, HIGH);
digitalWrite(dd, HIGH);
digitalWrite(ee, LOW);
digitalWrite(ff, HIGH);
digitalWrite(gg, HIGH);
break;

case 6 : 
digitalWrite(aa, HIGH);
digitalWrite(bb, LOW);
digitalWrite(cc, HIGH);
digitalWrite(dd, HIGH);
digitalWrite(ee, HIGH);
digitalWrite(ff, HIGH);
digitalWrite(gg, HIGH);
break;

case 7 : 
digitalWrite(aa, HIGH);
digitalWrite(bb, HIGH);
digitalWrite(cc, HIGH);
digitalWrite(dd, LOW);
digitalWrite(ee, LOW);
digitalWrite(ff, LOW);
digitalWrite(gg, LOW);
break;

case 8 : 
digitalWrite(aa, HIGH);
digitalWrite(bb, HIGH);
digitalWrite(cc, HIGH);
digitalWrite(dd, HIGH);
digitalWrite(ee, HIGH);
digitalWrite(ff, HIGH);
digitalWrite(gg, HIGH);
break;

case 9 : 
digitalWrite(aa, HIGH);
digitalWrite(bb, HIGH);
digitalWrite(cc, HIGH);
digitalWrite(dd, HIGH);
digitalWrite(ee, LOW);
digitalWrite(ff, HIGH);
digitalWrite(gg, HIGH);
break;

}
}

void setup()
{
  pinMode(a,OUTPUT);
  pinMode(b,OUTPUT);
  pinMode(c,OUTPUT);
  pinMode(d,OUTPUT);
  pinMode(e,OUTPUT);
  pinMode(f,OUTPUT);
  pinMode(g,OUTPUT);
  pinMode(deci,OUTPUT); 
  pinMode(gnd1,OUTPUT);
  pinMode(gnd2, OUTPUT);
  pinMode(gnd3, OUTPUT);
  pinMode(inp, INPUT); 
  digitalWrite(deci, HIGH);
}
  
 void loop ()
 {
   float TempOneDigit;
   int i;
Reading = (analogRead(inp)*5.00/1023.00);
HundredDigit = int(Reading) % 10;
TenDigit = int ((Reading-HundredDigit )*10) % 10;
TempOneDigit = int(Reading * 10);
OneDigit = int ((Reading - float(TempOneDigit/10))* 100) %10;

for (i=0 ; i<20 ; i++) {
 mask (OneDigit, a, b, c, d, e, f, g);
 digitalWrite(gnd3,LOW);
 digitalWrite(gnd2, HIGH);
 digitalWrite(gnd1, HIGH);
 delay(5);
 mask (TenDigit, a, b, c, d, e, f ,g);
 digitalWrite(gnd3,HIGH);
 digitalWrite(gnd2, LOW);
 digitalWrite(gnd1, HIGH);
 delay(5);
 mask (HundredDigit, a, b, c, d, e, f ,g);
 digitalWrite(gnd3,HIGH);
 digitalWrite(gnd2, HIGH);
 digitalWrite(gnd1, LOW);
 delay(5);

}

 }

1 Like

Is there a question here? If, move to Exhibits?
Are those supposed to be common cathode current limit resistor?
Hope it's like 100 ohm so what ever poor pin is sinking the current from 7 LEDs is not seeing more than 40mA absolute max.

Need some words of intention.

this is not a question, i just wanna share my work, and let you guys to correct my mistake, i'm new to arduino and new to electronic, i have no idea on what "common cathode current limit resistor" is, can you please elaborate more? if you mean the resistor i connected to the 7 segment display, the resistor i just simply put any value to just limit the current to prevent the 7 segment display from damage, i dont know how to choose a suitable value.

You should use a voltage divider on this so you don't fry your Arduino in higher than 5 volts.

I would use current limiting resistors on the segment lines, not the digit lines, and add switching transistors
for the digit lines so they can carry enough current - an Arduino pin can drive one segment without
overload, but probably not 7, unless they are small low current displays.

Elfnet:
You should use a voltage divider on this so you don't fry your Arduino in higher than 5 volts.

You should perhaps muse on the wisdom of commenting on matters which were forgotten four and a half years ago! :roll_eyes:

I need code for 4 digit voltmeter. What changes in code to be done
Also if I want to change measuring voltage range to 0-100mV instead 0-5V, what change in code required

Perhaps you better start by explaining whether you are using the actual circuit and code discussed here, or something else entirely?

Paul__B:
You should perhaps muse on the wisdom of commenting on matters which were forgotten four and a half years ago! :roll_eyes:

Nothing wrong with commenting on old threads. It's very possible that someone pulls the OP's pic up and builds it, and if Elfnet's and MarkT's comments make the OP's product better, then that's a good thing.

(That ngbk became a Guest meantime, of course means she might not see the new posts, but that doesn't make the new posts any less useful to the community at large.)

ardy_guy:
That ngbk became a Guest meantime, of course means she might not see the new posts,

Interesting! What forensics did you use to determine that ngbk1993 "became a Guest meantime"? I would like to know how to trace such things.

Paul__B:
Interesting! What forensics did you use to determine that ngbk1993 "became a Guest meantime"? I would like to know how to trace such things.

They were a member when they posted, as only members can post. Right under their name is the word "Guest", and their name is no longer a clickable link. Thus the conclusion (by Boolean logic) is that the became a guest between the time of the OP, and now.

EDIT: Make that Aristotelian logic.

ChrisTenone:
They were a member when they posted, as only members can post.

What about in 2014, which was "the time of the OP"?

Right. If a post is made by someone who used to be a mamber, but they are not a mamber now, they are labeled "guest". It's merely forum nomenclature, it dowsn't indicate that they have visited since.

ChrisTenone:
Right. If a post is made by someone who used to be a mamber, but they are not a mamber now, they are labeled "guest". It's merely forum nomenclature, it dowsn't indicate that they have visited since.

Mamber or
?

Not sure how - or why - someone becomes a non-member. Seems to be something that happened some years ago with a different forum software (which may even have been better behaved) and can no longer happen.

That black mamba, or this one?

ChrisTenone:
That black mamba, or this one?

an image of a Black Member popped in my mind, but i thought i'd better not post it here... :stuck_out_tongue:

Paul__B:
Not sure how - or why - someone becomes a non-member. Seems to be something that happened some years ago with a different forum software (which may even have been better behaved) and can no longer happen.

I think it was the result of the forum cleanup when there were all kinds of forum issues a few years ago. Removing inactive members with low post count was one of the actions that were taken. This was done before we ended up with the new login system.

Another reason can be that the member is banned.

Paul__B:
Mamber or
?

The one that you stay away from as far as possible. Black mambas are extremely agressive, especially when they want to mate. Most snakes will move away from you and you will only be in trouble if you accidentally tramp on one; a black mamba will chase you. And they are bloody fast; you will not outrun it.

I am trying to build LED 3 digit voltmeter with 7219 and Arduino UNO

I try 2 code, fisrt one is PICMICROLAB's, the second one is "How to Electronics 50V DC voltmeter.
These are 4 digit voltmeter and okay for me at the beginning.

But both have some problems, first one problem is:

The digit0 display only G segment between 9-0 . It does not display "0" , jump to 1.
You can also see for the last digit, what I mean at Arduino 4 Digit 7 Segment LED Voltmeter MAX7219 - YouTube

The second one is displays some random numbers, digit3 and digit2 values are changing at the same time with different values.

Is there anyone trying thiese codes or running codes
If so, do you share.

Not sure what you mean, but an Uno has a 10-bit A/D which means 2^10= 1024 steps.
So if you design your voltmeter (resistor divider and code) right, then you only have 1024 display steps.

A "9.999" display would need 10000 steps. That's 10 times more than what you have.

A "50 volt" voltmeter would only have 1024/50= ~20 steps per volt.
ONE decimal place (10 steps per volt) would be ok, two or more decimal places would be impossible.
Leo..

glamo:
I am trying to build LED 3 digit voltmeter with 7219 and Arduino UNO

But - just - why? :roll_eyes: