1

Topic: The G-sensor element "joystick" and slider conflict.

I build your example remote control robot platform with two DC motors car with the element "joystick” and one LED "on off". This work perfectly with your example you note in your Examples of Arduino projects.
But in my project I try to add in editor a slider connected to servo motor with G-sensor element which is driving the car. It did not work in my project. There was a conflict when I run it. There was interfacing problems between "joystick" G-sensor and slider. It should both work independently with each other. may be you have an example to show how robot car work with a slider?  please help! Thank you.

2

Re: The G-sensor element "joystick" and slider conflict.

Hello. Possibly your code have any error. Please write your code here

3

Re: The G-sensor element "joystick" and slider conflict.

Hello, Her is my code. When I trying to move the car with joystick the slider move with no control and no reaction to joystick .  And after a while no connecting to smartphone . I do not know where is the error. If I remove the slider then the robot car will Work with no problem. Please help! I am using HC-05 bluetooth.

/*
    -- Robotslider33 --
   
    This source code of graphical user interface 
    has been generated automatically by RemoteXY editor.
    To compile this code using RemoteXY library 2.3.3 or later version 
    download by link http://remotexy.com/en/library/
    To connect using RemoteXY mobile app by link http://remotexy.com/en/download/                   
      - for ANDROID 4.1.1 or later version;
      - for iOS 1.2.1 or later version;
     
    This source code is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.     
*/

//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// RemoteXY select connection mode and include library 
#define REMOTEXY_MODE__SOFTSERIAL
#include <SoftwareSerial.h>

#include <RemoteXY.h>

#include <Servo.h>
Servo myservo;

// RemoteXY connection settings 
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600


// RemoteXY configurate   
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
   { 255,4,0,0,0,37,0,8,13,0,
   5,49,60,10,30,30,1,26,31,2,
   0,25,7,22,11,2,26,31,31,79,
   78,0,79,70,70,0,4,0,9,14,
   7,41,2,26 };
   
// this structure defines all the variables of your control interface 
struct {

     // input variable
   int8_t joystick_1_x; // =-100..100 x-coordinate joystick position
   int8_t joystick_1_y; // =-100..100 y-coordinate joystick position
   uint8_t switch_1; // =1 if switch ON and =0 if OFF
   int8_t slider_1; // =0..100 slider position

     // other variable
   uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)

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

#define PIN_SWITCH_1 12

/* defined the right motor control pins */
#define PIN_MOTOR_RIGHT_UP 7
#define PIN_MOTOR_RIGHT_DN 6
#define PIN_MOTOR_RIGHT_SPEED 10

/* defined the left motor control pins */
#define PIN_MOTOR_LEFT_UP 5
#define PIN_MOTOR_LEFT_DN 4
#define PIN_MOTOR_LEFT_SPEED 9

/* 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);
   }
}



void setup() 
{
   RemoteXY_Init (); 
    /* 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_SWITCH_1, OUTPUT);

  myservo.attach(11);
  RemoteXY.slider_1 = 50;
   
   // TODO you setup code
   
}

void loop() 

   RemoteXY_Handler ();
   
  // TODO you loop code
   // use the RemoteXY structure for data transfer
    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);
   
   int ms = RemoteXY.slider_1*20+500;
   myservo.writeMicroseconds(ms);


}

4

Re: The G-sensor element "joystick" and slider conflict.

Do not use libraries at the same time such as SoftwareSerial.x and Servo.h
If you use Servo.h then you must use HardwareSerial in RemoteXY