|
單片機max7219計步器仿真圖 原理圖
0.png (29.34 KB, 下載次數(shù): 170)
下載附件
2016-5-10 22:53 上傳
0.png (69 KB, 下載次數(shù): 146)
下載附件
2016-5-10 22:54 上傳
計步器的所有仿真和源碼下載:
計步器Proteus仿真和源程序.rar
(85.34 KB, 下載次數(shù): 389)
2016-5-10 22:56 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
如果需要基于adxl345加速度 計步器程序在這里: http://www.zg4o1577.cn/bbs/dpj-50085-1.html
下面是部分源碼預(yù)覽:
- #include "reg51.h"
- #define uint unsigned int
- #define uchar unsigned char
- sbit DIN = P1^0;
- sbit CLK = P1^1;
- sbit LOAD = P1^2;
- sbit StartKey = P1^3;
- sbit StopKey = P1^4;
- sbit StepKey = P1^5;
- uchar StartFlag=0;
- #define NoOp 0x00
- #define Digit0 0x01
- #define Digit1 0x02
- #define Digit2 0x03
- #define Digit3 0x04
- #define Digit4 0x05
- #define Digit5 0x06
- #define Digit6 0x07
- #define Digit7 0x08
- #define DecodeMode 0x09
- #define Intensity 0x0a
- #define ScanLimit 0x0b
- #define ShutDown 0x0c
- #define DisplayTest 0x0f
- #define ShutdownMode 0x00
- #define NormalOperation 0x01
- #define ScanDigit 0x07
- #define DecodeDigit 0xff
- #define IntensityGrade 0x0a
- #define TestMode 0x01
- #define TextEnd 0x00
- uchar DisBuffer[8]= {0,0,0,0,0,0,0,0};
- void delay(uint t)
- {
- uint i;
- while(t--)
- {
- for(i=0; i<8; i++);
- }
- }
- void SendChar(uchar ch)
- {
- uchar i,temp;
- // _nop_();
- for(i=0; i<8; i++)
- {
- temp=ch&0x80;
- ch=ch<<1;
- if(temp)
- {
- DIN=1;
- CLK=0;
- CLK=1;
- }
- else
- {
- DIN=0;
- CLK=0;
- CLK=1;
- }
- }
- }
- void WriteWord(uchar addr,uchar num)
- {
- LOAD=0;
- // _nop_();
- SendChar(addr);
- // _nop_();
- SendChar(num);
- // _nop_();
- LOAD=1;
- }
- void InitDisplay()
- {
- WriteWord(ScanLimit,ScanDigit);
- WriteWord(DecodeMode,DecodeDigit);
- WriteWord(Intensity,IntensityGrade);
- WriteWord(ShutDown,NormalOperation);
- }
- void main()
- {
- unsigned long StepCount = 0;
- uchar i;
- InitDisplay();
- WriteWord(DisplayTest,TestMode);
- delay(3000);
- WriteWord(DisplayTest,TextEnd);
- while(1)
- {
- if(StartKey == 0)
- {
- delay(100);
- if(StartKey == 0)
- {
- StartFlag = 1;
- for(i = 0;i < 8;i++)
- {
- WriteWord(Digit0+i,0);
- }
- }
- while(!StartKey);
- }
- else if(StopKey == 0)
- {
- delay(100);
- if(StopKey == 0)
- {
- StartFlag = 0;
- }
- while(!StopKey);
- }
- if(StartFlag)
- {
- if(StepKey == 0)
- {
- delay(100);
- if(StepKey == 0)
- {
- StepCount++;
- }
- while(!StepKey);
- }
- }
-
- WriteWord(Digit7,StepCount%10);
- WriteWord(Digit6,StepCount/10%10);
- WriteWord(Digit5,StepCount/100%10);
- WriteWord(Digit4,StepCount/1000%10);
- WriteWord(Digit3,StepCount/10000%10);
- WriteWord(Digit2,StepCount/100000%10);
- WriteWord(Digit1,StepCount/1000000%10);
- WriteWord(Digit0,StepCount/10000000%10);
- }
- }
復(fù)制代碼
|
評分
-
查看全部評分
|