C# Button Click for UART
-
Ok I have setup a simple gui for uart. I am trying to light up 4 LEDS thru a MC. LED0 will be 0x01, LED 1, 2, 3 will be 2, 4, 8. Will this send out the appropriate command I am looking for. I have no way to test it until tomorrow because I do not have the hardware with me but was wondering if this would suffice. I do not get any errors or warnings so I am thinking it should. Thanks
private void buttonLED0_Click_1(object sender, EventArgs e)
{
Data = Data ^= 0x01;
int BytesToWrite = Data;
int bytes = serialPort1.BytesToWrite;
//UInt32 numBytesWritten = 1;
buttonLED0.Enabled = !buttonLED0.Enabled;if (buttonLED0.Enabled) { pictureBoxLED0.BackgroundImage = imageList1.Images\[(int)LEDColor.GreenOn\]; } if (!buttonLED0.Enabled) { pictureBoxLED0.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOn\]; } }
-
Ok I have setup a simple gui for uart. I am trying to light up 4 LEDS thru a MC. LED0 will be 0x01, LED 1, 2, 3 will be 2, 4, 8. Will this send out the appropriate command I am looking for. I have no way to test it until tomorrow because I do not have the hardware with me but was wondering if this would suffice. I do not get any errors or warnings so I am thinking it should. Thanks
private void buttonLED0_Click_1(object sender, EventArgs e)
{
Data = Data ^= 0x01;
int BytesToWrite = Data;
int bytes = serialPort1.BytesToWrite;
//UInt32 numBytesWritten = 1;
buttonLED0.Enabled = !buttonLED0.Enabled;if (buttonLED0.Enabled) { pictureBoxLED0.BackgroundImage = imageList1.Images\[(int)LEDColor.GreenOn\]; } if (!buttonLED0.Enabled) { pictureBoxLED0.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOn\]; } }
-
Ok I have setup a simple gui for uart. I am trying to light up 4 LEDS thru a MC. LED0 will be 0x01, LED 1, 2, 3 will be 2, 4, 8. Will this send out the appropriate command I am looking for. I have no way to test it until tomorrow because I do not have the hardware with me but was wondering if this would suffice. I do not get any errors or warnings so I am thinking it should. Thanks
private void buttonLED0_Click_1(object sender, EventArgs e)
{
Data = Data ^= 0x01;
int BytesToWrite = Data;
int bytes = serialPort1.BytesToWrite;
//UInt32 numBytesWritten = 1;
buttonLED0.Enabled = !buttonLED0.Enabled;if (buttonLED0.Enabled) { pictureBoxLED0.BackgroundImage = imageList1.Images\[(int)LEDColor.GreenOn\]; } if (!buttonLED0.Enabled) { pictureBoxLED0.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOn\]; } }
John-EE wrote:
I do not get any errors or warnings so I am thinking it should.
It would be nice if not getting compile time errors or warnings meant that something would work. The code you provided here doesn't look like it'll send anything out of the serial port. If it did, it would use the SerialPort.Write method. Take a look at msdn for details and examples.
Standards are great! Everybody should have one!
-
Ok I have setup a simple gui for uart. I am trying to light up 4 LEDS thru a MC. LED0 will be 0x01, LED 1, 2, 3 will be 2, 4, 8. Will this send out the appropriate command I am looking for. I have no way to test it until tomorrow because I do not have the hardware with me but was wondering if this would suffice. I do not get any errors or warnings so I am thinking it should. Thanks
private void buttonLED0_Click_1(object sender, EventArgs e)
{
Data = Data ^= 0x01;
int BytesToWrite = Data;
int bytes = serialPort1.BytesToWrite;
//UInt32 numBytesWritten = 1;
buttonLED0.Enabled = !buttonLED0.Enabled;if (buttonLED0.Enabled) { pictureBoxLED0.BackgroundImage = imageList1.Images\[(int)LEDColor.GreenOn\]; } if (!buttonLED0.Enabled) { pictureBoxLED0.BackgroundImage = imageList1.Images\[(int)LEDColor.RedOn\]; } }
-
I don't really know what the rest is about, but this is definitely odd:
John-EE wrote:
Data = Data ^= 0x01;
This will only do something other than the more usual
Data ^= 1
ifData
is a property with side effectsharold aptroot wrote:
if Data is a property with side effects
...which we are all really hoping it isn't. :laugh:
If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.