We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am using 8051 Microcontroller and connecting it with Bluetooth and LCD. I am able to send data from mobile to LCD Display and can also print pre-written lines in code on mobile Bluetooth Terminal and LCD Display. How can I write AT Commands in the code, so that I can access the GPIO Pins of Bluetooth ?
/* Port 2 rs, rw, en of LCD Port 1 LCD Output Port 3 Bluetooth */
#include<reg51.h> void Baud(); sbit rs = P2^5; sbit rw = P2^6; sbit en = P2^7; void lcdcmd(unsigned char ); void lcddata(unsigned char); void msdelay(unsigned char); void run(unsigned char *l); char String[10]="SCIENTECH"; void SerTx(unsigned char); void at_command_send(unsigned char *str); void enter(); int i;
unsigned char a; unsigned char var_tfr;
void EINT() interrupt 4 { a=SBUF; lcdcmd(0xcd); lcddata(a); // Put value of Serial Buffer at Port 1, which is LCD
RI=0; TI=0; }
void main() { Baud(); lcdcmd(0x38); // 2 lines and 5 x 7 matrix lcdcmd(0x01); // Clear Display lcdcmd(0x0E); // Display on, cursor blinking lcdcmd(0x06); // Increment Cursor lcdcmd(0x80);
run("BT - Interface : "); lcdcmd(0xc0); run("Data Receive: ");
at_command_send("AT+AB GPIOConfig 2 'O'"); enter(); msdelay(1); at_command_send("AT+AB GPIOWrite 2 1"); enter(); IE=0x90; while(1) { msdelay(1); } }
void at_command_send(unsigned char *str) { EA=0; while(*str!='\0') { TI=0; SBUF=(*str++); while(!TI); TI=0; } } void lcdcmd(unsigned char value) { P1 = value; rs=0; rw=0; en=1; msdelay(10); en=0; }
//void SerTx(unsigned char value1) //{ // SBUF=value1; // while(TI==0); // TI=0; // // RI=0; //}
void lcddata(unsigned char value) { P1 = value; rs=1; rw=0; en=1; msdelay(1); en=0;
}
void msdelay(unsigned char time) { unsigned int i,j; for(i=0; i<time; i++) { for (j=0; j<1275; j++); } }
void run(unsigned char *l) { while(*l) { var_tfr=*l++; P1= var_tfr; SBUF=var_tfr; rs=1; rw=0; en=1; msdelay(10); en=0; while(TI==0); TI=0; } }
void Baud() { TMOD=0x20; // Timer 1, Mode 2 SCON=0x50; // Mode 1 TH1=0xFD; // 9600 TR1=1; } void enter() {
SBUF=0x0a; while(TI==0); TI=0; RI=0; SBUF=0x0d; while(TI==0); TI=0; RI=0;