Berikut caranya:
1. Buka Bascom-AVR, ketik:
'berkedip semua 3x, lalu berjalan ke kiri, dan ke kanan
$regfile = "m16def.dat" 'inisial penggunaan mikrokontroller atmega 8535
$crystal = 12000000 'inisial penggunaan crystal=12000000
Config Portc = Output 'konfigurasi port
Portc = &B11111111
Dim X As Integer
Dim Y As Byte
Do
'---berkedip---
X = 0
Do
Portc = &B00000000
Waitms 50
Portc = &B11111111
Waitms 50
X = X + 1
Loop Until X = 3
'---bergeser kekiri---
Y = &B11111110
Do
Portc = Y
Waitms 50
Rotate Y , Left , 1
Loop Until Y = &B11111110
Portc = &B11111111
Waitms 50
'---bergeser kekanan---
Y = &B01111111
Do
Portc = Y
Waitms 50
Rotate Y , Right , 1 'perintah rotasi
Waitms 50
Loop Until Y = &B01111111
Portc = &B1111111
Waitms 50
Loop
$regfile = "m16def.dat" 'inisial penggunaan mikrokontroller atmega 8535
$crystal = 12000000 'inisial penggunaan crystal=12000000
Config Portc = Output 'konfigurasi port
Portc = &B11111111
Dim X As Integer
Dim Y As Byte
Do
'---berkedip---
X = 0
Do
Portc = &B00000000
Waitms 50
Portc = &B11111111
Waitms 50
X = X + 1
Loop Until X = 3
'---bergeser kekiri---
Y = &B11111110
Do
Portc = Y
Waitms 50
Rotate Y , Left , 1
Loop Until Y = &B11111110
Portc = &B11111111
Waitms 50
'---bergeser kekanan---
Y = &B01111111
Do
Portc = Y
Waitms 50
Rotate Y , Right , 1 'perintah rotasi
Waitms 50
Loop Until Y = &B01111111
Portc = &B1111111
Waitms 50
Loop
2. Lalu compile (tekan F7 atau klik menu Program-Compile
3. Buka rangkaian sismin atmega 16, atau buat dengan proteus seperti berikut:
4. Masukkan Programnya
5. Klik Play
6. Berikut Hasilnya:
Download Skrip Bascom-AVR nya
No comments:
Post a Comment