1.
Buatlah hardwarenya dengan 12 buah led dimana 8 led pertama sambungkan
dengan pin data (2-9) dan 4 led trakhir sambungkan dengan pin control
(1,14,16,17) jangan lupa tambahkan resistor dan penyambungan system
katoda.
2.
Buat project baru kemudian tambahkan 12 shape untuk simulasi lednya, 1
label untuk judul kemudian 5 commandbutton dan 4 buah timer.
3. Kemudian desain lah menjadi seperti gambar berikut :
4.
Atur properties masing-masing komponen seperti untuk shape backstyle
ubah menjadi 1-opaque kemudian backcolornya pilih warna putih kemudian
unutk timer semua interval beri nilai 100 dan dalam keadaan false.
5. Save project dan Form di folder yang sama lalu copykan inpout32.dll pada folder tempat penyimpanan tersebut.
6. Masukkan kode program seperti dibawah ini :
Private Declare Function Inp Lib "inpout32.dll" _
Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Private Declare Sub Out Lib "inpout32.dll" _
Alias "Out32" (ByVal PortAddress As Integer, ByVal value As Integer)
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Out 888, 255
Out 890, 4
Shape1.BackColor = vbRed
Shape2.BackColor = vbRed
Shape3.BackColor = vbRed
Shape4.BackColor = vbRed
Shape5.BackColor = vbRed
Shape6.BackColor = vbRed
Shape7.BackColor = vbRed
Shape8.BackColor = vbRed
Shape9.BackColor = vbRed
Shape10.BackColor = vbRed
Shape11.BackColor = vbRed
Shape12.BackColor = vbRed
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
End Sub
Private Sub Command2_Click()
Out 888, 0
Out 890, 11
Shape1.BackColor = vbWhite
Shape2.BackColor = vbWhite
Shape3.BackColor = vbWhite
Shape4.BackColor = vbWhite
Shape5.BackColor = vbWhite
Shape6.BackColor = vbWhite
Shape7.BackColor = vbWhite
Shape8.BackColor = vbWhite
Shape9.BackColor = vbWhite
Shape10.BackColor = vbWhite
Shape11.BackColor = vbWhite
Shape12.BackColor = vbWhite
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
End Sub
Private Sub Command3_Click()
Timer1.Enabled = True
Timer2.Enabled = True
Command1.Enabled = False
Command2.Enabled = False
Command4.Enabled = False
Command5.Enabled = True
End Sub
Private Sub Command4_Click()
Timer4.Enabled = True
Timer3.Enabled = True
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command5.Enabled = True
End Sub
Private Sub Command5_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
Out 888, 0
Out 889, 11
Shape1.BackColor = vbWhite
Shape2.BackColor = vbWhite
Shape3.BackColor = vbWhite
Shape4.BackColor = vbWhite
Shape5.BackColor = vbWhite
Shape6.BackColor = vbWhite
Shape7.BackColor = vbWhite
Shape8.BackColor = vbWhite
Shape9.BackColor = vbWhite
Shape10.BackColor = vbWhite
Shape11.BackColor = vbWhite
Shape12.BackColor = vbWhite
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
End Sub
Private Sub Form_Load()
End Sub
Private Sub Timer2_Timer()
Dim a As Integer
a = Timer1.Interval
Timer1.Interval = a + 100
Select Case a
Case 100
Out 890, 11
Out 888, 1
Shape12.BackColor = vbWhite
Shape1.BackColor = vbRed
Case 200
Out 888, 2
Shape1.BackColor = vbWhite
Shape2.BackColor = vbRed
Case 300
Out 888, 4
Shape2.BackColor = vbWhite
Shape3.BackColor = vbRed
Case 400
Out 888, 8
Shape3.BackColor = vbWhite
Shape4.BackColor = vbRed
Case 500
Out 888, 16
Shape4.BackColor = vbWhite
Shape5.BackColor = vbRed
Case 600
Out 888, 32
Shape5.BackColor = vbWhite
Shape6.BackColor = vbRed
Case 700
Out 888, 64
Shape6.BackColor = vbWhite
Shape7.BackColor = vbRed
Case 800
Out 888, 128
Shape7.BackColor = vbWhite
Shape8.BackColor = vbRed
Case 900
Out 888, 0
Out 890, 10
Shape8.BackColor = vbWhite
Shape9.BackColor = vbRed
Case 1000
Out 888, 9
Shape9.BackColor = vbWhite
Shape10.BackColor = vbRed
Case 1100
Out 888, 15
Shape10.BackColor = vbWhite
Shape11.BackColor = vbRed
Case 1200
Out 888, 3
Shape11.BackColor = vbWhite
Shape12.BackColor = vbRed
Timer1.Interval = 100
End Select
End Sub
Private Sub Timer3_Timer()
Dim b As Integer
b = Timer4.Interval
Timer4.Interval = b + 100
Select Case b
Case 100
Out 888, 96
Shape1.BackColor = vbWhite
Shape12.BackColor = vbWhite
Shape6.BackColor = vbRed
Shape7.BackColor = vbRed
Case 200
Out 888, 144
Shape6.BackColor = vbWhite
Shape7.BackColor = vbWhite
Shape5.BackColor = vbRed
Shape8.BackColor = vbRed
Case 300
Out 888, 8
Out 890, 10
Shape5.BackColor = vbWhite
Shape8.BackColor = vbWhite
Shape4.BackColor = vbRed
Shape9.BackColor = vbRed
Case 400
Out 888, 4
Out 890, 9
Shape4.BackColor = vbWhite
Shape9.BackColor = vbWhite
Shape3.BackColor = vbRed
Shape10.BackColor = vbRed
Case 500
Out 888, 2
Out 890, 15
Shape3.BackColor = vbWhite
Shape10.BackColor = vbWhite
Shape2.BackColor = vbRed
Shape11.BackColor = vbRed
Case 600
Out 888, 1
Out 890, 3
Shape2.BackColor = vbWhite
Shape11.BackColor = vbWhite
Shape1.BackColor = vbRed
Shape12.BackColor = vbRed
Timer4.Interval = 100
End Select
End Sub
7. Sekarang silahkan run dan contoh hasilnya dapat anda lihat di video dibawah ini.
http://youtu.be/YkzAkib60po
Tidak ada komentar:
Posting Komentar