#include #include #include "lcd.h" #include "pwm.h" #include "i2c.h" #include "IRIN.h" unsigned char PuZh[]=" Pechin Science "; extern uint journey; extern uint money; extern uchar sudu; unsigned int b12; unsigned int c12; unsigned int b123; unsigned int c123; extern unsigned char pwm_left; unsigned char code ASCII[15] = {'0','1','2','3','4','5','6','7','8','9','.','-','M'}; void delayms(unsigned int ms) { unsigned char i=100,j; for(;ms;ms--) { while(--i) { j=10; while(--j); } } } void Uart_Init() //使用定时器1作为波特率发生器(STC89C52、STC89C51、AT89C51等均可) { TMOD = 0x20 | 0x01; SCON = 0x50; //设置串行方式 TH1 = 0xFD; //波特率9600 TL1 = TH1; PCON = 0x00; EA = 1; //总中断打开 ES = 1; //开串口中断 TR1 = 1; //启动定时器1 } void us_delay(uchar t) { while(t--); } void Send_Uart(uchar value) { ES=0; //关闭串口中断 TI=0; //清发送完毕中断请求标志位 SBUF=value; //发送 while(TI==0); //等待发送完毕 TI=0; //清发送完毕中断请求标志位 ES=1; //允许串口中断 } void ESP8266_Set(uchar *puf) // 数组指针*puf指向字符串数组 { while(*puf!='\0') //遇到空格跳出循环 { Send_Uart(*puf); //向WIFI模块发送控制指令。 us_delay(5); puf++; } } void main(void) { int i = 0; InitLcd1602(); IRIN_Init(); Uart_Init(); pwm_left=10; b12=At24c02Read(1); c12=At24c02Read(8); money = 120; money=At24c02Read(5); journey = (b12<<8)|c12; while(1) { run(); ESP8266_Set("1111\r\n"); display(); keypros(); Delay10us(); } }