From: Matjaz on
I'm having problems with serial communication between simulink and arduino. I am trying to read joystick input and send it to arduino. I chose simulink becouse it's simple to read joystick input, it only takes one block. I could do using c++ program, but my knowledge in c isn't nearly good enough.

So, in Simulink, I can easily read values from joystick and send it to serial port. The problem is, that the joystick block returns a float from -1 to 1, so it sends multiple bytes per axis to arduino, depending on sample time. I only need two axis from joystick, and I want to encode these values and send a single byte to arduino. First axis would represent the four MSBs and the second axis the four LSBs. In other words, I want to quantize the values with 4 bites, and "join" both axis values in a single byte. How do I do this? Hope you understand what I'm trying to achieve.

ty
From: Matjaz on
I just wanna simplify my question, obviously the original post is confusing :)

OK, here we go:
I have a uint8 variable X, if I send it over serial port, it sends a byte for each digit of this int. For example, if X==3, one byte will be sent, that is an ASCII code for '3'. If X==33, two ASCII bytes '3' will be sent and so on...

What I want is that this int X is sent as a signle ASCII char (a single byte). How?