Вы находитесь на странице: 1из 2

Imports System

Imports System.IO.Ports
Public Class Form1
Dim txt As String
Dim caracter As Char
Dim entero As Double
Dim leer As Double
Dim x As Double
Dim y As Double
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handl
es MyBase.Load
Try
With AxNTGraph1
.PlotAreaColor = Color.White
.Caption = "Fotopletismografo"
.XLabel = "Tiempo"
.YLabel = "Amplitud"
.ClearGraph()
.SetRange(0, 80, 0, 600)
End With
With SerialPort1
.PortName = TextBox1.Text.ToUpperInvariant
.BaudRate = 9600
.Parity = IO.Ports.Parity.None
.DataBits = 8
.StopBits = IO.Ports.StopBits.One
.ReceivedBytesThreshold = 1
End With
If SerialPort1.IsOpen Then
SerialPort1.Open()
Call recibe()
Else
SerialPort1.Close()
End If
Catch ex As Exception
MsgBox("Error!!" & vbCrLf & ex.Message)
End Try
End Sub
Private Sub recibe()
Try
leer = CStr(SerialPort1.BytesToRead)
If (SerialPort1.BreakState <> 0) Then
entero = SerialPort1.ReadChar
If entero <> 10 Then
Timer1.Enabled = True
caracter = Chr(entero) 'Eje y (Voltaje)'
y = Convert.ToDouble(caracter)
x = Timer1.Enabled 'Eje x (tiempo)'
AxNTGraph1.PlotXY(x, y, 0)
End If
End If
Catch ex As Exception
MsgBox("Error!! " & vbCrLf & ex.Message)
End Try
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Hand

les Timer1.Tick
End Sub
End Class

Вам также может понравиться