兼职项目 智能自行车
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
2.2 KiB

3 years ago
#include <reg51.h>
#include <intrins.h>
#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() //ʹ<EFBFBD>ö<EFBFBD>ʱ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>STC89C52<EFBFBD><EFBFBD>STC89C51<EFBFBD><EFBFBD>AT89C51<EFBFBD>Ⱦ<EFBFBD><EFBFBD>ɣ<EFBFBD>
{
TMOD = 0x20 | 0x01;
SCON = 0x50; //<EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD>з<EFBFBD>ʽ
TH1 = 0xFD; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>9600
TL1 = TH1;
PCON = 0x00;
EA = 1; //<EFBFBD><EFBFBD><EFBFBD>жϴ<EFBFBD><EFBFBD><EFBFBD>
ES = 1; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
TR1 = 1; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>1
}
void us_delay(uchar t)
{
while(t--);
}
void Send_Uart(uchar value)
{
ES=0; //<EFBFBD>رմ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
TI=0; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
SBUF=value; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
while(TI==0); //<EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TI=0; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
ES=1; //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
}
void ESP8266_Set(uchar *puf) // <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>*pufָ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
while(*puf!='\0') //<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD>
{
Send_Uart(*puf); //<EFBFBD><EFBFBD>WIFIģ<EFBFBD><EFBFBD>Ϳ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>
us_delay(5);
puf++;
}
}
3 years ago
void main(void)
{
int i = 0;
3 years ago
InitLcd1602();
IRIN_Init();
Uart_Init();
3 years ago
pwm_left=10;
b12=At24c02Read(1);
c12=At24c02Read(8);
money = 120;
3 years ago
money=At24c02Read(5);
journey = (b12<<8)|c12;
3 years ago
while(1)
{
run();
ESP8266_Set("1111\r\n");
display();
keypros();
Delay10us();
3 years ago
}
}