need help in my programe .

yep , it's work now , i will try it but i wanna ask about some thing ...

move(analogRead(joy1),analogRead(joy2),6);

what is number 6 for yes i know what is for but will i use it 6 or change it ?

It's the dead zone.

how to know my dead zone number ???

It's up to you - it depends on how noisy your pots are, and how wide you want but. Experiment with it, play around.

Exactly and if you want to have different deadzones for both F/B, L/R, then you can have,

void move(int z, int y, int DZx, int DZy)// DZx = left/right, DZy = forward/reverse like a graph
{  
  //Movement varibles
  int DRV2 = map(z, 0, 512 - DZy, 255, 0);
  int DRV1 = map(z, 512 + DZy, 1023, 0, 255);
  int STRL = map(y, 0, 512 - DZx, 255, 0);
  int STRR = map(y, 512+ DZx, 1023, 0, 255);

it’s not working , i tested it on the mega and not working no action happen when i move pots up , down , left , or right

byte LMF = 2;// PWM Left motor forward pin
byte LMR = 3;// PWM Left motor Reverse pin
byte RMF = 4;// PWM Right motor forward pin
byte RMR = 5;// PWM Right motor reverse pin
byte LMF2 = 6; 
byte LMR2 = 7;
byte RMF2 = 8;
byte RMR2 = 9;
/*Rest of code here*/
byte joy1=A0;
byte joy2=A1;
int joy1_value;
int joy2_value;

void setup(){
  pinMode(LMF,OUTPUT);
  pinMode(LMR,OUTPUT);
  pinMode(RMF,OUTPUT);
  pinMode(RMR,OUTPUT);
  pinMode(LMF2,OUTPUT);
  pinMode(LMR2,OUTPUT);
  pinMode(RMF2,OUTPUT);
  pinMode(RMR2,OUTPUT);
  pinMode(joy1,INPUT);
  pinMode(joy2,INPUT);
}



void loop(){
 move(analogRead(joy1),analogRead(joy2),6);
}



void move(int z, int y, int DZ)// z = analog_1, y = analog_2, DZ = dead/neutral zone factor.



{
  //Movement varibles
  int DRV2 = map(z, 0, 512 - DZ, 255, 0);
  int DRV1 = map(z, 512 + DZ, 1023, 0, 255);
  int STRL = map(y, 0, 512 - DZ, 255, 0);
  int STRR = map(y, 512+ DZ, 1023, 0, 255);

  if(z > 512)//forwards               
  {
    //Serial.println("Forward with turning"); 
    analogWrite(LMF, constrain(abs(DRV1 - STRL),0,255)); 
    analogWrite(RMF, constrain(abs(DRV1 - STRR),0,255));
    analogWrite(LMF2, constrain(abs(DRV1 - STRL),0,255)); 
    analogWrite(RMF2, constrain(abs(DRV1 - STRR),0,255));  
    digitalWrite(LMR, LOW); 
    digitalWrite(RMR, LOW);
    digitalWrite(LMF2, LOW);
    digitalWrite(RMR2, LOW); 
  }
  else if(z < 512)//backwards               
  {
    //Serial.println("Reverse with turning"); 
    digitalWrite(LMF2, LOW); 
    digitalWrite(RMF2, LOW); 
    digitalWrite(LMF, LOW); 
    digitalWrite(RMF, LOW);   
    analogWrite(LMR, constrain(abs(DRV2 - STRL),0,255)); 
    analogWrite(RMR, constrain(abs(DRV2 - STRR),0,255));
    analogWrite(LMF2, constrain(abs(DRV2 - STRL),0,255));
    analogWrite(RMR2, constrain(abs(DRV2 - STRR),0,255)); 
  }
  else if(z == 512 && y > 512)//Right               
  {
    //Serial.println("360 left"); 
    digitalWrite(LMR, STRR); 
    analogWrite(RMR, LOW);   
    analogWrite(LMF, LOW); 
    digitalWrite(RMF, STRR);
    
    digitalWrite(LMR2, STRR); 
    analogWrite(RMR2, LOW);
    digitalWrite(LMF2, LOW); 
    analogWrite(RMF2, STRR);
  }
  else if(z == 512 && y < 512)//Left              
  {
    //Serial.println("360 right"); 
    analogWrite(LMR, LOW); 
    digitalWrite(RMR, STRL);   
    digitalWrite(LMF, STRL); 
    analogWrite(RMF, LOW); 
  
    analogWrite(LMR2, LOW); 
    digitalWrite(RMR2, STRL);   
    digitalWrite(LMF2, STRL); 
    analogWrite(RMF2, LOW);  
  }

  else //full stop
  { 
    digitalWrite(LMF, LOW); 
    digitalWrite(RMF, LOW);        
    digitalWrite(LMR, LOW); 
    digitalWrite(RMR, LOW);

    digitalWrite(LMF2, LOW); 
    digitalWrite(RMF2, LOW);        
    digitalWrite(LMR2, LOW); 
    digitalWrite(RMR2, LOW);      
  }
}

Time to enable those debug prints

i can't understand you , i just in arduino , can you explain what you say ?

 //Serial.println("Forward with turning");

Debug print - they tell you what the sketch is doing.

Uncomment them.

You need to see the values from the joystick and see if they change. If they DO, then see if these change too. DRV1,DRV2,STRL,STRR.

To see the values, you need to add Serial.begin(9600) or (115200) -> faster in the setup() function, and have a few Serial.print( ... ) and Serial.println( ... ) in your loop.

Serial.print("Joy1: "); Serial.print( analogRead(joy1) ); Serial.print("\t Joy2: "); Serial.println( analogRead(joy2) );

i got this message every time i try to upload to mega , do you think it's burned ]:D

Binary sketch size: 6,462 bytes (of a 258,048 byte maximum) avrdude: stk500v2_recv(): checksum error avrdude: verification error, first mismatch at byte 0x0000 0x02 != 0xff avrdude: verification error; content mismatch

and where i will see the values ???

I am not familiar with that error message, I though you said it was working, what happened?

There is a small button in the top right corner of the Arduino software (IDE), this new window is the Serial Monitor. The number you set in your code "Serial.begin( ??? )" must match the number in the lower right corner of the Serial monitor.

yes they are matching 9600 .
it was working and i uploaded program on it , but it refuse now to upload …

Unplug all the wires then try to upload. Also can you post a better picture of your wiring?

hey guys ,

this is my new code can you tell me if there is something wrong in it …
i uploaded it to mega and every time i switch it the 4 motors (car) moves for back with out stop with out press any switch …
i’m using 4 motors for car and 2 motor for arm .
i use joystick with 4 bush button and 2 pots ( written on them : R103 - 3810)

int m1_f = 2 ;
int m1_b = 3 ;
int m2_f = 4 ;
int m2_b = 5 ;
int m3_f = 6 ; 
int m3_b = 7 ;
int m4_f = 8 ;
int m4_b = 9 ;

int m5_up=10;
int m5_down=11;
int m6_hold=12;
int m6_drop=13;

int button1 = 44 ;
int button2 = 45 ;
int button3 = 46 ;
int button4 = 47 ;
int joy_steck1y = A8 ; 
int joy_steck1x = A9 ; 




void setup() {
  // put your setup code here, to run once:
 pinMode (m1_f , OUTPUT);
 pinMode (m1_b , OUTPUT);
 pinMode (m2_f , OUTPUT);
 pinMode (m2_b , OUTPUT);
 pinMode (m3_f , OUTPUT);
 pinMode (m3_b , OUTPUT);
 pinMode (m4_f , OUTPUT);
 pinMode (m4_b , OUTPUT);
 pinMode(m5_up,OUTPUT);
 pinMode(m5_down,OUTPUT);
 pinMode(m6_hold,OUTPUT);
 pinMode(m6_drop,OUTPUT);

 pinMode (button1 , INPUT );
 pinMode (button2 , INPUT );
 pinMode (button3 , INPUT );
 pinMode (button4 , INPUT );

}

void loop() {
  // put your main code here, to run repeatedly:
run();
Serial.print("joy_steck1y: ");
Serial.print( analogRead(joy_steck1y) );
Serial.print("\t joy_steck1x: ");
Serial.println( analogRead(joy_steck1x) );

}


void run(){  
int y_pos1 = analogRead (joy_steck1x);
int x_pos1 = analogRead (joy_steck1y);

  if(x_pos1>850) {robot_right();}
  if(x_pos1<150) {robot_left();}
  if(y_pos1>850) {robot_fw();}
  if(y_pos1<150) {robot_bw();}
  if(x_pos1>150 && x_pos1 <850&&y_pos1>150 && y_pos1 <850) {robot_stop();}


int but1_val1 = digitalRead (button1);
int but2_val2 = digitalRead (button2);
int but3_val1 = digitalRead (button3);
int but4_val2 = digitalRead (button4);

  if ( but1_val1 == HIGH &&but2_val2 == LOW) { robot_up();}
  //if ( but1_val1 == LOW ) { GLEABER_BACKWARD ();}


  //if ( but2_val2 == LOW ) { GLEABER_FORWARD ();}
  if ( but2_val2 == HIGH&&but1_val1 == LOW) { robot_down();}

if ( but2_val2 == LOW&&but1_val1 == LOW) { robot_arm2_stop();}
if ( but2_val2 == HIGH && but1_val1 == HIGH) { robot_arm2_stop();}


  if ( but3_val1 == HIGH&&but4_val2 == LOW ) { robot_hold();}
  //if ( but3_val1 == LOW ) { gleaber_open ();}


  //if ( but4_val2 == LOW  ){ gleaber_close ();}
  if ( but4_val2 == HIGH&& but3_val1 == LOW) { robot_drop();}



  if ( but4_val2 == HIGH&& but3_val1 == HIGH) { robot_arm_stop();}
  if ( but4_val2 == LOW&& but3_val1 == LOW) { robot_arm_stop();}
}//run


void robot_fw(){
  analogWrite(m1_f,110);           
  digitalWrite(m1_b,LOW);
  analogWrite(m2_f,150);;          
  digitalWrite(m2_b,LOW);
  analogWrite(m3_f,60);            
  digitalWrite(m3_b,LOW);
  analogWrite(m4_f,150);            
  digitalWrite(m4_b,LOW);
}


void robot_bw(){
digitalWrite(m1_f,LOW);
analogWrite(m1_b,110);               
digitalWrite(m2_f,LOW);
analogWrite(m2_b,150);              
digitalWrite(m3_f,LOW);
analogWrite(m3_b,60);                
digitalWrite(m4_f,LOW);
analogWrite(m4_b,150);               

}


void robot_stop(){
  digitalWrite (m1_f , LOW) ; 
  digitalWrite (m1_b , LOW) ; 
  digitalWrite (m2_f , LOW) ; 
  digitalWrite (m2_b , LOW) ; 
  digitalWrite (m3_f , LOW) ; 
  digitalWrite (m3_b , LOW) ; 
  digitalWrite (m4_f , LOW) ; 
  digitalWrite (m4_b , LOW) ; 

}


void robot_right(){
  
digitalWrite(m1_f,LOW);
analogWrite(m1_b,120);              
analogWrite(m2_f,150);             
digitalWrite(m2_b,LOW);
digitalWrite(m3_f,LOW);
analogWrite(m3_b,60);              
analogWrite(m4_f,150);              
digitalWrite(m4_b,LOW);

}


void robot_left(){
  
analogWrite(m1_f,110);             
digitalWrite(m1_b,LOW);
digitalWrite(m2_f,LOW);
analogWrite(m2_b,150);             
analogWrite(m3_f,60);              
digitalWrite(m3_b,LOW);
digitalWrite(m4_f,LOW);
analogWrite(m4_b,150);              

}


void robot_up(){

  analogWrite(m5_up   , 20);      
  digitalWrite(m5_down , LOW);

}

void robot_down(){
  
  digitalWrite(m5_up   , LOW);
  analogWrite(m5_down , 20);     
  
}

void robot_hold(){
  
  analogWrite(m6_hold , 20);      
  digitalWrite(m6_drop , LOW);
}

void robot_drop(){
  
  digitalWrite(m6_hold , LOW);
  analogWrite(m6_drop , 20);      
  
}

void robot_arm_stop(){
  
  digitalWrite(m6_hold , LOW);
  digitalWrite(m6_drop , LOW);
  
}

void robot_arm2_stop(){
  
  digitalWrite(m5_up   , LOW);
  digitalWrite(m5_down , LOW);
  
}

What values does it print to the serial monitor when you first turn it on?