Programming: views : 1798

Embedded program code in C language for Digital Voltmeter for AVR microcontroller

Digital voltmeter is very useful for accurate measurement of voltage. It has very small least count, depending on analog to digital convert (ADC) and least count of display. Here, seven segment display is used, however, any type of display can be used.
Embedded program code in C language for Digital Voltmeter for AVR microcontroller
Embedded-program-code-in-C-language-for-Digital-Voltmeter-for-AVR-microcontroller2016-08-06_10_32_05


Embedded program code in C language

 Note : Pin connection should be in according to code below. if any confusion then ask in comments below...

 

//PROJECT NAME:digital voltmeter
//PB 0=BUZZER
//PB1=LDR SENSOR
//PC2=SMOKE SENSOR
//PC0=ANALOG INPUT(TEMPERATURE SENSOR)
//PC3,PC4,PC5=E,RW,RS( 16X2 LCD)
//PD=DATA(16X2 LCD)
#define F_CPU 12000000UL //Setting F_CPU to the frequency of the microcontroller
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
/*ADC Conversion Complete Interrupt Service Routine ()*/
ISR(ADC_vect);
////////////////////// ////////////////////////// ////////////////////////// ////
void InitADC()
{
    DDRC = 0b00111000;                    // Configure PortA as input
    ADMUX=(1<<REFS 0);                // For Aref=AVcc;
    ADCSRA=(1<<ADE N)|(7<<ADPS0);
}
int ReadADC(int ch)
{
   ch=ch&0b00000111 ;               //Select ADC Channel ch must be 0-7
   ADMUX|=ch;
   ADCSRA|=(1<<AD SC);               //Start Single conversion
   while(!(ADCSRA & (1<<ADIF))); &n bsp;  //Wait for conversion to complete
   ADCSRA|=(1<<AD IF);                   //Clear ADIF by writing one to it
   return(ADC);
}
////////////////////// ////////////////////////// //////////////////////////
#define SELECT_7SEG_DDR DDRC
#define SELECT_7SEG_PORT PORTC
#define DISP1 PC5
#define DISP2 PC4
#define DATA_DDR DDRD
#define DATA_PORT PORTD
char DECODE_7SEG[11] = {0x77,0x14,0xb3,0xb6,0xd4, 0xe6,0xe7,0x34,0xf7,0xf6,0 x08};
void DISPLAY_7SEG(int a)
{
SELECT_7SEG_DDR |= (1 << DISP1) | (1 << DISP2);
DATA_DDR = 0xff;   // port assigned as output
char char1;
char1 = a%10;
a = a/10;
char1 = DECODE_7SEG[char1];
SELECT_7SEG_PORT &= ~((1 << DISP1) | (1 << DISP2));
DATA_PORT = char1;
SELECT_7SEG_PORT |= (1 << DISP1);
char1 = a%10;
a = a/10;
char1 = DECODE_7SEG[char1];
SELECT_7SEG_PORT &= ~((1 << DISP1) | (1 << DISP2));
DATA_PORT = char1;
SELECT_7SEG_PORT |= (1 << DISP2);
}

int main()
{
DDRC &=~(1<<PC0);&nbs p;   //PC2=LOW INPUT FOR TEMPERATURE
DDRB|=0xFF;   ;          //Output for relays
PORTB = 0x00;        //INITIAL VALUE
InitADC();
unsigned int count;
while(1 )
    {
    int temp_int=ReadADC(0);     
    DISPLAY_7SEG(temp_in t/10);
 & nbsp;  for(count = 0; count<1000; count++)
        {
        DISPLAY_7SEG(temp_in t/10);
        }
     }
return 0;
}

For any query, feel free to comment below..... 



Share this page with your friends
share via Whatsapp

Posted By :
Mahesh Nigam
(Scientist)
2019-09-27 17:13
See Author's other Published Topics

Happy Teacher’s Day of Dear Madam, Thank You For continually Inspiring me to do my best..
Dear Madam, Thank You For continually Inspiring me to do my best..
Happy teachers day of Thank you for teaching me how to read and write, for guiding me to distinguish between what is wrong and what is right. For allowing me to dream and soar as a kite, thank you for being my...
Thank you for teaching me how to read and write, for guiding me to distinguish between what is wrong and what is right. For allowing me to dream and soar as a kite, thank you for being my...
A good teacher is like a candle of A good teacher is like a candle – it consumes itself to light the way for others..
A good teacher is like a candle – it consumes itself to light the way for others..
The teacher who is indeed wise of The teacher who is indeed wise does not bid you to enter the house of his wisdom but rather leads you..
The teacher who is indeed wise does not bid you to enter the house of his wisdom but rather leads you..
Happy World Teachers' Day! of I am proud to let you know that you have been the great teacher in my life! Happy World Teachers' Day!...
I am proud to let you know that you have been the great teacher in my life! Happy World Teachers' Day!...
Happy teachers day of Without you, we would have been lost. Thank you teacher for guiding us, inspiring us And making us..
Without you, we would have been lost. Thank you teacher for guiding us, inspiring us And making us..
Wishing you a Teacher's Day of I was lucky to have a teacher as wonderful as you are. Wishing you a Teacher's Day that’s full of joyous...
I was lucky to have a teacher as wonderful as you are. Wishing you a Teacher's Day that’s full of joyous...
 Happy Teacher's Day! of Teacher, you have always challenged me to work hard and get good grades. I will always remember you. Happy Teacher's Day!...
