新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 傳送帶物品計數(shù)器的設計帶仿真

傳送帶物品計數(shù)器的設計帶仿真

作者: 時間:2016-11-30 來源:網(wǎng)絡 收藏

仿真文件的下載地址:http://www.51hei.com/f/csdwpjs.rar
#include"lcd1602.h"

本文引用地址:http://butianyuan.cn/article/201611/323829.htm

#define uchar unsigned char
#define uint unsigned int
uchar out[6];

sbit STAR_KEY =P3^2;//定義鍵與單片機的連接引腳

sbit L0=P1^0; //定義SFR中引腳的位
sbit L1=P1^1;
sbit L2=P1^2;
sbit L3=P1^3;
sbit L4=P1^4;
sbit L5=P1^5;
sbit L6=P1^6;
sbit L7=P1^7;


sbit MOTOR=P3^0;
uchar n[2]={1,0};
void delayms(uint x) //延時子程序
{
uchar y;
while(x--)
{
for(y=0;y<123;y++){;}
}
}

uchar Keynum() //按鍵子程序1
{
uchar key=0;
STAR_KEY=1; //置初值
if(STAR_KEY==0){delayms(10);if(STAR_KEY==0)n[0]=0;n[1]=1;} //按下STAR鍵則n[0]=0;n[1]=1
return n[1]; //返回n值
}
void xianshi(uint dispbuf) //顯示子程序
{
out[0]=dispbuf/10000+0x30;
out[1]=((dispbuf%10000)/1000)+0x30;
out[2]=((dispbuf%1000)/100)+0x30;
out[3]=((dispbuf%100)/10)+0x30;
out[4]=dispbuf%10+0x30;
out[5]=