- Thu Feb 20, 2014 3:09 pm
#168670
Hello everyone,
Working with 2 Arduino Fio v3's as well as 2 Xbee S1's. I will be having 2 pot values coming in to Fio1 which will be sent to Fio2 to power a pair of servo's.
I can send over values just fine one at a time but if i lose the signal it messes up on me. I have just been playing with a basic code to change the led's on Fio2. I have spent a few hours looking around but i cant figure out how everyone is using delimited code and strings and all sorts of other fancy bytes.
The best way i can think of is to send over AxxxByyy from the TX and receive that on RX and break it apart and use xxx as pot value 1 and yyy as pot value 2. But i cant seem to send over AxxxByyy because its text and the only thing ive been able to send over so far is single characters and numerical values.
OR is there a way i can break apart a number by how many digits it is? and would that be a good way? so i would send over xxxyyy and break that 6 digit number into its 2 parts?
Any and all help is greatly appreciated as i'm lost again
So far for the TX i have:
int led = 13;
void setup() {
Serial1.begin(57600);
Serial.begin(57600);
pinMode(led,OUTPUT);
}
void loop() {
int high= 200;
int low = 100;
Serial1.write(high);
delay(1000);
Serial1.write(low);
delay(1000);
}
and for the RX
int led = 13;
void setup() {
Serial1.begin(57600);
Serial.begin(57600);
pinMode(led,OUTPUT);
}
void loop() {
while(Serial1.available() > 0) {
int power = Serial1.read();
analogWrite(13,power);
delay(50);
}
}
Working with 2 Arduino Fio v3's as well as 2 Xbee S1's. I will be having 2 pot values coming in to Fio1 which will be sent to Fio2 to power a pair of servo's.
I can send over values just fine one at a time but if i lose the signal it messes up on me. I have just been playing with a basic code to change the led's on Fio2. I have spent a few hours looking around but i cant figure out how everyone is using delimited code and strings and all sorts of other fancy bytes.
The best way i can think of is to send over AxxxByyy from the TX and receive that on RX and break it apart and use xxx as pot value 1 and yyy as pot value 2. But i cant seem to send over AxxxByyy because its text and the only thing ive been able to send over so far is single characters and numerical values.
OR is there a way i can break apart a number by how many digits it is? and would that be a good way? so i would send over xxxyyy and break that 6 digit number into its 2 parts?
Any and all help is greatly appreciated as i'm lost again
So far for the TX i have:
int led = 13;
void setup() {
Serial1.begin(57600);
Serial.begin(57600);
pinMode(led,OUTPUT);
}
void loop() {
int high= 200;
int low = 100;
Serial1.write(high);
delay(1000);
Serial1.write(low);
delay(1000);
}
and for the RX
int led = 13;
void setup() {
Serial1.begin(57600);
Serial.begin(57600);
pinMode(led,OUTPUT);
}
void loop() {
while(Serial1.available() > 0) {
int power = Serial1.read();
analogWrite(13,power);
delay(50);
}
}