Mendeteksi Port Serial Dengan Visual Basic 2010
on January 15, 2013 at 11:47 AMPort Serial adalah salah satu kelengkapan yang sampai sekarang masih ada pada sebuah PC. Port serial biasanya digunakan untuk menghubungkan sebuah device dengan PC. Walaupun kehadiran USB semakin mendominasi standar komunikasi antar device, namun komunikasi serial masih sangat familiar.
Dengan memahami komunikasi serial, kita akang dapat melakukan banyak hal, khususnya bagi engineer atau bagi hobbiest elektronika.
Penggunaan laptop saat ini juga cenderung mendominasi baik bagi kalangan praktisi elektronika maupun mahasiswa. Sehingga kehadiran port serial pada sebuah laptop sangatlah penting. Disisi lain, laptop yang dirilis saat ini tidak ada yang menyertakan port serial sebagai sebuah device komunikasi. Untuk mengatasi ini, dipasaran banyak dijual aksesoris USB to Serial yang harganya bervariasi dan relatif terjangkau.
Dengan aksesoris USB to Serial, Anda dapat menghadirkan port serial virtual pada laptop atau PC yang sebelumnya tidak ada. Bisa juga digunakan untuk menambah kebutuhan port serial. Untuk mengetahui keberadaan port serial pada sebuah komputer, kita bisa melakukan pengecekan melalui langkah berikut:
1. Klik kanan pada My Computer, pilih Manage
2.Pilih Computer Management–> System Tools–> Device Manager. Lihat pada group Ports (COM & LPT)
Pada contoh di atas, PC memiliki satu port serial onboard dan satu virtual serial port dengan ID chip Prolific.
Sekarang, bagaimana cara mendeteksi port serial secara otomatis menggunakan Visual Basic 2010?
Pada sesi ini diberikan contoh menggunakan VB 2010, namun saya sudah mencoba dan dapat diterapkan juga pada VB 2008.
Buat project seperti berikut:
1. Pilih New Project
2. Buat form berikut
3.Isikan coding berikut:
– Tambahkan komponen Serial Port dari group Components
– Pada Button1 (button Close)
[sourcecode]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Ingin As MsgBoxResult
Ingin = MsgBox("Apakah Anda akan keluar?", MsgBoxStyle.YesNo, "Keluar")
If Ingin = MsgBoxResult.Yes Then
Me.Close()
ElseIf Ingin = MsgBoxResult.No Then
Exit Sub
End If
End Sub
[/sourcecode]
– Pada button Disconnect
[sourcecode]
Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click
‘tutup koneksi Serial port, jika berhasil tampilkan indikator
Try
SerialPort1.Close()
btnConnect.Enabled = True
btnDisconnect.Enabled = False
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
[/sourcecode]
– Pada button Connect
[sourcecode]
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
‘cek, jika status serial port open, tutp koneksi serial port
If SerialPort1.IsOpen Then
SerialPort1.Close()
End If
‘atur properti serial port
Try
With SerialPort1
.PortName = cbbCOMPorts.Text
.BaudRate = 115200
.ReadBufferSize = 500
.Parity = IO.Ports.Parity.None
.DataBits = 8
.StopBits = IO.Ports.StopBits.One
.Handshake = IO.Ports.Handshake.None
End With
‘open koneksi serial port
SerialPort1.Open()
btnConnect.Enabled = False
btnDisconnect.Enabled = True
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
[/sourcecode]
– Pada Form1_load
[sourcecode]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
‘cek available serial port pada komputer
‘termasuk serial modem
For i As Integer = 0 To _
My.Computer.Ports.SerialPortNames.Count – 1
‘tambahkan ke dalam list combo serial port
cbbCOMPorts.Items.Add( _
My.Computer.Ports.SerialPortNames(i))
Next
‘disable button disconnect
btnDisconnect.Enabled = False
End Sub
[/sourcecode]
Berikut adalah hasil programnya.
Demikian, semoga bermanfaat.
Discussion (46) ¬
Om,klw laptop punya port pararel tdk?
Setahu saya tidak punya. CMIIW
nah klo Ada masukan bit dari eksternal input ke port status ,cara baca/mendeteksi port status tersebut gimana?
Perbedaan port Data dan port Status adalah pada nomer register hardwarenya.
terimakasih mas infonya membantu π
kalau di VB, cara nampilin kamera tau ga mas?
coba cek posting saya di:
http://rohmadi.com/2012/09/14/menampilkan-webcam-pada-visual-basic-6-0/
gan ini kodingannya import fungsi apa aja??
clomid without iui buy clomid cheap can u buy clomid online when to take clomid during cycle
https://buytadalafil.men/# tadalafil 2.5 mg tablets india
furosemide 100mg lasix 100 mg tablet
https://buynolvadex.store/# tamoxifen cancer
cialis duree action cialis 10 mg peut on associer cialis et priligy ou acheter du cialis sur internet forum
erection pills ed treatment review
ΡΡΠ°Π±Π΅Π»Π΅Ρ ΡΠ»Π΅ΠΊΡΡΠΈΡΠ΅ΡΠΊΠΈΠΉ
https://www.elektroshtabeler-kupit.ru/
diflucan 6 tabs where to buy diflucan
buy clopidogrel 75mg without prescription – purchase clopidogrel pill order reglan 10mg online
https://gabapentin.icu/# neurontin cost generic
cheap erectile dysfunction non prescription ed pills
https://erectionpills.best/# ed pills for sale
neurontin 600 mg neurontin price south africa
Simply wanna comment on few general things, The website design is perfect, the subject material is really great. “In business school classrooms they construct wonderful models of a nonworld.” by Peter Drucker.
diflucan 150 tab diflucan 200 mg price south africa
https://withoutprescription.store/# buy prescription drugs online without
buy diflucan yeast infection diflucan prices canada
where can i buy cipro online purchase cipro
oral losartan 25mg – topiramate medication buy phenergan online cheap
https://diflucan.icu/# canadian order diflucan online
neurontin tablets 300 mg neurontin 300 mg tablet
ΡΡΠ°Π±Π΅Π»Π΅Ρ ΡΠ»Π΅ΠΊΡΡΠΈΡΠ΅ΡΠΊΠΈΠΉ ΡΠ°ΠΌΠΎΡ ΠΎΠ΄Π½ΡΠΉ
https://shtabeler-elektricheskiy-samokhodnyy.ru
kamagra 100 prix kamagra pas cher inde kamagra en france livraison rapide comment se procurer du kamagra pour homme
https://gabapentin.icu/# brand name neurontin price
neurontin 200 mg purchase neurontin
purchase neurontin canada neurontin 600 mg cost
https://withoutprescription.store/# ed prescription drugs
neurontin 100 mg caps buy neurontin online no prescription
male ed drugs male erection pills
https://diflucan.icu/# can i buy diflucan over the counter in australia
cipro for sale ciprofloxacin over the counter
neurontin 100 mg cap neurontin cost
https://cipro.best/# buy cipro online without prescription
stromectol stromectol for lice
gnc ed pills ed drug prices
https://withoutprescription.store/# canadian drug pharmacy
buy prescription drugs online ed meds online canada
brand levofloxacin 250mg – canadian viagra cialis for sale
buy neurontin online neurontin price south africa
I savour, lead to I found just what I used to be taking a look for. You have ended my 4 day lengthy hunt! God Bless you man. Have a great day. Bye
without downloads
igt slots downloads
play slots for real money
diflucan 150 mg price diflucan cost
https://withoutprescription.store/# meds online without doctor prescription
cipro online no prescription in the usa cipro 500mg best prices
buy cipro cheap buy cipro online
https://diflucan.icu/# how much is diflucan
prescription price for neurontin neurontin 600mg
https://gabapentin.icu/# neurontin 800 pill
buy anti biotics without prescription buy prescription drugs from canada cheap
rogaine or propecia propecia cost in india long term propecia side effects what is propecia for
furosemide toxicity lasix 40mg what are the side effects of furosemide why do you give furosemide to someone in cardiogenic shock
ciprofloxacin mail online ciprofloxacin 500 mg tablet price