Using parameters from two inputs inside one function

I'm trying to use value3 from the sliderSpinCallback function as a variable inside the sliderSpeedCallback function below it. Is there a way to do this? I tried declaring the value2 and value 3 as global variables at the beginning of the program but I guess that doesn't help because it is declared as a local variable inside the function. Any help appreciated.

void sliderBall_FeedCallback(unsigned int value1) {

  Ball_Feed = value1;

  /* Start your code (sliderBall_FeedCallback) */
  /* End your code */

  analogWrite(3,value1);
}

void sliderSpinCallback(unsigned int value3) {


  /* Start your code (sliderSpinCallback) */
  /* End your code */


}
void sliderSpeedCallback(unsigned int value2) {


  /* Start your code (sliderSpeedCallback) */
  /* End your code */

  analogWrite(5,value2);
  analogWrite(6,value3);
}

Here is the complete sketch:

#include <RBL_nRF8001.h>
#include <SPI.h>
#include <boards.h>
#include <IOSControllerBLE.h>
#include <EEPROM.h>

#define Ball_Feed_PIN      3
#define Speed_PIN     5
#define Spin_PIN      6
#define Sweep_PIN     4

/* Start your code (defines) */
/* End your code */

/*
 *
 * IOSController Library initialization
 *
 */

IOSControllerBLE iosController(&doWork,&doSync,&processIncomingMessages,&processOutgoingMessages,NULL,NULL);

/******* Start Global Variable for Widgets *******/

unsigned int Ball_Feed;
unsigned int Speed;
unsigned int Spin;
unsigned int value1;
unsigned int value2;
unsigned int value3;

/******* End Global Variable for Widgets *******/

void setup()
{  
  ble_begin();
  
  Serial.begin(115200);

  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
  pinMode(10,OUTPUT);
  digitalWrite(10,LOW);


  Ball_Feed = 0;
  pinMode(Ball_Feed_PIN,OUTPUT);
  analogWrite(Ball_Feed_PIN,Ball_Feed);

  Speed = 0;
  pinMode(Speed_PIN,OUTPUT);
  analogWrite(Speed_PIN,Speed);

  Spin = 0;
  pinMode(Spin_PIN,OUTPUT);
  analogWrite(Spin_PIN,Spin);
  pinMode(Sweep_PIN,OUTPUT);
  digitalWrite(Sweep_PIN,LOW);


  /* Start your code (setup) */
  /* End your code */
}

void loop() {  
  
  iosController.loop();
}

/**
*
*
* This function is called periodically and it is equivalent to the standard loop() function
*
*/
void doWork() {
  


  /* Start your code (doWork) */
  /* End your code */
}

/**
*
*
* This function is called when the ios device connects and needs to initialize the position of switches and knobs
*
*/
void doSync (char *variable) {


  if(strcmp(variable,"Ball Feed")==0) {

    sliderBall_FeedSyncCallback();
  }

  if(strcmp(variable,"Speed")==0) {

    sliderSpeedSyncCallback();
  }

  if(strcmp(variable,"Spin")==0) {

    sliderSpinSyncCallback();
  }

  if(strcmp(variable,"Sweep")==0) {

    switchSweepSyncCallback();
  }


  /* Start your code (doSync) */
  /* End your code */
}

/**
*
*
* This function is called when a new message is received from the iOS device
*
*/
void processIncomingMessages(char *variable, char *value) {


  if(strcmp(variable,"Ball Feed")==0) {

    sliderBall_FeedCallback(atoi(value));
  }

  if(strcmp(variable,"Speed")==0) {

    sliderSpeedCallback(atoi(value));
  }

  if(strcmp(variable,"Spin")==0) {

    sliderSpinCallback(atoi(value));
  }

  if(strcmp(variable,"Sweep")==0) {

    switchSweepCallback(atoi(value));
  }


  /* Start your code (processIncomingMessages) */
  /* End your code */
}

/**
*
*
* This function is called periodically and messages can be sent to the iOS device
*
*/
void processOutgoingMessages() {



  /* Start your code (processOutgoingMessages) */
  /* End your code */
}


/* Widgets synchronization callbacks */

void sliderBall_FeedSyncCallback() {

  /* Start your code (sliderBall_FeedSyncCallback) */

  //iosController.writeMessage("Ball Feed",Insert value here);

  /* End your code */

  iosController.writeMessage("Ball Feed",Ball_Feed);
}

void sliderSpeedSyncCallback() {

  /* Start your code (sliderSpeedSyncCallback) */

  //iosController.writeMessage("Speed",Insert value here);

  /* End your code */

  iosController.writeMessage("Speed",Speed);
}

void sliderSpinSyncCallback() {

  /* Start your code (sliderSpinSyncCallback) */

  //iosController.writeMessage("Spin",Insert value here);

  /* End your code */

  iosController.writeMessage("Spin",Spin);
}

void switchSweepSyncCallback() {

  /* Start your code (switchSweepSyncCallback) */

  //iosController.writeMessage("Sweep",Insert value here);

  /* End your code */

  iosController.writeMessage("Sweep",digitalRead(Sweep_PIN));
}


/* Widgets operations callbacks */

void sliderBall_FeedCallback(unsigned int value1) {

  Ball_Feed = value1;

  /* Start your code (sliderBall_FeedCallback) */
  /* End your code */

  analogWrite(3,value1);
}

void sliderSpinCallback(unsigned int value3) {


  /* Start your code (sliderSpinCallback) */
  /* End your code */


}
void sliderSpeedCallback(unsigned int value2) {


  /* Start your code (sliderSpeedCallback) */
  /* End your code */

  analogWrite(5,value2);
  analogWrite(6,value3);
}



void switchSweepCallback(boolean on) {

  /* Start your code (switchSweepCallback) */
  /* End your code */

  digitalWrite(Sweep_PIN,on);
}



/* Analog input preprocess functions */



/**** User Functions *****/

/* Start your code (User Functions) */
/* End your code */

Yes, but what library is this from? Is it some kind of hardware device? Any links to the catalog description or a datasheet?

Post your full code.

I'm using the RedBearLab Bluetooth BLE with the Arduino Uno board. The code is generated by an IOS app called Arduino Manager. I copied and pasted the full sketch in the bottom box. There are two libraries that I installed with Arduino Manager. They are attached.

IOSControllerBLE.cpp (14.8 KB)

IOSControllerBLE.h (4.83 KB)

To use the argument to one callback function in another callback function you should store it in a global variable of a DIFFERENT NAME.

unsigned int Ball_Feed;
unsigned int Spin;
unsigned int Speed;

void sliderBall_FeedCallback(unsigned int ball_feed) {
  Ball_Feed = ball_feed;
  analogWrite(3, Ball_Feed);
}

void sliderSpinCallback(unsigned int spin) {
  Spin = spin;
}

void sliderSpeedCallback(unsigned int speed) {
  Speed = speed;
  analogWrite(5,Speed);
  analogWrite(6,Spin);
}

Thanks for the help. The code compiled ok, but the motor was unresponsive to the spin slider. I copied and pasted the code in. I also tried placing the analogWrite(6,Spin) command into the spin callback function, and it did control the motor that way. The reason I am trying to do it this way is so the spin control will affect the speed of the motors in relation to each other, with the speed control controlling the speed of both motors. I'll work on the math of that part once I get the basics to work. Any other suggestions?

Thanks!

Any other suggestions?

The usual one. POST YOUR CODE!