Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to pass a value '89' in pololu serial transmitter as bytes..That means if i send '89' to pololu.it receive '89' itself.How can i done this?
C#
private void button2_Click(object sender, EventArgs e)
       {

           byte b = byte.Parse(textBox1.Text);
           serialPort1.Write("r"+b);
       }
Posted
Updated 27-Aug-14 1:03am
v3
Comments
Nelek 27-Aug-14 6:06am    
Have you check the specifications of the manufacturer? They should have information about it
Member 10994712 27-Aug-14 6:09am    
I tried this code
byte b = byte.Parse(textBox1.Text);
serialPort1.Write(new byte[] {b }, 0, 1);
but now am getting hex value of 89..i need 89 itself

1 solution

You can easily send a byte value by setting it into a variable as :
C#
private void button2_Click(object sender, EventArgs e)
{
    byte b = 89; // for a decimal value
    byte bh = 0x89; // for a hexadecimal value

    serialPort1.Write("r"+b); // not sure why the "r" is there
}

If the data from your textbox is not being parsed correctly then you should expalin what the error is.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900