Professional Documents
Culture Documents
NIM : 061840341357
Absen : 6 (enam)
Kelas : 5 ELA
SOAL
Buat rangkaian dan program menggunakan Bascom untuk mengaktifkan 8 output LED
menggunakan 3 switch dan tampilan visual basic.
GAMBAR RANGKAIAN
GAMBAR RANGKAIAN MENGGUNAKAN PROTEUS
$regfile = "8052.dat"
$baud = 9600
$crystal = 12000000
Dim A As Byte
Do
A = Inkey()
If P1.0 = 0 Then
Wait 5
A = " A"
P2 = &B11111110
Wait 5
P2 = &B11111100
Wait 5
P2 = &B11111000
Wait 5
P2 = &B11110000
Wait
P2 = &B11100000
Wait 5
P2 = &B11000000
Wait 5
P2 = &B10000000
Wait 5
P2 = &B00000000
Wait 5
P2 = &B11111111
Wait 5
P2 = &B01111111
Wait 5
P2 = &B00111111
Wait 5
P2 = &B00011111
Wait 5
P2 = &B00001111
Wait 5
P2 = &B00000111
Wait 5
P2 = &B00000011
Wait 5
P2 = &B00000001
Wait 5
P2 = &B00000000
Wait 5
End If
If P1.1 = 0 Then
Wait 5
A = "B"
P2 = &B00000000
Wait 5
P2 = &B11111111
Wait 5
P2 = &B00000000
Wait 5
P2 = &B11111111
Wait 5
End If
If P1.2 = 0 Then
Wait 5
A = "C"
P2 = &B11111111
Wait 5
End If
Loop
MSComm1.PortOpen = True
Shape1.Visible = False
Shape2.Visible = False
Shape3.Visible = False
Shape4.Visible = False
Shape5.Visible = False
Shape6.Visible = False
Shape7.Visible = False
Shape8.Visible = False
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
End Sub
MSComm1.PortOpen = False
Shape1.Visible = True
Shape2.Visible = True
Shape3.Visible = True
Shape4.Visible = True
Shape5.Visible = True
Shape6.Visible = True
Shape7.Visible = True
Shape8.Visible = True
End Sub
Timer1.Enabled = True
End Sub
Timer2.Enabled = True
End Sub
End Sub
Timer3.Enabled = True
End Sub
MSComm1.Output = "A"
Shape1.Visible = True
delay1
Shape1.Visible = True
Shape2.Visible = True
delay1
Shape1.Visible = True
Shape2.Visible = True
Shape3.Visible = True
delay1
Shape1.Visible = True
Shape2.Visible = True
Shape3.Visible = True
Shape4.Visible = True
delay1
Shape1.Visible = True
Shape2.Visible = True
Shape3.Visible = True
Shape4.Visible = True
Shape5.Visible = True
delay1
Shape1.Visible = True
Shape2.Visible = True
Shape3.Visible = True
Shape4.Visible = True
Shape5.Visible = True
Shape6.Visible = True
delay1
Shape1.Visible = True
Shape2.Visible = True
Shape3.Visible = True
Shape4.Visible = True
Shape5.Visible = True
Shape6.Visible = True
Shape7.Visible = True
delay1
Shape1.Visible = True
Shape2.Visible = True
Shape3.Visible = True
Shape4.Visible = True
Shape5.Visible = True
Shape6.Visible = True
Shape7.Visible = True
Shape8.Visible = True
delay1
Shape1.Visible = False
Shape2.Visible = False
Shape3.Visible = False
Shape4.Visible = False
Shape5.Visible = False
Shape6.Visible = False
Shape7.Visible = False
Shape8.Visible = False
delay1
Shape8.Visible = True
delay1
Shape8.Visible = True
Shape7.Visible = True
delay1
Shape8.Visible = True
Shape7.Visible = True
Shape6.Visible = True
delay1
Shape8.Visible = True
Shape7.Visible = True
Shape6.Visible = True
Shape5.Visible = True
delay1
Shape8.Visible = True
Shape7.Visible = True
Shape6.Visible = True
Shape5.Visible = True
Shape4.Visible = True
delay1
Shape8.Visible = True
Shape7.Visible = True
Shape6.Visible = True
Shape5.Visible = True
Shape4.Visible = True
Shape3.Visible = True
delay1
Shape8.Visible = True
Shape7.Visible = True
Shape6.Visible = True
Shape5.Visible = True
Shape4.Visible = True
Shape3.Visible = True
Shape2.Visible = True
delay1
Shape1.Visible = True
Shape2.Visible = True
Shape3.Visible = True
Shape4.Visible = True
Shape5.Visible = True
Shape6.Visible = True
Shape7.Visible = True
Shape8.Visible = True
delay1
End Sub
Dim y As Single
y = Timer + 5
DoEvents
Loop
End Sub
MSComm1.Output = "B"
Shape1.Visible = True
Shape2.Visible = True
Shape3.Visible = True
Shape4.Visible = True
Shape5.Visible = True
Shape6.Visible = True
Shape7.Visible = True
Shape8.Visible = True
delay1
Shape1.Visible = False
Shape2.Visible = False
Shape3.Visible = False
Shape4.Visible = False
Shape5.Visible = False
Shape6.Visible = False
Shape7.Visible = False
Shape8.Visible = False
delay1
Shape1.Visible = True
Shape2.Visible = True
Shape3.Visible = True
Shape4.Visible = True
Shape5.Visible = True
Shape6.Visible = True
Shape7.Visible = True
Shape8.Visible = True
delay1
End Sub
Shape1.Visible = False
Shape2.Visible = False
Shape3.Visible = False
Shape4.Visible = False
Shape5.Visible = False
Shape6.Visible = False
Shape7.Visible = False
Shape8.Visible = False
delay1
End Sub
PEMBAHASAN
Untuk ujian akhir semester Mata Kuliah Praktek Antarmuka Mikrokontroler semester 5 saya
mendapatkan sistem minimum AT89S52 untuk alat penghubung mikrokontroler dengan
rangkaian dan program yang telah ditentukan pada soal.
Komponen yang dibutuhkan untuk menjalankan program uas ini adalah 3 buah switch, 8 led
dan jumper secukupnya yang saya rangkai di protoboard. USBISP dan kabel RS232 juga
dibutuhkan untuk menjalankan program ini. USBISP berguna untuk mengisi program (file
hex) hasil compile dari komputer ke mikrokontroler.
Pin 1 (Port 1.0) untuk switch 1 berfungsi menjalankan perintah pertama pada soal yaitu
menggeser output LED ON 1 bit ke kanan lalu menggeser output LED ON 1 bit ke kiri.
Pin 2 (Port 1.1) untuk switch 2 berfungsi menjalankan perintah kedua pada soal yaitu
menghidupkan LED flip flop.
Pin 3 (Port 1.2) untuk switch 3 berfungsi menjalankan perintah ketiga yaitu memadamkan
LED 8 bit.
Ada beberapa kendala yang saya alami ketika membuat program ini, yaitu :
1. Program dan koding yang saya buat tidak langsung berhasil, masih ada beberapa syntax
yang error sehingga saya mencari referensi dari beberapa sumber untuk memperbaiki
program dan koding yang saya buat agar berhasil dijalankan tanpa ada masalah.
2. Ketika saya akan mengupload program hasil compile (file hex) ke mikrokontroler
menggunakan software Progisp terkadang muncul pesan “Chip Enable Program Error”.
Hal ini disebabkan oleh jumper yang saya gunakan goyang atau USBISP tidak tercolok
dengan benar.
3. Ketika saya menekan switch 1 untuk menjalankan program, output LED-nya masih tidak
menyala. Ternyata hal ini disebabkan oleh pengaturan properties setting baudrate pada
MSComm pada Visual Basic tidak sesuai dengan koding di BASCOM 8051.