- Back to Home »
- Coba-Coba saja mensimulasikan Traffic Light ^_^
Posted by : Unknown
Selasa, 15 Oktober 2013
rangkaian ini dicoba menggunakan ATmega16 dengan bahasa pemrograman menggunaka Bascom AVR. Rangkaian ini menghitung mundur selama 9 detik dan lampu akan berpindah dari hijau ke kuning lalu ke merah (prinsip dasar traffic light) berikut rangkaian / skematik-nya :
jika anda ingin belajar sekalian download proteus dan bascom AVR nya
berikut program rangkaiannya.
$regfile = "m16def.dat"
$crystal = 12000000
Config Porta = Output
Config Portc = Output
Config Portd = Output
Config Pinb.0 = Input
do
'stanby red traffic'
Portc = &B00100100
Porta = &B00100100
'traffic light'
Portc = &B00100001 'hijau'
'seven segmen'
Portd = &B10010000 '9
Waitms 70
Portd = &B10000000 '8
Waitms 70
Portd = &B11111000 '7
Waitms 70
Portd = &B10000010 '6
Waitms 70
Portd = &B10010010 '5
Waitms 70
Portd = &B10011001 '4
Waitms 70
Portd = &B10110000 '3
Waitms 70
Portd = &B10100100 '2
Waitms 70
Portd = &B11111001 '1
Waitms 70
Portd = &B01000000 '0
Waitms 100
Portc = &B00100010
Waitms 125
Portc = &B00100100
Waitms 100
Portc = &B00001100 'hijau'
'seven segmen'
Portd = &B10010000 '9
Waitms 70
Portd = &B10000000 '8
Waitms 70
Portd = &B11111000 '7
Waitms 70
Portd = &B10000010 '6
Waitms 70
Portd = &B10010010 '5
Waitms 70
Portd = &B10011001 '4
Waitms 70
Portd = &B10110000 '3
Waitms 70
Portd = &B10100100 '2
Waitms 70
Portd = &B11111001 '1
Waitms 70
Portd = &B01000000 '0
Waitms 100
Portc = &B00010100 'kuning'
Waitms 125
Portc = &B00100100 'merah'
Waitms 100
Porta = &B00001100 'hijau'
'seven segmen'
Portd = &B10010000 '9
Waitms 70
Portd = &B10000000 '8
Waitms 70
Portd = &B11111000 '7
Waitms 70
Portd = &B10000010 '6
Waitms 70
Portd = &B10010010 '5
Waitms 70
Portd = &B10011001 '4
Waitms 70
Portd = &B10110000 '3
Waitms 70
Portd = &B10100100 '2
Waitms 70
Portd = &B11111001 '1
Waitms 70
Portd = &B01000000 '0
Waitms 100
Porta = &B00010100 'kuning'
Waitms 125
Porta = &B00100100 'merah'
Waitms 100
Porta = &B00100001 'hijau'
'seven segmen'
Portd = &B10010000 '9
Waitms 70
Portd = &B10000000 '8
Waitms 70
Portd = &B11111000 '7
Waitms 70
Portd = &B10000010 '6
Waitms 70
Portd = &B10010010 '5
Waitms 70
Portd = &B10011001 '4
Waitms 70
Portd = &B10110000 '3
Waitms 70
Portd = &B10100100 '2
Waitms 70
Portd = &B11111001 '1
Waitms 70
Portd = &B01000000 '0
Waitms 100
Porta = &B00100010 'kuning'
Waitms 125
Porta = &B00100100 'merah'
Waitms 100
loop
sekian dam terima kasih, hehehe