1

Topic: ???

Hello
I have a sketch. Look near. Please can wrtie me different

signed char slider_1; /* =-100..100 slider position */
unsigned char slider_1; /* =-100..100 slider position */


i am begginer but more things i do not understanding...
//////////////////////////////////////////////
//        RemoteXY include library          //
//     use  library  version 2.1.3 or up    //
//   use ANDROID app version 3.4.1 or up    //
//////////////////////////////////////////////

/* RemoteXY select connection mode and include library */
#define REMOTEXY_MODE__SERIAL

#include <RemoteXY_Base.h>
#include <RemoteXY_Serial.h>

#include <SoftwareSerial.h>
#include <RemoteXY.h>

/* RemoteXY connection settings */
#define REMOTEXY_SERIAL Serial
#define REMOTEXY_SERIAL_SPEED 9600


/* RemoteXY configurate  */
unsigned char RemoteXY_CONF[] =
   { 7,0,224,0,4,5,5,35,36,11
  ,32,32,1,2,0,45,48,15,6,1
  ,79,78,0,79,70,70,0,4,160,8
  ,3,84,5,2,4,160,6,56,84,5
  ,2,4,32,2,10,6,44,2,4,32
  ,90,10,6,45,2,130,0,32,10,37
  ,37,12,130,0,10,2,80,7,14,129
  ,0,11,6,10,3,0,83,101,114,118
  ,111,32,49,0,130,0,8,55,80,7
  ,14,129,0,9,55,10,3,0,83,101
  ,114,118,111,32,50,0,130,0,1,12
  ,8,40,14,129,0,6,49,10,3,0
  ,83,101,114,118,111,32,51,0,130,0
  ,1,48,18,5,14,130,0,89,12,8
  ,41,14,130,0,79,48,18,5,14,129
  ,0,80,49,10,3,0,83,101,114,118
  ,111,32,52,0,130,0,53,41,36,6
  ,12,129,0,58,42,30,4,0,65,100
  ,97,109,32,197,160,117,106,97,110,115
  ,107,195,189,0,130,0,69,30,20,11
  ,12,129,0,70,32,17,4,0,65,77
  ,65,86,69,84,0,129,0,73,36,11
  ,4,0,54,56,54,32,66,0 };
   
/* this structure defines all the variables of your control interface */
struct {

    /* input variable */
  signed char joystick_1_x; /* =-100..100 x-coordinate joystick position */
  signed char joystick_1_y; /* =-100..100 y-coordinate joystick position */
  unsigned char switch_1; /* =1 if switch ON and =0 if OFF */
  unsigned char slider_1; /* =-100..100 slider position */
  unsigned char slider_2; /* =-100..100 slider position */
  unsigned char slider_3; /* =-100..100 slider position */
  unsigned char slider_4; /* =-100..100 slider position */

    /* other variable */
  unsigned char connect_flag;  /* =1 if wire connected, else =0 */

} RemoteXY;

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////

#include <Servo.h>

Servo prve_servo;
Servo druhe_servo;
Servo tretie_servo;
Servo stvrte_servo;


/* defined the right motor control pins */
#define PIN_MOTOR_RIGHT_UP 17
#define PIN_MOTOR_RIGHT_DN 18
#define PIN_MOTOR_RIGHT_SPEED 4

/* defined the left motor control pins */
#define PIN_MOTOR_LEFT_UP 7
#define PIN_MOTOR_LEFT_DN 8
#define PIN_MOTOR_LEFT_SPEED 12

/* defined the LED pin */
#define PIN_LED 13


/* defined two arrays with a list of pins for each motor */
unsigned char RightMotor[3] = 
  {PIN_MOTOR_RIGHT_UP, PIN_MOTOR_RIGHT_DN, PIN_MOTOR_RIGHT_SPEED};
unsigned char LeftMotor[3] = 
  {PIN_MOTOR_LEFT_UP, PIN_MOTOR_LEFT_DN, PIN_MOTOR_LEFT_SPEED};

/*
   speed control of the motor
   motor - pointer to an array of pins
   v - motor speed can be set from -100 to 100
*/
void Wheel (unsigned char * motor, int v)
{
  if (v>100) v=100;
  if (v<-100) v=-100;
  if (v>0) {
    digitalWrite(motor[0], HIGH);
    digitalWrite(motor[1], LOW);
    analogWrite(motor[2], v*2.55);
  }
  else if (v<0) {
    digitalWrite(motor[0], LOW);
    digitalWrite(motor[1], HIGH);
    analogWrite(motor[2], (-v)*2.55);
  }
  else {
    digitalWrite(motor[0], LOW);
    digitalWrite(motor[1], LOW);
    analogWrite(motor[2], 0);
  }
}

#define PIN_SWITCH_1 13


void setup() 
{
  RemoteXY_Init (); 
 
  pinMode (PIN_SWITCH_1, OUTPUT);
   
  /* initialization pins */
  pinMode (PIN_MOTOR_RIGHT_UP, OUTPUT);
  pinMode (PIN_MOTOR_RIGHT_DN, OUTPUT);
  pinMode (PIN_MOTOR_LEFT_UP, OUTPUT);
  pinMode (PIN_MOTOR_LEFT_DN, OUTPUT);
  pinMode (PIN_LED, OUTPUT);

  // TODO you setup code
  prve_servo.attach(9);
  druhe_servo.attach(10);
  tretie_servo.attach(11);
  stvrte_servo.attach(5);

  RemoteXY.slider_1=50;
  RemoteXY.slider_2=50;
  RemoteXY.slider_3=50;
  RemoteXY.slider_4=50;
   
   
}

void loop() 

  RemoteXY_Handler ();
   
      /* manage LED pin */
  digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?LOW:HIGH);
     
     /* manage the right motor */
  Wheel (RightMotor, RemoteXY.joystick_1_y - RemoteXY.joystick_1_x);
  /* manage the left motor */
  Wheel (LeftMotor, RemoteXY.joystick_1_y + RemoteXY.joystick_1_x);

  prve_servo.writeMicroseconds(RemoteXY.slider_1*20+500);
  druhe_servo.writeMicroseconds(RemoteXY.slider_2*20+500);
  tretie_servo.writeMicroseconds(RemoteXY.slider_3*20+500);
  stvrte_servo.writeMicroseconds(RemoteXY.slider_4*20+500);
   
 
}