Wednesday, 7 January 2015

Practical 13 ADC with 8051 micro controller

ADC



















Program

#include<REG51.H>
#include<string.h>


sbit rs=P2^5;
sbit en=P2^6;


sbit rd=P2^1;
sbit wr=P2^2;
sbit intr=P2^3;

void delay(unsigned int a)
{
int i,j;
for(i=0;i<a;i++)
{
for(j=0;j<1275;j++)
{
}
}
}


void lcd_write_cmd(unsigned char item)
{
P3 = item;
rs= 0;
en=1;
delay(1);
en=0;
return;


}

void lcd_write_data(unsigned char item)
{
P3 = item;
rs= 1;
en=1;
delay(1);
en=0;

}
void lcd_string(unsigned char *str)     //Function to send string
{
    int i=0;
  while(str[i]!='\0')
{
    lcd_write_data(str[i]);
    i++;
    delay(1);
}
return;
}


void lcd_init(void)
{
delay(1);
lcd_write_cmd(0x38); /* send cmd */
lcd_write_cmd(0x0E); /* send cmd for display on, courser off */
}

unsigned char adc()
{
unsigned char temp;
wr=1;
delay(1);
wr=0;
while(intr==0);
rd=0;
temp=P1;
delay(1);
rd=1;
return temp;
}

void convndisplay(unsigned char in)
{

  char x=0,i=2;
  while(1)
  {
    x=(in%10)+0x30;
    in=in/10;
lcd_write_cmd(0x87+i);
lcd_write_data(x);
i--;
if(in==0){break;}
   }
   delay(200);
   lcd_write_cmd(0x87);
}

void main()
{
   unsigned char temp;
P2=0x08;
P1=0xff;
P3=0x00;
intr=1;
wr=0;
rd=0;
rs=0;
en=0;
  lcd_init();
  lcd_write_cmd(0x80);
  lcd_string("Vikas");
lcd_write_cmd(0x01);
lcd_string("TEMP = ");
  while(1)
  {
  delay(20);
  temp=adc();
  convndisplay(temp);
  }
  while(1);
}



Wednesday, 3 December 2014

Practical 3

Switch + Led

In This Practical i will show, How to manage input and Output with the help of microcontroller.

Sunday, 12 October 2014

Practical 2

Pin addressing using 8051 microcontroller


In this program we will learn how to male pin addressing using sbit in keil. corcuit diagram and program is given below.

Monday, 25 August 2014

Practical 1

Now in this practical we will access whole port of 8051 micro controller.




Circuit Diagram :

































Code  :

#include<reg51.h>

void delay()
{
int x,y;
for(x=0;x<500;x++)
{
for(y=0;y<500;y++);
}


}


void main()
{
P0=0x00;

while(1)
{
P0=0x00;
delay();
P0=0xff;
delay();
}

}

8051 Practical List



            1.    PORT Blink
            2.       LED Blink
            3.      Switch + LED
            4.      7Seg display
            5.       7Seg + Switch
            6.       LCD
            7.       PIR sensor
            8.       IR Sensor
            9.       PIR + IR + LCD
          10.   Keypad + LCD
          11.   Keypad + 7seg
          12.   Stepper  Motor
          13.   ADC
          14.   Serial Communication
          15.   LCD + Serial