Teacher, you have always challenged me to work hard and get good grades. I will always remember you. Happy Teacher's Day!...
Happy Teacher's Day! of The best teachers teach from the heart, not from the book. Thank you for being a wonderful teacher. Happy Teacher's Day!..
The best teachers teach from the heart, not from the book. Thank you for being a wonderful teacher. Happy Teacher's Day!..
Happy Teacher’s Day of Happy Teacher’s Day! It has been an honor to get to learn so many...
Happy Teacher’s Day! It has been an honor to get to learn so many...
Wishing you joy and happiness of Wishing you joy and happiness, you are an amazing teacher, and you only..
Wishing you joy and happiness, you are an amazing teacher, and you only..

Peoples

Comments...

Prashant Sharma: Mahesh nigam ji Your artical is good . I want to make a digital volt.eter and amp Meter using seven segment . Can u help me to provide a program I m using 3 segment display which have 12 pins in center. Model = SUNR056CA3D032020 COMMON ANODE . MY WHATSAPP NO. IS 9412582901

Reply 18:29 2021-08-30

Mahesh Nigam(Scientist): Above article is only for volt meter and it is very old code. It was made by using three 7 segment display of 10pin. This will also compatible with 12pin three digit segment display with small change in pin connection. problem is that, this code is not for Current Meter. If you want to read both Voltage meter and current meter, we can provide it for you but it will cost you some amount. Contact me for more detail on +91-9125110098

Reply 15:52 2021-09-04

Write Your Comment

Related to Programming

Latest topics




More Categories
latest mobile phones ireps.gov.in irctc.co.in Working Principle Viral Discussion True Love quotes True Love Today is Celebrated For Tips for better life Tips and Hacks Technology News Teachers Day Quotes Study Materials Self Motivating Quotes Science Sad Lines (Sayeri) Romantic shayari quotes Robotics Reviews Results Questions_and_Answers Programming Problem Resolved PHP Codes PCB Design Online Works New Year Quotes Shayari Status My World My Responsibilities Motivational lines Mobile Issues Microcontrollers Lucknow Local News Latest Technology Iphone Homeopathy Historical place in India Heart Touching Love Quotes Health Good Night Quotes Good Morning Quotes GeM.gov.in GST portal Funny Lines (Sayeri) Friendship Quotes Food Recipes Exam Time Table Engineering Project Ideas Electronics Electronic and electrical project making ideas Electricals Educations Desh Bhakti Shayeri Criminal Love Cricket News Corona Updates Christmas Quotes Shayari Status CBSE Updates/Circulars Breaking News Breaking Heart Shayeri Break Up Lines (Sayeri) BirthDay Wishes Best kitchen Tips Best Valentine quotes Shayeri Beauty Hacks Basic Knowledges Attitude quotes shayari Attitude quotes Attitude quotes Assembly Election 2022
Go to top

Important Links

  • Contact Us
  • About Us
  • All copyright © 2020 are reserved by Groomix - designed by Groomix

    MORE

    Programming >
    latest mobile phones >
    ireps.gov.in >
    irctc.co.in >
    Working Principle >
    Viral Discussion >
    True Love quotes >
    True Love >
    Today is Celebrated For >
    Tips for better life >
    Tips and Hacks >
    Technology News >
    Teachers Day Quotes >
    Study Materials >
    Self Motivating Quotes >
    Science >
    Sad Lines (Sayeri) >
    Romantic shayari quotes >
    Robotics >
    Reviews >
    Results >
    Questions_and_Answers >
    Problem Resolved >
    PHP Codes >
    PCB Design >
    Online Works >
    New Year Quotes Shayari Status >
    My World My Responsibilities >
    Motivational lines >
    Mobile Issues >
    Microcontrollers >
    Lucknow Local News >
    Latest Technology >
    Iphone >
    Homeopathy >
    Historical place in India >
    Heart Touching Love Quotes >
    Health >
    Good Night Quotes >
    Good Morning Quotes >
    GeM.gov.in >
    GST portal >
    Funny Lines (Sayeri) >
    Friendship Quotes >
    Food Recipes >
    Exam Time Table >
    Engineering Project Ideas >
    Electronics >
    Electronic and electrical project making ideas >
    Electricals >
    Educations >
    Desh Bhakti Shayeri >
    Criminal Love >
    Cricket News >
    Corona Updates >
    Christmas Quotes Shayari Status >
    CBSE Updates/Circulars >
    Breaking News >
    Breaking Heart Shayeri >
    Break Up Lines (Sayeri) >
    BirthDay Wishes >
    Best kitchen Tips >
    Best Valentine quotes Shayeri >
    Beauty Hacks >
    Basic Knowledges >
    Attitude quotes shayari >
    Attitude quotes >
    Attitude quotes >
    Assembly Election 2022 >

    Peoples

    Latest Comments