Gerbang AND adalah suatu gerbang logika dasar yang mempunyai 2 input atau lebih dan mempunyai 1 output
Cara kerjanya : output akan berlogika "1" jika semua input berlogika "1"
Gerbang AND ibarat seperti saklar seri
Untuk mengetahui cara kerjanya, penulis kali ini akan mensimulasikan dengan program mikrokontroler Atmega 8535, seperti di bawah ini
1. Gambar rangkaian
2. List Code : dengan Bascom AVR
$regfile = "m8535.dat"
$crystal = 4000000
Config Portb = Input
Config Portc = Output
Config Lcd = 20 * 4
Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E = Porta.3 , Rs = Porta.2
Cursor Off
Ddrb = 0 : Portb = 255
Locate 1 , 1
Lcd "**** CARA KERJA ****"
Locate 2 , 1
Lcd " GERBANG 'AND' "
Waitms 2
Portc = 8
Do
If Pinb.0 = 0 And Pinb.1 = 0 Then
Locate 3 , 1
Lcd "Input A = 1 , B = 1 "
Locate 4 , 1
Lcd "Output Q = 1 "
End If
If Pinb.0 = 0 And Pinb.1 = 1 Then
Locate 3 , 1
Lcd "Input A = 1 , B = 0 "
Locate 4 , 1
Lcd "Output Q = 0 "
End If
If Pinb.0 = 1 And Pinb.1 = 0 Then
Locate 3 , 1
Lcd "Input A = 0 , B = 1 "
Locate 4 , 1
Lcd "Output Q = 0 "
End If
If Pinb.0 = 1 And Pinb.1 = 1 Then
Locate 3 , 1
Lcd "Input A = 0 , B = 0 "
Locate 4 , 1
Lcd "Output Q = 0 "
End If
'========================================
If Pinb.0 = 0 And Pinb.1 = 0 Then
Portc = 1
End If
If Pinb.0 = 0 And Pinb.1 = 1 Then
Portc = 0
End If
If Pinb.0 = 1 And Pinb.1 = 0 Then
Portc = 0
End If
If Pinb.0 = 1 And Pinb.1 = 1 Then
Portc = 0
End If
Loop
Semoga bermanfaat
Tidak ada komentar:
Posting Komentar
Silahkan berkomentar !