As the subject, I think that's what I want to do. Well, what I want to do is convert 9 bytes (from serial) to 'real' numbers to move a servo (in degrees) like this :-
W239 048 is the sort of 9 bytes, what I'm trying to do is extract the 239 and 048 to send to two servos (to azimuth and elevation) but can't think how to do it ! :-[
Thanks, sounds good. I'm trying to make two servos 'track' the moon for example using software called Orbitron - it has a plug-in to control a ham radio az-el rotor and can output in the form WAAA EEE - AAA being the azimuth and EEE the elevation in degrees. Then I could send it to, two servos and also a bit of code to get over the 180 degree limit of servos
If (az=>180)
{tilt=180-el} ;
{dir=az-180};
'Tilt' and 'dir' are to be sent to the servos and az and el from the coversion from WAAA EEE
The following is an excerpt from a program to interface with an RS232 controlled instrument, which returned a string, of which the numerical data was extracted to be passed to a D2A function:
char SERIALDATA[50]
Serial.println("MEAS POW L1 D2?"); //RS232 Query.
int i = 0; //loop integer.
int X = 0;
while (X != 58){
if (Serial.available() > 0) { //Check serial buffer for info.
X = Serial.read(); //Read byte from serial buffer.
SERIALDATA = X; //Store byte to string.
i++; //Go to next byte.*
}*
}*
long P1 = SERIALDATA[0]-48;*
long P2 = SERIALDATA[1]-48;*
long P3 = SERIALDATA[2]-48;*
long P4 = SERIALDATA[4]-48;*
long P5 = SERIALDATA[5]-48;*
_ long POWER = 10000P1+1000P2+100P3+10P4+P5;_
return POWER;* Essentially it just reads each ascii character as its byte reference and then subtracts 48 to get the actual number. The numbers then need to be recombined.