VB Lesson: Serial Port

May 6th, 2011  Posted at   Lesson PIC, Lesson VB

Serial Port membolehkan software di dalam komputer berhubung dengan hardware lain di luar. Misalnya menghubungkan Visual Basic dengan hardware PIC.

Melalui serial port, Visual Basic boleh mengawal alatan lain ataupun memaparkan bacaan daripada alatan lain. Software Visual Basic boleh menghasilkan sistem SCADA (Supervisory Control And Data Acquisition).

Berikut adalah videonya.

PIC Source Code

VB Source Code

56 Responses to “VB Lesson: Serial Port”

  1. hilmi says:

    salam,saya nak tanya , macam mana nak link kan xbee dengan vb 2010.

  2. kamal says:

    salam.. sy ad sikit maslah, kalo tak keberatan, sy nk minta tunjuk ajar saudara utk memberi sedikit input or info cmne sy nk link kan rfid sy dgn vb especially vb.net..dgn ayat yg lebeh jelas,

    sy membuat satu projek yg mana melibatkan database, masalah sy, sy tdak tahu bagaimana nk hubungkan rfid sy dgn database sy.

    harap encik/saudara/bos boleh membantu sy yg memerlukan ini,, terima kasih

  3. Akmal says:

    Salam, sy nk tanya, dlm PIC tu perlu ke kite declare lib dia? sbb sy menggunakan SK40C dr cytron?

    • Shahrul says:

      w/salam, Akmal. Library bergantung kpd coding, kalau coding semua dlm main file tak perlu declare library. Kalau ada function dlm file library, kena declare library.

  4. wan says:

    apa function timer1? cthnya kt line 13 & 28..x perlu declare ke?

  5. Dejan says:

    How much does it cost?
    WHat about other codes you have, for example dht11, current sensor??
    I would like to have a price list if possible. Have a project which implements many stuff from your web site.

  6. okay says:

    how to download this vb source code….?? thankq~~

  7. Nor says:

    Salam, saya ada dua soalan:

    1) untuk function “uart_number(adc,10,4)”, en. cuba send value adc ke vb kan? so, character
    10 dgn 4 tu untuk apa?

    2) function ni kira apa? kenapa kena tolak 48?

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    SerialPort1.Write(“S” & HScrollBar1.Value & “.”)
    If SerialPort1.BytesToRead = 4 Then
    j = 0
    For Me.i = 1 To 4
    Rx(j) = SerialPort1.ReadByte
    j = j + 1
    Next
    End If

    ADC = Val((Rx(0) – 48) & (Rx(1) – 48) & (Rx(2) – 48) & (Rx(3) – 48))
    If ADC >= 0 And ADC <= 1023 Then
    HScrollBar2.Value = ADC
    Label2.Text = HScrollBar2.Value
    End If
    End Sub

    Terima Kasih :)

    • Shahrul says:

      W/salam, Nor.
      1) 10 tu untuk nombor decimal, 4 tu untuk bilangan digit
      2) Tolak 48 untuk tukar nombor ASCII kpd integer. Nombor 0 bersamaan 0x30 (48) ASCII.

  8. ikram says:

    program vb dgn pic kt atas tu complete program ke?

  9. husna says:

    salam… nak tny, kalau utk buat vb(input) —>> arduino xbee (output) utk bce data yg diletakkan dalam vb, kena buat serial port mcm ni jgak ke?? boleh bg info??

Leave a Reply to wan

What is 14 + 14 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)