Shop OBEX P1 Docs P2 Docs Learn Events
Plotting graph On vb net — Parallax Forums

Plotting graph On vb net

ajit.nayak87ajit.nayak87 Posts: 76
edited 2014-09-23 05:55 in General Discussion
Dear all,

I am new to vb net. I am collecting data from Arduino and dispalyed on VB net through serial communication. Now i wanted to plot graph for time vs serial data received. Can some one suggest me how can do this. How to choose chart. Is there any example code .I have written code up to receive data and display it.Now i wanted to plot graph time Vs current value
Imports System
Imports System.IO.Ports
Imports System.ComponentModel
Imports System.Threading


Imports System.Drawing


Public Class Form1
    Dim myPort As Array
    Dim Distance As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        myPort = IO.Ports.SerialPort.GetPortNames()
        PortComboBox.Items.AddRange(myPort)
        BaudComboBox.Items.Add(9600)
        BaudComboBox.Items.Add(19200)
        BaudComboBox.Items.Add(38400)
        BaudComboBox.Items.Add(57600)
        BaudComboBox.Items.Add(115200)
        ConnectButton.Enabled = True
        DisconnectButton.Enabled = False


    End Sub


    Private Sub ConnectButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConnectButton.Click
        SerialPort1.PortName = PortComboBox.Text
        SerialPort1.BaudRate = BaudComboBox.Text
        SerialPort1.Open()
        Timer1.Start()


        'lblMessage.Text = PortComboBox.Text & " Connected."
        ConnectButton.Enabled = False
        DisconnectButton.Enabled = True
    End Sub


    Private Sub DisconnectButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisconnectButton.Click
        SerialPort1.Close()


        DisconnectButton.Enabled = False
        ConnectButton.Enabled = True
    End Sub


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Try
            SerialPort1.Write("c")
            System.Threading.Thread.Sleep(250)
            Dim k As Double
            Dim distance As String = SerialPort1.ReadLine()
            k = CDbl(distance)
            ListBoxSensor.Text = k
        Catch ex As Exception


        End Try






    End Sub


    Private Sub Relay_ON_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Relay_ON.Click
        SerialPort1.Write("1")
    End Sub


    Private Sub Relay_Off_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Relay_Off.Click
        SerialPort1.Write("0")
    End Sub








End Class


Sign In or Register to comment.