Sie sind auf Seite 1von 2

$regfile = "m16def.

dat" $crystal = 8000000 Config Config Config Config Dim Dim Dim Dim ktu N(4) N(3) N(2) N(1) Porta Portb Portc Portd = = = = Output Output Output Output 'output 7segmen 'counter 'perulangan 'perulangan untuk wa

O(8) N(4) U As W As = = = = 80 60 40 20

As Integer As Integer Byte Integer

Porta = Lookup(0 , Traffic) Portb = Lookup(4 , Traffic) Do For U = 1 To 4 Decr N(u) If N(u) = -1 Then N(u) = 79 Next U 'proses O(1) = N(1) Mod 100 O(1) = O(1) / 10 O(2) = N(1) Mod 10 O(3) = N(2) Mod 100 O(3) = O(3) / 10 O(4) = N(2) Mod 10 O(5) = N(3) Mod 100 O(5) = O(5) / 10 O(6) = N(3) Mod 10 O(7) = N(4) Mod 100 O(7) = O(7) / 10 O(8) = N(4) Mod 10 For W = 1 To 50 For U = 1 To 8 Portd = Lookup(u , Modes) Portc = Lookup(o(u) , Segmen) Waitms 1 Next U Next W If If If If If N(1) N(1) N(2) N(2) N(2) = = = = = 6 1 6 1 1 Then Then Then Then Then Porta Porta Porta Porta Portb = = = = = Lookup(1 Lookup(2 Lookup(3 Lookup(4 Lookup(0 , , , , , Traffic) Traffic) Traffic) Traffic) Traffic) 'delay 'out 7segmen 'counter 7 segmen

If If If If If

N(3) N(3) N(4) N(4) N(4)

= = = = =

6 1 6 1 1

Then Then Then Then Then

Portb Portb Portb Portb Porta

= = = = =

Lookup(1 Lookup(2 Lookup(3 Lookup(4 Lookup(0

, , , , ,

Traffic) Traffic) Traffic) Traffic) Traffic)

Loop Modes: Data 0 , 1 , 2 , 4 , 8 , 16 , 32 , 64 , 128 Traffic: Data 12 , 10 , 33 , 17 , 9 'pengaktifan 7segmen 'out traffic

Segmen: Data &HC0 , &HF9 , &HA4 , &HB0 , &H99 , &H92 , &H82 , &HF8 , &H80 , &H90 Source code Traffic Light Simulator dengan bascom avr dan at mega 8535 $regfile = "m8535.dat" $crystal = 16000000 Config Portc = Output Config Porta = Output Do Portc = &B11011110 Porta = &B11110011 Wait 3 Portc = &B11011101 Porta = &B11110011 Wait 1 Portc = &B11011011 Porta = &B11110110 Wait 3 Portc = &B11011011 Porta = &B11110101 Wait 1 Portc = &B10011011 Porta = &B11111011 Wait 3 Portc = &B01011011 Porta = &B11111011 Wait 1 Portc = &B11110011 Porta = &B11110011 Wait 3 Portc = &B11101011 Porta = &B11110011 Wait 1 Loop End

ganyang-angkara.blogspot.com

Das könnte Ihnen auch gefallen