public LEDUserControl1()
        {
            InitializeComponent();
           
            //a simple latching method to ensure the mouse button is released before sending data to comm port.
            trackBar1.MouseDown += (s,
                        e) =>
            {
                clicked = true;
            };
            trackBar1.MouseUp += (s,
                                    e) =>
            {
                if (!clicked)
                    return;

                clicked = false;
                Console.WriteLine("Mouse up"+trackBar1.Value);
                if(this.checkBox1.Checked)
                    this.PWMValue=(byte)(255-trackBar1.Value);
            };
            comm = new Comms();
            comm.ScanPorts();
            try
            {
                comm.OpenArduinoConnection();
                this.checkBox1.Checked = true;
            }
            catch
            {
                this.checkBox1.Checked = false;
                this.trackBar1.Enabled = false;
            }
        }
        public LEDUserControl1()
        {
            InitializeComponent();
           /* trackBar1.Scroll += (s, e) =>
                {
                    if (clicked)
                        return;
                    Console.WriteLine("Scroll "+trackBar1.Value);
                };*/
            trackBar1.MouseDown += (s,
                        e) =>
            {
                clicked = true;
            };
            trackBar1.MouseUp += (s,
                                    e) =>
            {
                if (!clicked)
                    return;

                clicked = false;
                Console.WriteLine("Mouse up"+trackBar1.Value);
                this.PWMValue=(byte)trackBar1.Value;
            };
            comm = new Comms();
            comm.ScanPorts();
            try
            {
                comm.OpenArduinoConnection();
                this.checkBox1.Checked = true;
            }
            catch
            {
                this.checkBox1.Checked = false;
            }
        }