rc car

HI,

I have make a rc car with servo and dc motor . I work it with REMOTEXY(bluetooth) and control with phone.
My problem is that when i get work dc motor and servo don't work.if i test servo differetion to dc motor and up side down they work.

THANKS FOR YOUR TIME.

check my program :

#include <Servo.h>
Servo myservo;

/* 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[10]=
{PIN_MOTOR_RIGHT_UP, PIN_MOTOR_RIGHT_DN, PIN_MOTOR_RIGHT_SPEED};
unsigned char LeftMotor[9] =
{PIN_MOTOR_LEFT_DN, PIN_MOTOR_LEFT_UP, PIN_MOTOR_LEFT_SPEED};

void Wheel (unsigned char * motor, int v)
{
//if (v>100) v=100;
//if (v<-100) v=-100;
//if (dist>=60) RemoteXY.slider_1=0;
if (v>0) {
digitalWrite(motor[0], HIGH);
digitalWrite(motor[1], LOW);
analogWrite(motor[2], RemoteXY.slider_1); //v*2.55
}
else if (v<0) {
digitalWrite(motor[0], LOW);
digitalWrite(motor[1], HIGH);
analogWrite(motor[2], RemoteXY.slider_1); //(-v)*2.55
}
else {
digitalWrite(motor[0], LOW);
digitalWrite(motor[1], LOW);
analogWrite(motor[2], 0);
}
}

void setup()
{

pinMode (PIN_MOTOR_RIGHT_UP, OUTPUT);
pinMode (PIN_MOTOR_RIGHT_DN, OUTPUT);
pinMode (PIN_MOTOR_LEFT_UP, OUTPUT);
pinMode (PIN_MOTOR_LEFT_DN, OUTPUT);
RemoteXY_Init();
Serial.begin(9600);
myservo.attach(3);
}

void loop()
{

RemoteXY_Handler();

if (RemoteXY.switch_1==0) {
RemoteXY.led_1_r = 0;
}
else {
RemoteXY.led_1_r = 255;
int ms = RemoteXY.slider_220+500;
myservo.writeMicroseconds(ms);
Wheel (RightMotor, RemoteXY.joystick_1_y - RemoteXY.joystick_1_x);
/
manage the left motor */
Wheel (LeftMotor, RemoteXY.joystick_1_y + RemoteXY.joystick_1_x);
}
}

Hello ,

previously, can you attach an picture for wiring connection on your arduino board ?

what microcontroller did you use, how many servo / dc motor you use ?

Cheers,
niel.

That's not a complete program. It doesn't compile, there's no RemoteXY defined and I can't see any code for a servo in there anywhere.

And I can't understand exactly what "when i get work dc motor and servo don't work.if i test servo differetion to dc motor and up side down they work" means.

Steve

I am using arduino uno with a servo and 2 dc motors with l298n
this is dc motors connection

and this is like as my servo connection

check and my remotexy
and Steve i add servo

"when i get work dc motor and servo don't work.if i test servo differetion to dc motor and up side down they work" means.
when i ran it. if you understand me

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

// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__HARDSERIAL

#include <RemoteXY.h>

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

// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,14,0,25,0,214,0,10,8,4,
4,0,85,-1,14,64,1,1,6,4,
128,1,46,89,16,1,1,6,66,130,
1,13,37,29,1,6,31,66,130,39,
14,36,28,1,6,16,67,4,11,27,
17,7,1,16,8,11,67,4,49,27,
15,7,1,16,8,11,2,0,0,0,
23,12,1,1,6,31,31,79,78,0,
79,70,70,0,1,1,64,0,12,12,
1,6,31,76,73,71,72,84,0,1,
1,76,0,12,12,1,6,31,72,79,
82,78,0,1,0,33,10,12,12,1,
6,1,206,148,0,1,0,26,7,9,
9,1,6,94,60,0,1,0,43,7,
9,9,1,6,94,62,0,131,1,23,
1,20,7,1,6,31,77,65,73,78,
49,0,131,0,43,1,20,7,2,6,
31,77,65,73,78,50,0,6,0,0,
13,51,51,2,2,26,5,4,55,16,
44,44,2,6,1,31,2,1,74,2,
22,11,2,1,6,31,31,79,78,0,
79,70,70,0,65,4,2,1,12,12,
2 };

// this structure defines all the variables and events of your control interface
struct {

// input variables
int8_t slider_1; // =0..100 slider position
uint8_t slider_2; // =0..100 slider position
uint8_t switch_1; // =1 if switch ON and =0 if OFF
uint8_t button_1; // =1 if button pressed, else =0
uint8_t button_2; // =1 if button pressed, else =0
uint8_t button_3; // =1 if button pressed, else =0
uint8_t button_4; // =1 if button pressed, else =0
uint8_t button_5; // =1 if button pressed, else =0
uint8_t rgb_1_r; // =0..255 Red color value
uint8_t rgb_1_g; // =0..255 Green color value
uint8_t rgb_1_b; // =0..255 Blue color value
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_2; // =1 if switch ON and =0 if OFF

// output variables
int8_t level_1; // =0..100 level position
int8_t level_2; // =0..100 level position
char text_1[11]; // string UTF8 end zero
char text_2[11]; // string UTF8 end zero
uint8_t led_1_r; // =0..255 LED Red brightness

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

} RemoteXY;
#pragma pack(pop)

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

A possible problem:

#define PIN_MOTOR_RIGHT_SPEED 10
#define PIN_MOTOR_LEFT_SPEED 9

from the Servo library reference:

use of the (Servo) library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins.