BASCOM-AVR 4个数码管同时显示数字0-9
2020-09-07 来源:51hei
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
$regfile = 'm16def.dat' 'ATMega16 单片机
$crystal = 8000000 '8兆赫晶振
Dim I As Byte
'PORTB 8个引脚PB0-PB7连接了数码管 A B C D E F G H
Config Porta = Output
Config Portb = Output
Porta.0 = 0 '第1位数码管亮
Porta.1 = 0
Porta.2 = 0
Porta.3 = 0 '第4个数码管亮
'====================
'数码管显示0-9,1秒钟切换1次
Do
Wait 1
I = I + 1
If I >= 10 Then I = 0
If I = 0 Then Portb = &HC0
If I = 1 Then Portb = &HF9
If I = 2 Then Portb = &HA4
If I = 3 Then Portb = &HB0
If I = 4 Then Portb = &H99
If I = 5 Then Portb = &H92
If I = 6 Then Portb = &H82
If I = 7 Then Portb = &HF8
If I = 8 Then Portb = &H80
If I = 9 Then Portb = &H90
Loop
End