请问大家,用stc89c52单片机和28byj48步进电机怎么让电机的步数显示在lcd1602液晶屏上?

2019-11-26 11:25发布

<font face="微软雅黑">uchar code table[]="ghfhfhf";</font><font face="微软雅黑">sbit lcden=P3^6;</font><font face="微软雅黑">sbit lcdrs=P3^4;</font><font face="微软雅黑">sbit wela=P2^7;</font><font face="微软雅黑"><br> </font><font face="微软雅黑">代码2:</font><font face="微软雅黑">void write_com(uchar com)</font><br> <font face="微软雅黑">{</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; lcdrs=0;</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; P0=com;</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; delay();</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; lcden=1;</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; delay();</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; lcden=0;</font><br> <font face="微软雅黑">}</font><br> <font face="微软雅黑"><br> </font><br> <font face="微软雅黑">void write_data(uchar date)</font><br> <font face="微软雅黑">{</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; lcdrs=1;</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; P0=date;</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; delay();</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; lcden=1;</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; delay();</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; lcden=0;</font><br> <font face="微软雅黑">}</font><br> <font face="微软雅黑"><br> </font><br> <font face="微软雅黑">void init()</font><br> <font face="微软雅黑">{</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; dula=0;</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; wela=0;</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; lcden=0;</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; write_com(0x38);&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;//16×2显示</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; write_com(0x0e);&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;//开显示,显示光标,光标不闪烁</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; write_com(0x06);&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;//当读或写一个字符后,地址指针加一,且光标加一。整屏显示不移动</font><br> <font face="微软雅黑">//&nbsp; &nbsp; &nbsp; &nbsp; write_com(0x01); //清屏</font><br> <font face="微软雅黑">&nbsp; &nbsp; &nbsp; &nbsp; //write_com(0x80+0x10);&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;//第二行显示</font><br> <br> <font face="微软雅黑">}</font><br> <br> <p><br></p>
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。