ADC (anlog to digital)

                          ANLOG TO DIGITAL 




PINSEL1 :  where it is used to change the pin state either input are output state 

ADCR : Adddres control register used to enable state of adc block 

ADDR: Addres data register



program code

#include<lpc21xx.h>

int main()
{
 int result;
 PINSEL1 |=(1<<24);   //pin configuration
 PINSEL1 &= ~(1<<25);
 ADCR=(1<<1) | (3<<8)| (1<<16) | (1<<21);              //adc configuration
 while(1)
 {
  while(!(ADDR & (1<<31))); //if addr bit 1 then
  result=ADDR & (0x3ff<<6); //read the result
  result=result>>6;   //then shift back
  lcd_num(result/3.3);  //if we divid result with 3.3 then we will get duty cycle
  delay(1000);
   }
}




Comments

Popular posts from this blog

READING VALUES FROM SENSOR AND THAT WRITING TO EEPROM

Smart Power management system in any management system

Locker Security Sytem Using Humun Detect Sensor and OTP Throuhgt Bluettoth