Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. C# Button Click for UART COM

C# Button Click for UART COM

Scheduled Pinned Locked Moved COM
csharpcomhardwareworkspace
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John EE
    wrote on last edited by
    #1

    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. This will have to be sent out through TxD. 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

    #region Buttons

        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\];
            } 
        }
    
    _ 1 Reply Last reply
    0
    • J John EE

      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. This will have to be sent out through TxD. 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

      #region Buttons

          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\];
              } 
          }
      
      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      You're in the wrong forum. COM here stands for Component Object Model and not serial port.

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups