WONDERFUL RUNNING LED WITH ATMEGA8535
Sumber:sukasukapaktri.blogspot.co.id/2012/12/wonderful-running-led-with-atmega8535.html
Projek Wonderful Running Led With Atmega8535. Awalnya dia tertarik untuk belajar mikrokontroler khususnya belajar pemrograman BASCOM AVR.
Wonderful Running LED
Mengapa menggunakan chip ATMEGA8535 itu karena selain banyak di pasaran, IC ini juga memiliki fitur yang cukup kompleks sehingga akan mudah diaplikasikan ke dalam bentuk pengontrolan yang lain. Untuk lebih jelasnya mengenai ATMEGA8535 bisa download datasheetnya di sini.
Sebagai langkah awal pembelajaran, saya aplikasikan mikrokontroler ATMEGA8535 sebagai pengendali running led yang diprogram dengan software BASCOM AVR.
Pemrograman dengan BASCOM AVR
LED akan secara bergantian hidup dan mati sesuai dengan instruksi program yang tersimpan dalam chip mikrokontroler. Dengan bahasa pemrograman basic kita menggunakan istilah pengondisian DO - IF - THEN - END - IF - LOOP.
Berikut contoh programnya:
$regfile = "m8535dat"
$crystal = 11059200
config portb = input
config porta = output
config portc = output
sw1 Alias PORTB.1
LED Alias PORTC
Ddrb = &B00000000
PORTC = &B11111111
'--------------------------------
Do
If sw1 = 0 then
waitms 50
LED = &B00000000
waitms 20
LED = &B11111111
waitms 50
LED = &B00000000
waitms 20
LED = &B11111111
waitms 50
LED = &B00000000
waitms 20
LED = &B11111111
waitms 50
LED = &B00000000
waitms 20
LED = &B11111111
waitms 50
'----------------------------------
LED = &B11111110
waitms 10
LED = &B11111101
waitms 10
LED = &B11111011
waitms 10
LED = &B11110111
waitms 10
LED = &B11101111
waitms 10
LED = &B11011111
waitms 10
LED = &B10111111
waitms 10
LED = &B01111111
'------------------------------------- 1
waitms 10
LED = &B01111110
waitms 10
LED = &B01111101
waitms 10
LED = &B01111011
waitms 10
LED = &B01110111
waitms 10
LED = &B01101111
waitms 10
LED = &B01011111
waitms 10
LED = &B00111111
'------------------------------ 2
waitms 10
LED = &B00111110
waitms 10
LED = &B00111101
waitms 10
LED = &B00111011
waitms 10
LED = &B00110111
waitms 10
LED = &B00101111
waitms 10
LED = &B00011111
'------------------------------- 3
waitms 10
LED = &B00011110
waitms 10
LED = &B00011101
waitms 10
LED = &B00011011
waitms 10
LED = &B00010111
waitms 10
LED = &B00001111
'----------------------------------- 4
waitms 10
LED = &B00001110
waitms 10
LED = &B00001101
waitms 10
LED = &B00001011
waitms 10
LED = &B00000111
'---------------------------------- 5
waitms 10
LED = &B00000110
waitms 10
LED = &B00000101
waitms 10
LED = &B00000011
'---------------------------------- 6
waitms 10
LED = &B00000010
waitms 10
LED = &B00000000
'--------------------------------- 7
waitms 30
LED = &B11100111
waitms 10
LED = &B11000011
waitms 10
LED = &B10000001
waitms 10
LED = &B00000000
waitms 10
LED = &B10000001
waitms 10
LED = &B11000011
waitms 10
LED = &B11100111
waitms 10
LED = &B11111111
'---------------------------------
waitms 30
LED = &B11100111
waitms 10
LED = &B11000011
waitms 10
LED = &B10000001
waitms 10
LED = &B00000000
waitms 10
LED = &B10000001
waitms 10
LED = &B11000011
waitms 10
LED = &B11100111
waitms 10
LED = &B11111111
'--------------------------------
waitms 30
LED = &B11100111
waitms 10
LED = &B11000011
waitms 10
LED = &B10000001
waitms 10
LED = &B00000000
waitms 10
LED = &B10000001
waitms 10
LED = &B11000011
waitms 10
LED = &B11100111
waitms 10
LED = &B11111111
End If
Loop
Videonya dapat dilihat dibawah ini:
Comments
Post a Comment
-Berkomentarlah yang baik dan rapi.
-Menggunakan link aktif akan dihapus.