电机功能测量:
3、LCD显示测量结果
4、按键控制电机转速
#include"LCD.H"
void write_com(unsigned char com) //写命令
{
RS_CLR;
RW_CLR;
P0=com;
DelayMs(3);
EN_SET;
DelayMs(3);
EN_CLR;
}
void write_data(unsigned char date) //写一个字符
{
RS_SET;
RW_CLR;
P0=date;
DelayMs(3);
EN_SET;
DelayMs(3);
EN_CLR;
}
void init() //初始化
{
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
/*------------------------------------------------
写入字符串函数
------------------------------------------------*/
void LCD_Write_String(unsigned char x,unsigned char y,unsigned char *s)
{
if (y == 0)
{
write_com(0x80 + x);
}
else
{
write_com(0xC0 + x);
}
while (*s)
{
write_data( *s);
s ++;
}
}
#include"LCD.H"
void write_com(unsigned char com) //写命令
{
RS_CLR;
RW_CLR;
P0=com;
DelayMs(3);
EN_SET;
DelayMs(3);
EN_CLR;
}
void write_data(unsigned char date) //写一个字符
{
RS_SET;
RW_CLR;
P0=date;
DelayMs(3);
EN_SET;
DelayMs(3);
EN_CLR;
}
void init() //初始化
{
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
/*------------------------------------------------
写入字符串函数
------------------------------------------------*/
void LCD_Write_String(unsigned char x,unsigned char y,unsigned char *s)
{
if (y == 0)
{
write_com(0x80 + x);
}
else
{
write_com(0xC0 + x);
}
while (*s)
{
write_data( *s);
s ++;
}
}
阅读全文