Advertisement
Guest User

Untitled

a guest
May 24th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. public Form1()
  2.         {
  3.             InitializeComponent();
  4.             SerialPort1 = new SerialPort();
  5.             SerialPort1.PortName = "COM3";
  6.             SerialPort1.BaudRate = 9600;
  7.             btnLigaLED.BackColor = Color.White;
  8.             btnDesligaLED.BackColor = Color.White;
  9.         }
  10.  
  11.         private void BtnLigaLED_Click(object sender, EventArgs e)
  12.         {
  13.             SerialPort1.Open();
  14.             if (SerialPort1.IsOpen)
  15.             {
  16.                 SerialPort1.WriteLine("1");
  17.             }
  18.             SerialPort1.Close();
  19.             btnLigaLED.BackColor = Color.Aqua;
  20.             btnDesligaLED.BackColor = Color.White;
  21.         }
  22.  
  23.         private void BtnDesligaLED_Click(object sender, EventArgs e)
  24.         {
  25.             SerialPort1.Open();
  26.             if (SerialPort1.IsOpen)
  27.             {
  28.                 SerialPort1.WriteLine("0");
  29.             }
  30.             SerialPort1.Close();
  31.             btnDesligaLED.BackColor = Color.Aqua;
  32.             btnLigaLED.BackColor = Color.White;
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement