Programming: views : 1797

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

Airtel cheating ther customers by incomplete description of recharge pack of Big companies like Airtel, also cheating their customers by providing incomplete or confusing description of their recharge plans
Big companies like Airtel, also cheating their customers by providing incomplete or confusing description of their recharge plans
साहस और धैर्य का प्रतिक कारगिल विजय दिवस  of साहस और धैर्य का प्रतिक कारगिल विजय दिवस
साहस और धैर्य का प्रतिक कारगिल विजय दिवस
Vaisakhi  of Vaisakhi
Vaisakhi
3 मार्च - विश्व वन्यजीव दिवस of 3 मार्च - विश्व वन्यजीव दिवस
3 मार्च - विश्व वन्यजीव दिवस
1 मार्च- विश्व प्रशंसा दिवस of 1 मार्च- विश्व प्रशंसा दिवस
1 मार्च- विश्व प्रशंसा दिवस
1 मार्च- विश्व नागरिक सुरक्षा दिवस of 1 मार्च- विश्व नागरिक सुरक्षा दिवस
1 मार्च- विश्व नागरिक सुरक्षा दिवस
1 मार्च - शून्य भेदभाव दिवस of 1 march शून्य भेदभाव दिवस
1 march शून्य भेदभाव दिवस
करती रही of पूरा नही बस थोड़ा सा ही समझा होता ....
पूरा नही बस थोड़ा सा ही समझा होता ....
वैलेंटाइन of वैलेंटाइन डे मनाने के पीछे एक रोचक तथ्य व 7 से 14 तक वैलेंटाइन सेलिब्रेट करने की सूची
वैलेंटाइन डे मनाने के पीछे एक रोचक तथ्य व 7 से 14 तक वैलेंटाइन सेलिब्रेट करने की सूची
National Test Agency of UGC NET December 2023 results and download its subject wise cut-off
UGC NET December 2023 results and download its subject wise cut-off
परीक्षा पे चर्चा  of परीक्षा पे चर्चा युवाओं के लिए तनाव मुक्त माहौल बनाने के लिए प्रधान मंत्री नरेंद्र मोदी के नेतृत्व में बड़े आंदोलन - 'एग्जाम वॉरियर्स' का हिस्सा है।
परीक्षा पे चर्चा युवाओं के लिए तनाव मुक्त माहौल बनाने के लिए प्रधान मंत्री नरेंद्र मोदी के नेतृत्व में बड़े आंदोलन - 'एग्जाम वॉरियर्स' का हिस्सा है।

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