We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpElectronics,  Serial Library › convert number to low/high byte (hex) for serial
Page Index Toggle Pages: 1
convert number to low/high byte (hex) for serial (Read 1738 times)
convert number to low/high byte (hex) for serial
Dec 2nd, 2008, 3:16am
 
hi, I'm having difficulties while talking to a servo controller via serial connection:
everything works fine as far as understanding the protocoll and adressing single servos with a specific position, but to move the servos interactively I need to take the position of e.g. a slider and convert it to a hex-number which then needs to be send out as "low byte" and "high byte".
Could anybody please help me with the conversion and the seperation of the hex number into the two parts?!

would be so great and thanks alot
Re: convert number to low/high byte (hex) for seri
Reply #1 - Dec 7th, 2008, 12:32pm
 
Basically, when I need to send 4 byte integer to serial port I do something like that:
   myPort.write(val>>24);
   myPort.write(val>>16);
   myPort.write(val>>8);
   myPort.write(val);

Page Index Toggle Pages: 1