User manual

is then available for other programs again, such as the Ar-
duino™-IDE. If you want to transfer any program changes or other
programs to your Arduino-board, you need to terminate the
program first or click Disconnect to release the interface again.
001 Private Sub SerialPort1_DataReceived(sender As Object
, e As System.IO.Ports.SerialDataReceivedEventArgs)
Handles SerialPort1.DataReceived
002
003 Dim cnt As Byte
004 Dim in_bytes As Byte
005 Dim HighByte As Byte
006 Dim LowByte As Byte
007 Dim crc As Byte
008 Dim crc_ok As Byte
009 Dim data_Word As Integer
010 Dim voltage As Single
011
012 Try
013
014 ' This is where the data are received
015 If SerialPort1.IsOpen Then
016
017 Control.CheckForIllegalCrossThreadCalls
= False
018
019 ' How many Bytes are in the buffer
020 in_bytes = SerialPort1.BytesToRead
021
022 ' Collect all bytes
023 For cnt = 1 To (in_bytes)
024 input_data(cnt) = SerialPort1.ReadByte
025 Next
026
027 ' Empty buffer
028 SerialPort1.DiscardInBuffer()
029
030 HighByte = input_data(1)
031 LowByte = input_data(2)
032 crc = input_data(3)
033
034 ' Checksum
035 crc_ok = 170 Xor input_data(1) Xor input_
data(2)
036
037 If crc = crc_ok Then
038
039 ' High and Low Byte are