hsuri
Newbie level 5
I am new to Microcontrollers..need urgent help with the code..
Follwing is the code to display a single message on the sound of a clap using 8051
---------- Post added at 12:03 ---------- Previous post was at 12:02 ----------
Urgent help required...plzz:-?
Follwing is the code to display a single message on the sound of a clap using 8051
Code:
#include<reg51.h>
#define port P1
#define dataport P2 //Data port for LCD
#define sec 1000
//CONTROL PINS
sbit rs = port^0;
sbit rw = port^1;
sbit e = port^2;
sbit sensor_input=P0^0;
void delay(unsigned int msec) //Time delay function
{
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(10);
}
return;
}
void main()
{
unsigned char str1[] ="HELLO";
unsigned char str2[] =" WORLD";
sensor_input=1;
sensor_input=0;
lcd_cmd(0x38);
lcd_cmd(0x0e);
lcd_cmd(0x01);
while(1)
{
if(sensor_input==1)
{
lcd_cmd(0x82);
lcd_data_string(str1);
lcd_cmd(0xc6);
lcd_data_string(str2);
delay(sec);
lcd_cmd(0x01);
delay(100);
}
}
}
---------- Post added at 12:03 ---------- Previous post was at 12:02 ----------
Urgent help required...plzz:-?