Keinget maenan waktu SD, mainan yang bentuknya kaya tabung dengan ujungnya setengah bola, dan di dalamya terdapat lampu beraneka ragam, dulu saya masih bingung dengan cara kerja mainan itu, karena setiap saya pencet tombol yang ada di situ, lampunya menyala selalu berubah-ubah, berkedip-kedip, bergerak ke kanan, ke kiri, dll, hingga kembali lagi ke awal, nah dari situ saya muncul ide untuk membuat program seperti itu, dan cukup mudah membuatnya, tanpa bertele-tele
berikut gambar simulasi rangkaiannya :
dan berikut coding program dengan bascom-Avr :
berikut gambar simulasi rangkaiannya :
dan berikut coding program dengan bascom-Avr :
$regfile = "m16def.dat"
$crystal = 8000000
Config Portc = Output
Config Porta = Input
Porta = &HFF
Portc = &HFF
S1 Alias Pina.0
Dim K As Integer 'kondisi
Dim Ro As Byte 'rotate
Dim Ro1 As Byte 'rotate
Dim Ro2 As Byte 'rotate
K = 0
Do
If S1 = 0 Then
K = 0
Do 'button 1
Portc = &H00
If S1 = 1 Then K = 1
Waitms 200
Portc = &HFF
If S1 = 1 Then K = 1
Waitms 200
Loop Until S1 = 0 And K = 1
K = 0
Ro = &HFE
Do 'button 2
Portc = Ro
Rotate Ro , Left , 1
Waitms 200
If S1 = 1 Then K = 1
Loop Until S1 = 0 And K = 1
K = 0
Ro = &H7F
Do 'button 3
Portc = Ro
Rotate Ro , Right , 1
Waitms 200
If S1 = 1 Then K = 1
Loop Until S1 = 0 And K = 1
K = 0
Ro1 = &H7F
Ro2 = &HFE
Do 'button 4
Ro = Ro1 And Ro2
Portc = Ro
Rotate Ro1 , Right , 1
Rotate Ro2 , Left , 1
If S1 = 1 Then K = 1
Waitms 200
Loop Until S1 = 0 And K = 1
K = 0
Ro1 = &H7F
Ro2 = 0
Do 'button 5
Portc = Ro1
If Ro2 = 0 Then
Rotate Ro1 , Right , 1
Else
Rotate Ro1 , Left , 1
End If
If Ro1 = &H7F Then Ro2 = 0
If Ro1 = &HFE Then Ro2 = 1
Waitms 200
If S1 = 1 Then K = 1
Loop Until S1 = 0 And K = 1
Portc = &HFF
Do
Loop Until S1 = 1
End If
Loop
$crystal = 8000000
Config Portc = Output
Config Porta = Input
Porta = &HFF
Portc = &HFF
S1 Alias Pina.0
Dim K As Integer 'kondisi
Dim Ro As Byte 'rotate
Dim Ro1 As Byte 'rotate
Dim Ro2 As Byte 'rotate
K = 0
Do
If S1 = 0 Then
K = 0
Do 'button 1
Portc = &H00
If S1 = 1 Then K = 1
Waitms 200
Portc = &HFF
If S1 = 1 Then K = 1
Waitms 200
Loop Until S1 = 0 And K = 1
K = 0
Ro = &HFE
Do 'button 2
Portc = Ro
Rotate Ro , Left , 1
Waitms 200
If S1 = 1 Then K = 1
Loop Until S1 = 0 And K = 1
K = 0
Ro = &H7F
Do 'button 3
Portc = Ro
Rotate Ro , Right , 1
Waitms 200
If S1 = 1 Then K = 1
Loop Until S1 = 0 And K = 1
K = 0
Ro1 = &H7F
Ro2 = &HFE
Do 'button 4
Ro = Ro1 And Ro2
Portc = Ro
Rotate Ro1 , Right , 1
Rotate Ro2 , Left , 1
If S1 = 1 Then K = 1
Waitms 200
Loop Until S1 = 0 And K = 1
K = 0
Ro1 = &H7F
Ro2 = 0
Do 'button 5
Portc = Ro1
If Ro2 = 0 Then
Rotate Ro1 , Right , 1
Else
Rotate Ro1 , Left , 1
End If
If Ro1 = &H7F Then Ro2 = 0
If Ro1 = &HFE Then Ro2 = 1
Waitms 200
If S1 = 1 Then K = 1
Loop Until S1 = 0 And K = 1
Portc = &HFF
Do
Loop Until S1 = 1
End If
Loop
download http://adf.ly/1ZL01I
Password Rar: ganyang-angkara.blogspot.com
moga bermanfaat bagi agan-agan yang ingin mencobanya,
moga berhasil mencobanya..
*..sesama blogger harus saling menghargai, jika agan-agan ingin mengcopas harap cantumkan alamat urlnya, Terimakasih..*