interfacing of ultrasonic sensor to 89c51 with keil codes
#1

yesabout interfacing of ultrasonic sensor to 89c51 with keil codes in to the right box for getting free material
Reply
#2

interfacing of ultrasonic sensor to 89c51 with keil codes

#include<REGX51.h>

#include<intrins.h>
// for using _nop_() function
#define port P2
#define dataport P0
sfr16 DPTR =0x82;
sbit trig=P3^5;
sbit rs=port^0;
sbit rw=port^1;
sbit e=port^2;


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

void lcd_cmd(unsigned char item) // Function to send command to LCD
{
dataport = item;
rs= 0;
rw=0;
e=1;
delay(1);
e=0;
return;
}

void lcd_data(unsigned char item) // Function to send data to LCD
{
dataport = item;
rs= 1;
rw=0;
e=1;
delay(1);
e=0;
return;
}

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

void send_pulse(void) //to generate 10 microseconds delay
{
TH0=0x00;TL0=0x00;
trig=1;
_nop_();_nop_();_nop_();_nop_();_nop_();
_nop_();_nop_();_nop_();_nop_();_nop_();
trig=0;

}

unsigned int get_range(void)
{
int range=0;
int s;
send_pulse();
delay(40);// generate a delay of 40 Milli seconds=40000 micro
DPH=TH0;DPL=TL0;
TH0=0xFF;TL0=0xFF;
lcd_cmd(0x81);
delay(2);
lcd_data_string("output:");
lcd_cmd(0x8a);
if(DPTR<35000)
{//actually you need to use 38000 but the sensor may not work at higher levels
range=DPTR/59;
s=range/100;
range=range%100;
if(s!=0)
{
lcd_data(s+48);
}
else
{
lcd_cmd(0x06);
s=range/10;
range=range%10;
lcd_data(s+48);
lcd_data(range+48);
lcd_data(' ');
}
}
else
{
range=0; // indicates that there is no obstacle in front of the sensor
lcd_cmd(0x06);
lcd_data(0);
}
return range;
}

void main()
{
lcd_cmd(0x38);
lcd_cmd(0x0c);
delay(2);
lcd_cmd(0x01);
delay(2);
lcd_cmd(0x81);
delay(2);
lcd_data_string("start");
delay(20);
TMOD=0x09;//timer0 in 16 bit mode with gate enable
TR0=1;//timer run enabled
TH0=0x00;TL0=0x00;

P3=0x04;//setting pin P3.2


while(1)
{ get_range();
delay(2);
}
}
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: ultrasonic sensor interfacing with 89c52 circuit diagram pdf, ultrasonic c program keil, keil codes for line follwer, ultrasonic sensor interfacing with lpc2148 codechnology, temperature sensor lcd display keil uvision, ultrasonic sensor interfacing with atmega16 pdf, trig the,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  development of road light gateway with sensor network ppt 2 1,820 15-04-2018, 05:30 PM
Last Post: Guest
  techmax ebooks activation codes by subjects 2 1,454 15-11-2017, 10:03 AM
Last Post: Guest
  ldr sensor interfacing with lpc2148 4 1,839 22-09-2017, 11:40 AM
Last Post: Guest
  vodacom free airtime cheat codes 4 1,555 29-05-2017, 09:36 AM
Last Post: jaseela123d
  MATLAB codes needed for powerline communication 1 8,081 12-04-2017, 05:00 PM
Last Post: jaseela123d
  vodacom cheat codes unlimited data bundles 3 1,462 01-03-2017, 04:35 PM
Last Post: jaseela123d
Big Grin south african mtn airtime cheating hacking codes 2 1,082 09-09-2016, 02:55 PM
Last Post: bradley
Smile free cell c airtime vouchers free cell c airtime cheat codes free cell c airtime hack 2 1,857 21-07-2016, 03:21 PM
Last Post: dhanabhagya
  mtn airtime advance south africa codes 3 1,361 19-07-2016, 02:37 PM
Last Post: visalakshik
  unlimited cellc airtime tricks codes free 2 773 15-07-2016, 03:01 PM
Last Post: anasek

Forum Jump: