-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisualStudioCode.cs
More file actions
41 lines (34 loc) · 1.12 KB
/
VisualStudioCode.cs
File metadata and controls
41 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ArduinoSerialIn
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
serialPort1.BaudRate = 9600;
serialPort1.PortName = "COM3";
serialPort1.Open();
serialPort1.DataReceived += serialPort1_DataReceived;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
string line = serialPort1.ReadLine();
this.BeginInvoke(new LineReceivedEvent(LineReceived), line);
}
private delegate void LineReceivedEvent(string line);
private void LineReceived(string line)
{
label1.Text = line; // place where the values from Serial.Monitor (Arduino) are displayed.
}
}
}