Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApplication3
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- byte cmd = 0x10;
- serialPort1.BaudRate = 9600;
- serialPort1.PortName = "COM1";
- serialPort1.Open();
- serialPort1.Write(new byte[] {cmd},0,1);
- }
- private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
- {
- MessageBox.Show("Prisli data");
- }
- private void Form1_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (serialPort1.IsOpen)
- {
- serialPort1.Close();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement