欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
AVR單片機出租車計價器Proteus仿真及程序
[打印本頁]
作者:
哈哈151-
時間:
2020-4-4 17:34
標題:
AVR單片機出租車計價器Proteus仿真及程序
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
51hei.png
(15.52 KB, 下載次數: 67)
下載附件
2020-4-4 18:57 上傳
單片機源程序如下:
#include <iom16v.h>
#include <macros.h>
#include "stdio.h"
#include "delay.h"
#define uchar unsigned char
#define uint unsigned int
char smg_zx[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d, 0x7d,0x07,0x7f,0x6f,0x76,0X38};//
char smg_wx[]={0B00000001,0B00000010,0B00000100,0b00001000,0b00010000,0b00100000,0b01000000,0b10000000};
char buff[]={1,2,3,4,5,6,7,8};
uint cnt0=0,lc=0,dj=0,KS=11,ZJ=0;
uchar mode=0;
void delay_ms(unsigned int k) //8M MS級函數
{
unsigned int i,j;
for(i=0;i<k;i++)
{
for(j=0;j<570;j++);
}
}
////多位數拆分函數///////*/
void xs_buff()
{
buff[0]=lc/10;
buff[1]=lc%10;
buff[2]=dj/10;
buff[3]=dj%10;
buff[4]=ZJ/100;
buff[5]=ZJ/10%10;
buff[6]=ZJ%10;
buff[7]=KS;
}
void xs_smg()
{
static unsigned char posit=0;
PORTA |= 0XFF; // turn off
PORTA = ~ smg_wx[posit];//selecting led 7-segment
PORTB = smg_zx[buff[posit]]; //
delay_ms(2);
if(posit++>=7)posit=0;
}
void keyscan()
{
if((PIND&0xf0)!=0xf0)
{
delaynms(20);
if((PIND&0xf0)!=0xf0)
{
if((PIND&0x10)==0) //第一個按鍵
{
if(dj++>=10)dj=0;
KS=11; //L //++cnt_1; //00-FF
}
if((PIND&0x20)==0) //第二個按鍵
{
mode=0; //--cnt_1;//00-FF
SEI();
KS=10; //H
}
if((PIND&0x40)==0) //第三個按鍵
{
//--cnt_1;//00-FF
CLI();
KS=11; //L
}
if((PIND&0x80)==0) //第四個按鍵
{
if(mode++>=2)mode=0;//第一次按下時結束計價,第二次時清零,
KS=11; //L //--cnt_1;//00-FF
CLI();
if(mode==2)
{ZJ=0; lc=0;}
}
}
while((PIND&0xf0)!=0xf0);
}
}
void init_devices(void)//設備初始化函數
{
PORTA = 0XFF;//內部上拉
DDRA = 0xFF;//輸出
PORTB = 0XFF;//內部上拉
DDRB = 0xFF;//輸出
PORTD = BIT(4)|BIT(5)|BIT(6)|BIT(7);//內部上拉
PORTD &= (~BIT(3));
DDRD = ~(BIT(3)|BIT(4)|BIT(5)|BIT(6)|BIT(7));//輸入
/****外部事件計數*******/
MCUCR = 0x02;
GICR = 0x80;
SREG = 0x80;
CLI(); //關中斷
//SEI(); //開中斷
}
void main(void)
{
init_devices();//設備初始化
delaynms(300); //延時待系統穩定;
while(1)
{
keyscan();
xs_buff();
xs_smg();
ZJ=lc*dj;
}
}
/****外部事件計數*******/
#pragma interrupt_handler int1_isr:3
void int1_isr()
{
if(++cnt0>500){cnt0=0;if(lc++>=99)lc=0;}
}
復制代碼
51hei.png
(11.13 KB, 下載次數: 54)
下載附件
2020-4-4 18:57 上傳
全部資料51hei下載地址:
AVR出租車計價器.rar
(176.81 KB, 下載次數: 42)
2020-4-4 17:33 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1