Home Login Sign Up Blogs & Articles Jobs Mobiles & Tablets Online Calculators Engineering Projects List Groomix Enterprises Publish your topics Ask Question About Blogs & Articles Feedback

programming

views : 231

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.

Image : project demonstrating model for Digital Voltmeter for AVR microcontroller

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..... 

Posted By :
Mr. Unique

2016-09-09/06:21:11

Share this Page

Comments...

Please, Login to comment or reply

More :programming

programming
Arduino UNO tachometer coding with variable resistor and DC motor speed control

p

programming
Here is the code to interface 2 serial devices with AVR

p

programming
Software Uart for AVR microcontroller tested on 1200 baud rate

p

programming
ATMEL STUDIO-While loop conditioning issues

p

programming
ATMEL STUDIO-While loop is not working using interrupt incremented conditioning

p

programming
Copy and paste code for facebook share button in your websites
programming
How to program atmel 8051 family microcontroller? (step by step)
programming
Embedded program code in C language for Digital Voltmeter for AVR microcontroller
programming
Assemby program code for Automatic Door Opening System (8051 family microcontroller)
programming
Very simple and accurate Seven Segment Display program Code in Embedded C language

p

programming
Highway vehicle speed detector or checker Embedded C language code in MikroC AVR Framework also applicable for 8051 Microcontroller

p

programming
Assembly program for accurate 1 second delay function
programming
What is Embedded system programming?

Latest Updates

programming
Arduino UNO tachometer coding with variable resistor and DC motor speed control
views :167

p

programming
Here is the code to interface 2 serial devices with AVR
views :143

p

programming
Software Uart for AVR microcontroller tested on 1200 baud rate
views :723

p

programming
ATMEL STUDIO-While loop conditioning issues
views :181

p

programming
ATMEL STUDIO-While loop is not working using interrupt incremented conditioning
views :277

p

programming
Copy and paste code for facebook share button in your websites
views :284
programming
How to program atmel 8051 family microcontroller? (step by step)
views :289
programming
Embedded program code in C language for Digital Voltmeter for AVR microcontroller
views :231
programming
Assemby program code for Automatic Door Opening System (8051 family microcontroller)
views :170
programming
Very simple and accurate Seven Segment Display program Code in Embedded C language
views :179

p

programming
Highway vehicle speed detector or checker Embedded C language code in MikroC AVR Framework also applicable for 8051 Microcontroller
views :100

p

programming
Assembly program for accurate 1 second delay function
views :149
programming
What is Embedded system programming?
views :180

Reach Us From Google Map

DO MORE WITH US

PRODUCT CATEGORY