Introduction:
We are back again here with the latest Arduino Project, i.e DC Voltmeter using Arduino and Seven Segment Display. This time we will be interfacing Arduino with 7 segment display and MA7219 IC to measure voltage ranging from 0-50V with almost no error at all. This DC voltmeter is linear with voltage and shows linear characteristics from 0.01 Volt to 50 Volt. Voltage beyond 50 Volt isn’t measurable by it. The above figure shows the 0-50V DC Voltmeter using Arduino and Seven Segment Display.
The Arduino inbuilt 10 bit ADC, can be used for measuring the 0-50V. Popular MAX7219 display driver, connected with Arduino Uno is used for displaying the measured DC voltage.
You can learn more about 7 segment Display at Stopwatch using 4 Digit 7 Segment Display & Arduino
Parts & Components:
- Arduino UNO Board
- MA7219 IC
- Resistors – 27K & 1200K
- 1N4728 3.3 Volt Zener Diode
- 4 digits, common cathode Seven Segment Display
Design & Explanation:
The voltage divider circuit is used to divide voltage into two parts, out of which one is fed to the input analog terminal of Arduino. Internal reference voltage as Vref 1.1V of Arduino is selected for measurement.
The resistor R1and R2 forms the voltage divider which is connected to analog input pin A0 of Arduino.
1N4728 3.3 Volt Zener Diode, at the A0 pin, is used for high voltage protection for Arduino.
If Vin is 50V then
0-50V DC Voltmeter using Arduino and Seven Segement Display:
0-50V DC Voltmeter using Atemga328 and Seven Segement Display:
The same project can also be implemented using Atmega328 micro-controller. All you need to do is replace the Arduino Board with Atmega328 micro-controller, with addition of few more components as in the circuit diagram below.
Programming & Source Code:
Here is a code for 0-50V DC Voltmeter using Arduino. The programming is written in the Arduino language and the same program is applicable for both circuits. For the first circuit, you can directly upload the program. And for the 2nd circuit, you need to upload the program to ATmega328. This is done by replacing the ATmega328 microcontroller on Arduino Uno Board with a fresh ATmega328 micro-controller. Before uploading you need to upload bootloader, then the only program can be successfully uploaded.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
#include <LedControl.h> int analogPin1 = 0; int val = 0; // inputs: DIN pin, CLK pin, LOAD pin. number of chips LedControl mydisplay = LedControl(11, 9, 10, 1); void setup() { analogReference(INTERNAL); mydisplay.shutdown(0, false); // turns on display mydisplay.setIntensity(0, 15); // 15 = brightest mydisplay.setDigit(0, 0, 9, false); mydisplay.setDigit(0, 1, 8, false); mydisplay.setDigit(0, 2, 7, false); mydisplay.setDigit(0, 3, 6, false); mydisplay.setDigit(0, 4, 5, true); mydisplay.setDigit(0, 5, 4, false); mydisplay.setDigit(0, 6, 3, false); mydisplay.setDigit(0, 7, 2, false); } void loop() { val = analogRead(analogPin1); int converted = map(val, 0, 1023, 0,5000); converted = HexToBCD(converted); mydisplay.setDigit(0, 0, ((converted>>12)&0x0F), false); mydisplay.setDigit(0, 1, ((converted>>8)&0x0F), true); mydisplay.setDigit(0, 2, ((converted>>4)&0x0F), false); mydisplay.setDigit(0, 3, (converted&0x0F), false); delay(1000); } unsigned int HexToBCD(unsigned int number) { unsigned char i=0; unsigned int k = 0; while(number) { k = ( k ) | ((number%10) << i*4); number = number / 10; i++; } return(k); } |
There is a simple method to measure the voltage as well in case if you want to measure the voltage from 0-30V. You can simply use a Resistive Voltage Sensor with Arduino Board.