A Tm ega1 6 |2 'menyalakan LED dengan input tombol $regfile "m16def.dat" $crystal = 12000000 Config Porta = Input Config Portd = Output PortA = 255 Do Portd = Pina Loop End 'tipe IC mikrokontroller yang digunakan 'tipe X-tal oscilator 12 Mhz 'konfigurasi PortA sebagai Input 'konfigurasi PortD sebagai output 'memberi nilai PortA = 255 'awal program 'nilai PORTD = PORTA 'Looping menuju awal program 'end program
'menyalakan LED dengan input tombol $regfile "m16def.dat" $crystal = 12000000 Config Porta = Input Config Portd = Output Porta = 255 Do If Pina.0 = 1 Then Portd.0 = 0 If Pina.1 = 1 Then Portd.1 = 0 If Pina.2 = 1 Then Portd.2 = 0 If Pina.3 = 1 Then Portd.3 = 0 If Pina.4 = 1 Then Portd.4 = 0 If Pina.5 = 1 Then Portd.5 = 0 If Pina.6 = 1 Then Portd.6 = 0 If Pina.7 = 1 Then Portd.7 = 0 If Pina.0 = 0 Then Portd.0 = If Pina.1 = 0 Then Portd.1 = If Pina.2 = 0 Then Portd.2 = If Pina.3 = 0 Then Portd.3 = If Pina.4 = 0 Then Portd.4 = If Pina.5 = 0 Then Portd.5 = If Pina.6 = 0 Then Portd.6 = If Pina.7 = 0 Then Portd.7 = Loop End 1 1 1 1 1 1 1 1 'tipe IC mikrokontroller yang digunakan 'tipe X-tal oscilator 12 Mhz 'konfigurasi PortA sebagai Input 'konfigurasi PortD sebagai output 'memberi nilai PORTA=255 'awal program 'jika PINA.0 berlogika 1 maka PORTD.0 berlogika 0
A Tm ega1 6 |3
'menampilkan tulisan bergeser pada LCD Display $regfile "m16def.dat" $crystal = 12000000 Config Portb = Output 'tipe IC mikrokontroller yang digunakan 'tipe X-tal oscilator 12 Mhz 'konfigurasi PortB sebagai output
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2 'konfigurasi lcd Config Lcd = 16 * 2 'tipe lcd 16*2 Do Cls Upperline Lcd "Hello world." Wait 1 Lowerline Lcd "Welcome to." Wait 1 Loop End 'awal program 'hapus tampilan LCD dysplay 'pilih baris paling atas 'menuliskan "Hell0 world" 'tunda waktu 'pilih baris yang paling bawah 'menuliskan "welcome to" 'tunda waktu 'Looping menuju awal program 'end program
'menampilkan tulisan pada LCD Display $regfile "m16def.dat" $crystal = 12000000 Dim A As Byte Config Portb = Output 'konfigurasi PortB sebagai output Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2 Config Lcd = 16 * 2 Do Cls Locate 1 , 16 Lcd "SMKN 1 NGANJUK" Wait 1 For A = 1 To 28 Shiftlcd Left Wait 1 Next Loop End 'awal program 'bersihkan lcd Display 'lokasi baris 1 kolom 16 'tampilan SMKN 1 NGANJUK 'tipe IC mikrokontroller yang digunakan 'tipe X-tal oscilator 12 Mhz
A Tm ega1 6 |4
'menampilkan tulisan pada LCD Display dengan inputan keypad $regfile "m16def.dat" $crystal = 12000000 Dim A As Byte 'tipe IC mikrokontroller yang digunakan 'tipe X-tal oscilator 12 Mhz 'inisialisasi variable A
Config Portb = Output 'konfigurasi PortB sebagai output Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2 Config Lcd = 16 * 2 'tipe LCD 16*2 Config Kbd = Porta 'konfigurasi PORTA sebagai kbd
'program awal 'bersihkan layar LCD display 'scan port keypad 'lokasi tampilan baris 1 kolom 1 'tampilkan nilai A di LCD display 'tunda waktu 200 ms 'Looping menuju awal program 'end program
'menampilkan tulisan pada LCD Display dengan inputan keypad $regfile "m16def.dat" $crystal = 12000000 Dim Key As Byte Dim A As Byte 'tipe IC mikrokontroller yang digunakan 'tipe X-tal oscilator 12 Mhz 'inisialisasi variable Key 'inisialisasi variable A
Config Portb = Output 'konfigurasi PortB sebagai output Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2 Config Lcd = 16 * 2 Config Kbd = Porta Do Gosub Keypad Locate 1 , 1 Lcd A Waitms 200 Loop 'konfigurasi tipe LCD 16*2 'konfigurasi PortA sebagai kbd 'program awal 'memanggil sub program keypad 'lokasi tampilan baris 1 kolom 1 'tampilkan nilai A di LCD display 'tunda waktu 200 ms 'Looping menuju awal program
A Tm ega1 6 |5 Keypad: Do Key = Getkbd() Loop Until Key < 16 If Key = 0 Then A = 1 If Key = 1 Then A = 4 If Key = 2 Then A = 7 If Key = 3 Then A = 10 If Key = 4 Then A = 2 If Key = 5 Then A = 5 If Key = 6 Then A = 8 If Key = 7 Then A = 0 If Key = 8 Then A = 3 If Key = 9 Then A = 6 If Key = 10 Then A = 9 If Key = 11 Then A = 11 If Key = 12 Then A = 12 If Key = 13 Then A = 13 If Key = 14 Then A = 14 If Key = 15 Then A = 15 Waitms 200 Cls Return End 'sub program pengganti nilai kbd