aah, yes, i've changed that to this:
// RECIEVER
byte incomingByte, sensor1, sensor2,sensor3;
void setup() {
// start serial port at 19200 bps
Serial.begin(19200);
Serial.println("Ready!");
// led pins
//pinMode (5, OUTPUT);
//pinMode (5, OUTPUT);
//pinMode (6, OUTPUT);
delay(1000);
delay(100);
}
void loop() {
if (Serial.available()) { // are there any bytes available on the serial port ???
// assign bytes to the var [ch65533]incomingByte[ch65533]
incomingByte = Serial.read();
Serial.print(int(incomingByte));
// from now on is pretty clear I guess :)
if ((int(incomingByte) == 253)) {
sensor1 = Serial.read();
}
if ((int(incomingByte) == 254)) {
sensor2 = Serial.read();
}
if ((int(incomingByte) == 255)) {
sensor3 = Serial.read();
}
Serial.print(int(sensor1));
Serial.print("\t");
Serial.print(int(sensor2));
Serial.print("\t");
Serial.print(int(sensor3));
Serial.print("\t");
Serial.println(" ");
}
//analogWrite (5, sensor1);
//analogWrite (6, sensor2);
//analogWrite (6, sensor3);
}
int analogValue0, analogValue1, analogValue2, val0,val1, val2;
const int xPin = 0; // x-axis of the accelerometer
const int yPin = 1; // y-axis
const int zPin = 2; // z-axis (only on 3-axis models)
void setup()
{
// start serial port at 19200 bps
Serial.begin(19200);
pinMode(xPin, INPUT);
pinMode(yPin, INPUT);
pinMode(zPin, INPUT);
}
void loop()
{
// read analog input
analogValue0 = analogRead(xPin);
analogValue1 = analogRead(yPin);
analogValue2 = analogRead(zPin);
val0 = map(analogValue0, 0, 1023, 252, 0); // 253, 254 and 255 for SYNC
val1 = map(analogValue1, 0, 1023, 252, 0);
val2 = map(analogValue2, 0, 1023, 252, 0);
// remap values
Serial.print(253, BYTE); //SYNC char
Serial.print(val0 , BYTE);
Serial.print(254, BYTE); //SYNC char
Serial.print(val1, BYTE);
Serial.print(255, BYTE); //SYNC char
Serial.print(val2, BYTE);
delay(150);
}
somehow it doesn't get the data correctly. I've used the xbee's out of the box. I've read that the standaard settings is enough for xbee's
but still no correct signal
i get this:
2540 152 0
2540 152 0
2300 152 0
1520 152 0
2540 134 0
2540 158 0
2540 152 0
2540 24 0
2540 255 0
2540 24 0
2540 255 0
2540 134 0
2540 158 0
2540 152 0
when i print within the if statement, i see that it sticks at sensor 1
help??