need suggest !

I'm keep asking but no one answer me

below there is my code which i use 3 sensors data (flex1,flex2,mpu6050) i'm trying to control a robotic arm i already sent the data using xbee and i receive it successfully but i can't use them as individual values

transmit code :

// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files // for both classes must be in the include path of your project

include "I2Cdev.h"

include "MPU6050.h"

// class default I2C address is 0x68 // specific I2C addresses may be passed as a parameter here // AD0 low = 0x68 (default for InvenSense evaluation board) // AD0 high = 0x69 MPU6050 accelgyro;

int16_t ax, ay, az; int16_t gx, gy, gz;

define LED_PIN 13

bool blinkState = false;

int f2 = A1; //analog pin 0 int f1=A0;

void setup(){ // join I2C bus (I2Cdev library doesn't do this automatically) Wire.begin();

// initialize serial communication // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but // it's really up to you depending on your project) Serial.begin(9600);

// initialize device Serial.println("Initializing I2C devices..."); accelgyro.initialize();

// verify connection Serial.println("Testing device connections..."); Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");

// configure Arduino LED for

}

void loop(){ accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); int flex1 = analogRead(f1); int flex2 = analogRead(f2); int flex11= map(flex1, 225, 279, 180, 0); int flex12 = map(flex2, 225, 279, 180, 0); int vro = map(ay, -16000, 16000, 0, 179); int vba=map(ax, -16000, 16000, 0, 179); flex11=constrain(flex11,0,180); flex12=constrain(flex12,0,180); vro=constrain(vro,0,180); vba=constrain(vba,0,180); // read raw accel/gyro measurements from device Serial.print(vba);Serial.print("\n"); Serial.print(vro);Serial.print("\n"); Serial.print(flex11);Serial.print("\n"); Serial.print(flex12);Serial.print("\n");

delay(100);

}


reciver code : void setup() { // put your setup code here, to run once: Serial.begin(9600); }

void loop() { // put your main code here, to run repeatedly: if (Serial.available()==1) { Serial.write(Serial.read()); } }

happyboss:
I’m keep asking but no one answer me

Starting several Threads about the same problem is not the way to make friends here.

Have you had any answers to your earlier questions? if so post a link to that Thread.

If you really have not had any answers then please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum Your code is too long for me to study quickly without copying to a text editor.

Also, please use the AutoFormat tool to indent your code consistently as that makes it much easier to read,

And then tell us exactly what the program does and what you want it to do that is different.

What do you mean by “i can’t use them as individual values”

…R

transmitter 
// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
// for both classes must be in the include path of your project
#include "I2Cdev.h"
#include "MPU6050.h"

// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for InvenSense evaluation board)
// AD0 high = 0x69
MPU6050 accelgyro;

int16_t ax, ay, az;
int16_t gx, gy, gz;

#define LED_PIN 13
bool blinkState = false;


int f2 = A1; //analog pin 0
int f1=A0;

void setup(){
    // join I2C bus (I2Cdev library doesn't do this automatically)
    Wire.begin();

    // initialize serial communication
    // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
    // it's really up to you depending on your project)
    Serial.begin(9600);

    // initialize device
    Serial.println("Initializing I2C devices...");
    accelgyro.initialize();

    // verify connection
    Serial.println("Testing device connections...");
    Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");

    // configure Arduino LED for

}

void loop(){
  accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
  int flex1 = analogRead(f1); 
 int flex2 = analogRead(f2); 
   int flex11= map(flex1, 225, 279, 180, 0);
  int flex12 = map(flex2, 225, 279, 180, 0);
  int vro = map(ay, -16000, 16000, 0, 179); 
int vba=map(ax, -16000, 16000, 0, 179);
 flex11=constrain(flex11,0,180);
 flex12=constrain(flex12,0,180);
 vro=constrain(vro,0,180);
 vba=constrain(vba,0,180);
 // read raw accel/gyro measurements from device
 Serial.print(vba);Serial.print("\n");
  Serial.print(vro);Serial.print("\n");
   Serial.print(flex11);Serial.print("\n");
    Serial.print(flex12);Serial.print("\n");


  


    delay(100);

}
//reciver
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
if (Serial.available()==1)
{
  Serial.write(Serial.read());
}
}

i need to control 4 servo motor but how can i make any of these sender values go to the wright value

Did you write this code?

Have you ever made one servo work? How did you do that? Just create four instances in the same way and send individual values to each one.

I'm by no means even considered a novice at this, but after going at an almost identical situation, I can say this You send no means to tell the receiver exactly "what" it is receiving. You should look at Robin2's sticky on Serial for beginning/end markers

Your receive side does exactly nothing to assign values to int's, which it wouldn't know what value is what anyhow. Getting the start/end markers lets the rx side know where the beginning of the string is, which also lets you assign each to an int and then do what you need to do

This is the link referred to in Reply #5 Serial Input Basics

...R