ronkpatell
Member level 5
hi jayMake sure it works with 6V. In the datasheet you sent it is mentioned that V range is 3.3V to 4.2V.
i am trying with this code plz check is is this correct or not .and i still using your ptotues file and i assume that that virtual terminal work as bluetooth module ..
- - - Updated - - -
hi jayMake sure it works with 6V. In the datasheet you sent it is mentioned that V range is 3.3V to 4.2V.
i am trying with this code plz check is is this correct or not .and i still using your ptotues file and i assume that that virtual terminal work as bluetooth module ..
#include<reg51.h>
//#define DATA P1 //DATA bus is named for Port 2 (8-bit)
void delay(int n); //universal Delay routine for your code; can be customised for your use.
void s_inst(void); //Send Instruction Function Select routine
void s_data(void); //Send Data Select routine
void s_latch(void); // Latch Data/Instruction on LCD Databus
sbit rs= P3^5;
sbit rw= P2^1;
sbit en= P3^4;
sbit rx= P3^1;
sbit tx= P3^0;
void lcdcmd(unsigned char value)
{
P1=value;
rs=0;
rw=0;
en=1;
//mdelay(1);
en=0;
}
void lcd_data(unsigned char value)
{
P1=value;
rs=1;
rw=0;
en=1;
//mdelay(1);
en=0;
}
void lcd_init()
{
lcdcmd(0x38);
//mdelay(250);
lcdcmd(0x0F);
//mdelay(250);
lcdcmd(0x01);
//mdelay(250);
lcdcmd(0x06);
lcdcmd(0x0C);
}
//mdelay(250);
void recieve() //for recive serial data
{
unsigned char value;
while(RI==0);
value=SBUF;
P1=value;
RI=0;
}
void transmit()//for trasmitt data
{
P2=P1-32;
SBUF=P2;
while(TI==0);
TI=0;
SBUF=P1;
while(TI==0);
TI=0;
}
void uart_init()
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
//EA = 1;
//ES = 1;
}
void main()
{
unsigned char i;
unsigned char mes1[10]="Trans mode";
unsigned char mes2[10]="Reciv mode";
uart_init();
lcd_init();
if(rx==1)
{ rx=1;
recieve();
for(i=0;i<=10;i++)
{
//
// DATA=mes2; //It will send y[0]='F' as = 0x45 on Port 2.
// s_latch();
SBUF=mes2;
lcd_data(mes2);
while(RI==1)
RI=1;
}
}
else if(tx==1)
{
tx=1;
transmit();
for(i=0;i<10;i++)
{
// DATA=mes1; //It will send y[0]='F' as = 0x45 on Port 2.
// s_latch();
SBUF=mes1;
lcd_data(mes1);
while(TI==0)
TI=0;
}
}
/* for(i=0;i<8;i++)
{
lcd_data(mes1);
} */
}
void delay(int n) //Universal delay routine
{
int a=0,s=0;
for(a=0;a<=n;a++)
for(s=0;s<=10;s++);
}
void s_inst(void) //Instruction select routine
{
rs=0;
}
void s_data(void) // Data select routine
{
rs=1;
}
/*void s_latch(void) // Latch routine
{
en=1;
delay(10);
en=0;
delay(10);
} */
// END of program