Increase your Embedded skills with our new online classes (from Just Rs750/-) for details click here

For all your embedded quires visit our new forum.embed4u.com

Archive

Posts Tagged ‘infra sensors’

IR Sensor based visitor counter

September 6th, 2011 Comments off

IR Sensor based visitor counter:

Description:
In this project we are used simple IR Sensors, IR transmitter led and IR Receiver Led using LM358 circuit.IR Led supply voltage is +5v the output of the IR in this particular circuit is normally LOW 0 volt, the obstacle will cross the IR LED output is High > 4 volt.In this project the output of the IR LED pin is connected to the 8051 micro controller port pin P1.0. In this project 2*16 LCD is use to display the counting numbers. The LCD circuit RS pin P3.6 and E/N pin is P3.7 and DATA Pin is connected to PORT 0. In this project port 2 LED is connected to display the counting numbers in the LED also..In this project is used for bottle counting in the bottling plant like coca-cola, Pepsi, in this project slightly modification to display in the 7segment display also..

C Code:

/*program for IR Sensor based VISITOR COUNTER */

#include<reg51.h>
#include<string.h>
#define LCD_clear() LCD_command(0x01) /* Clear LCD Display
#define LCD_orgin()LCD_command(0x02) /* set to orgin LCD 
#define LCD_row1() LCD_command(0x80) /* Begin at 1st line
#define LCD_row2()LCD_command(0xc0) /* Begin at 2nd line


sbit port10=P1^0;       //IR Sensor Input
sbit rs=P3^6;             //Lcd Register Select Pin
sbit en=P3^7;           //Lcd Enable Pin


static unsigned char counter;

void lcd_en()      //Funtion for LCD Enable
 {
   en=1;
   en=0;
}

void LCD_delay(unsigned char ms) //Function for create Time Delay
{
 unsigned int n,i;
for(n=0;n<ms;n++)
  {
   for(i=0;i<1536;i++);
  }
}

void LCD_command(unsinged char command) //LCD Command Pass Funtion
 {
  rs=0;
  P0=command;
  lcd_en();
  LCD_delay(1);
}
void LCD_init() //LCD intialization funtion
{
 LCD_command(0x38);
 LCD_command(0x06);
 LCD_command(0x0c);
 LCD_command(0x01);
}
void LCD_putc(unasigned char ascii)
 {
  rs=1;
  P0=ascii;
  lcd_en();
  LCD_delay(2);
}
void LCD_puts(unsigned char *lcd_string)
 {
  while(*lcd_string)
    {
     LCD_putc(*lcd_string++);
   }
}
void disp(unsinged char name1)
  {
    rs=1;
    P0=name1;
    lcd_en();
    lcd_delay(300);
 }
void main()
 {
   port10=0;   //make P1.0 as init=0, initially all port pins are high
   P2=0;         //make low for P2
  LCD_init(); //call LCD initialization function 
while(1)                  //Run forever always true
  {
    if(port10)    //check condition P2.0 is high P2.0==1
     {
       LCD_command(0x80); //LCD command for display first line
       LCD_puts("visit count="); //String display in the LCD
        {
           disp(((counter%10000)/1000)+48);
           disp(((counter%1000)/100)+48);
           disp(((counter%100)/10)+48);
           disp(((counter%10)/1)+48);
        }
   }
  P2=counter;    // 8 LED's conneted in PORT 2
 LCD_comman(0xc0) //LCD command for display 2nd line
 LCD_puts("www.embed4u.com");
}
}

IR_sensor_8051_projects_visitor_counter

LCD_interface_with_8051_circuit