Hex Command Set with Analogue Read-In

Hi, I am trying to program a wireless bluetooth connection with an i-racer. I have run into a problem and I can't find anything that is related to this kind of thing, or at least I can't see any. The problem is that I have an analogue read in for a throttle, but these hex values have a direction and a speed variable. I am wondering how I could use the analogue read in to change the hex value of the speed.

Here is the command set below:

Command Set

Those commands all look like a single byte with the upper four bits defining the direction and the lower 4 bits defining the speed.

I don't understand what you mean by:

use the analogue read in to change the hex value of the speed

If you mean how can you set the speed by using the result of an analogRead on the Arduino, that's not hard. The analogRead gives you 10 bits, but the command can only take 4, so you'll have to shift it off. Then you can OR the result with the direction code.

int x = analogRead(whateverPin);

int command = x >> 6;

command = command | 0x10;   // For forward.  OR in which ever direction command you need