Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8656451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:16:42+00:00 2026-06-12T15:16:42+00:00

I am trying to send a single byte to a PIC from a computer

  • 0

I am trying to send a single byte to a PIC from a computer (Note: the pic only accepts a single byte else it will only accept the first byte of the data send)

This shouldn’t be much of a problem because I only want to manage a total of 8 LEDS so I only need it to go from 0 to 255 but I am having issues achieving this.
If I try to send the value 1 to the pic my program sends 31 if I try to send 5 it sends 35 If I try to send 255 it sends 3*2*3*5*3*5* so for every single digit I try to send it adds a 3 in front of it. I am using the following code to determine the value and to send it:

        Dim t As Integer = 0
    Dim result As Integer = 0
    For Each chk As CheckBox In GroupBox1.Controls
        If chk.Checked = True Then
            result = result + 2 ^ t
        End If
        t = t + 1
    Next
    publisher.Connect(IPTo, PortTo)
    Dim sendbytes() As Byte = ASCII.GetBytes(result)
    publisher.Send(sendbytes, sendbytes.Length)

I think the issue is with the convert to ASCII.

I also try to receive the inputs from the PIC to my pc for this I have the following script inside a timer:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Try
            Dim ep As IPEndPoint = New IPEndPoint(IPAddress.Any, 0)
            Dim rcvbytes() As Byte = subscriber.Receive(ep)

            Dim translate As String
            translate = System.BitConverter.ToInt32(rcvbytes, 0)

            TBRcv.Text = translate
        Catch ex As Exception
        End Try
    End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:16:43+00:00Added an answer on June 12, 2026 at 3:16 pm

    ASCII.GetBytes expects a string (encoded in ASCII). Giving it an Int32 doesn’t make sense.

    Check out System.BitConverter.GetBytes() and System.BitConverter.ToInt32() (for the receiving end)

    So the only change you’d need to make is:

    Dim sendbytes() As Byte = BitConverter.GetBytes(result) 
    

    Further discussion:
    What has happened is that your result (let’s say 5), is first converted to string (now it’s “5”), then ASCII.GetBytes will now return a byte array with a single value 0x35, because Asc(“5”) is 0x35.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send data as a model from an html form to
I'm trying to send a single image from my iPhone app to my Google
i am trying to know the data is getting loaded in single byte or
I am trying to create a single column picker whose data is derived from
I`m trying to send simple html page with form data to user with GET,
I am trying to send emails from smtps (secure smtp) using Indy and the
I'm trying to center a google map on a single marker pulled from a
I am trying to send a serialized Java object from a client to a
I'm trying to use broadcasters to send messages from a child thread to the
I'm trying to send and receive a byte stream in which certain ranges of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.