74HC595 Nixie Driver

Dependencies:   mbed

Committer:
heroistired
Date:
Fri Jun 16 07:07:15 2017 +0000
Revision:
0:b5bd2bc3c14d
Chen Huan; EEA of THU

Who changed what in which revision?

UserRevisionLine numberNew contents of line
heroistired 0:b5bd2bc3c14d 1 #include "mbed.h"
heroistired 0:b5bd2bc3c14d 2 #include "Nixie.h"
heroistired 0:b5bd2bc3c14d 3
heroistired 0:b5bd2bc3c14d 4 //数码管驱动示例
heroistired 0:b5bd2bc3c14d 5
heroistired 0:b5bd2bc3c14d 6 Nixie myNixie(PA_0,PA_1,PA_4); //声明数码管类 依次是 DIO SCK RCK 任意GPIO脚都可以
heroistired 0:b5bd2bc3c14d 7
heroistired 0:b5bd2bc3c14d 8 int pos = 0, num = 0;
heroistired 0:b5bd2bc3c14d 9 bool WithDot = false;
heroistired 0:b5bd2bc3c14d 10 int main()
heroistired 0:b5bd2bc3c14d 11 {
heroistired 0:b5bd2bc3c14d 12 while(1)
heroistired 0:b5bd2bc3c14d 13 {
heroistired 0:b5bd2bc3c14d 14 wait(0.15);
heroistired 0:b5bd2bc3c14d 15 myNixie.NixieShow(num,pos,WithDot);//在数码管上显示数字 num 要显示的数字 pos 数字显示的位置 从左到右 0-7 WithDot 是否显示小数点
heroistired 0:b5bd2bc3c14d 16 num++;
heroistired 0:b5bd2bc3c14d 17 pos++;
heroistired 0:b5bd2bc3c14d 18 if(num == 10)
heroistired 0:b5bd2bc3c14d 19 {
heroistired 0:b5bd2bc3c14d 20 num = 0;
heroistired 0:b5bd2bc3c14d 21 if(WithDot)
heroistired 0:b5bd2bc3c14d 22 WithDot = false;
heroistired 0:b5bd2bc3c14d 23 else
heroistired 0:b5bd2bc3c14d 24 WithDot = true;
heroistired 0:b5bd2bc3c14d 25 }
heroistired 0:b5bd2bc3c14d 26 if(pos == 8)
heroistired 0:b5bd2bc3c14d 27 pos = 0;
heroistired 0:b5bd2bc3c14d 28 }
heroistired 0:b5bd2bc3c14d 29 }