1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

help me in AVR ADC

Discussion in 'AVR' started by beginer electroner, Dec 4, 2006.

  1. beginer electroner

    beginer electroner New Member

    Joined:
    Aug 5, 2006
    Messages:
    17
    Likes:
    0
    I need a link on the adc working, and some basic application
     
  2. Sceadwian

    Sceadwian Banned

    Joined:
    Oct 27, 2006
    Messages:
    14,047
    Likes:
    141
    Location:
    Rochester, US
  3. Mindaugasu

    Mindaugasu New Member

    Joined:
    Apr 26, 2005
    Messages:
    10
    Likes:
    0
    If you like WinAVR compiler tools you can use AVRLIB library. Then code looks really simple:
    Code (text):

    //----- Include Files ---------------------------------------------------------
    #include <avr/io.h>     // include I/O definitions (port names, pin names, etc)
    #include <avr/signal.h> // include "signal" names (interrupt names)
    #include <avr/interrupt.h>  // include interrupt support
    #include <avr/iom8.h>
    #include <avr/delay.h>
    #include "global.h"     // include our global settings
    //#include "uart.h"     // include uart function library
    #include "rprintf.h"    // include printf function library
    #include "a2d.h"        // include A/D converter function library
    #include "timer.h"      // include timer function library (timing, PWM, etc)
    #include "lcd.h"

    //----- Begin Code ------------------------------------------------------------
    int main(void)
    {
        u08 a=0;
        u08 Pressure;

        a2dInit();
       
        // initialize LCD
        lcdInit();
        // direct printf output to LCD
        rprintfInit(lcdDataWrite);

        // print message on LCD
        rprintf("Welcome");

        DDRC = 0x00;
        PORTC = 0x00;
    lcdClear();
        // display a bargraph of the analog voltages on a2d channels 0,1
        while(1)
        {
       
            lcdGotoXY(0,0);
            lcdProgressBar(a2dConvert8bit(0), 255, 20);
            lcdGotoXY(0,1);
            Pressure=(int)((((a2dConvert8bit(0)+0.3)/255)-0.04)/0.009);
            rprintf("Pressure:%d  kPa", Pressure);
        }

        return 0;
    }

     
    Full ready to compile project files you can find here
    Reading Pressure sensor with Atmega8
     

Share This Page