0% found this document useful (0 votes)
66 views2 pages

New Program Code for Obstacle Detection

The document contains program code that was forwarded from one person to another. The code is for an obstacle detection program using infrared sensors connected to a microcontroller. It initializes an LCD display, then continuously checks the infrared sensors and displays the appropriate message on the LCD like "Obstacle Detected" if a sensor is triggered, or "Not detected" if none are. The code defines the LCD pins, infrared sensor pins, and includes functions for initializing the LCD, sending commands and data to it, displaying strings, and delaying.

Uploaded by

Meet Patel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views2 pages

New Program Code for Obstacle Detection

The document contains program code that was forwarded from one person to another. The code is for an obstacle detection program using infrared sensors connected to a microcontroller. It initializes an LCD display, then continuously checks the infrared sensors and displays the appropriate message on the LCD like "Obstacle Detected" if a sensor is triggered, or "Not detected" if none are. The code defines the LCD pins, infrared sensor pins, and includes functions for initializing the LCD, sending commands and data to it, displaying strings, and delaying.

Uploaded by

Meet Patel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Fwd: new program code

1 message

Harshil Patel <harshil.160410117034@[Link]> Fri 12 Apr, 2019 at 10:09 AM


To: meet.160410117043@[Link]

---------- Forwarded message ---------


From: harshil patel <harshil.160410117035@[Link]>
Date: Fri, Apr 12, 2019, 9:58 AM
Subject: Fwd: new program code
To: <harshil.160410117034@[Link]>

---------- Forwarded message ---------


From: Kishan Kansara <kishankansara.160410117021@[Link]>
Date: Wed, 10 Oct 2018, 12:26 am
Subject: new program code
To: <harshil.160410117035@[Link]>

jo bhai program mate try kri chhe.. aa program 99.99% chali jse. #include<reg51.h>
#define lcd P2
 
sbit IR1=P3^1;
sbit IR2=P3^2;
sbit IR3=P3^3;
sbit IR4=P3^4; 
sbit rs=P3^5; 
sbit rw=P3^6; 
sbit en=P3^7;
 
void lcd_init();
void cmd(unsigned char);
void dat(unsigned char);
void delay();
void lcd_string(char *s); 
void main()
{
    lcd_init();
    lcd_string("  Created by Harshil   ");
    while(1) {
        if(IR1 == 0)
{
            cmd(0xc0);
            lcd_string("Obstacle Detected");
            delay();
    }
else if(IR2 == 0)
{
    cmd(0xc0);
lcd_string("obstacle Detected");
delay();
}
else if(IR3 == 0)
{
    cmd(0xc0);
lcd_string("obstacle Detected");
delay();
}
else if(IR4 == 0)
{
    cmd(0xc0);
lcd_string("obstacle Detected");
delay();
}
else 
{
            cmd(0xc0);
            lcd_string("  Not detected ");
    }
  }
}
 
void lcd_init()
{
    cmd(0x38);
    cmd(0x0e);
    cmd(0x06);
    cmd(0x01);
    cmd(0x80);
}
 
void cmd(unsigned char a)
{
    lcd=a;
    rs=0;
    rw=0;
    en=1;
    delay();
    en=0;
}
 
void dat(unsigned char b)
{
    lcd=b;
    rs=1;
    rw=0;
    en=1;
    delay();
    en=0;
}
 
void lcd_string(char *s)
{
    while(*s) 
{
       dat(*s++);
     }
}
 
void delay()
{
    unsigned int i;
    for(i=0;i<20000;i++);
}

You might also like