I need you ! PLEASE HELP ME !

Hello
I have a problem, with my code I do not manage to include the function map
Thanks

#include <Servo.h>
int capteur1 = 3; // Connecté au Pin 3
int capteur2 = 4;
int capteur3 = 5;
int capteur4 = 6;
Servo servo;
Servo servo1;
Servo servo2;
int pos = 0;
void setup() {
pinMode(capteur1, INPUT);
pinMode(capteur2, INPUT);
pinMode(capteur3, INPUT);
pinMode(capteur4, INPUT);
servo.attach(9);
servo1.attach(10);
servo2.attach(11);
Serial.begin(9600);
}
void loop()
{
if(HIGH == digitalRead(capteur1))
for(pos = 0; pos < 180; pos += 1) // il va tourner à droite à 180 °
{
servo.write(pos);
delay(15);
}
else Serial.println(“Capteur1: BLANC”);
delay(1000);
if(HIGH == digitalRead(capteur2))
for(pos = 0; pos < 90; pos+=1) // goes from 180 degrees to 0 degrees
{
servo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
else Serial.println(“Capteur2: BLANC”);
delay(1000);
if(HIGH == digitalRead(capteur3))
for(pos = 90; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
servo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
else Serial.println(“Capteur3: BLANC”);
delay(1000);
if(HIGH == digitalRead(capteur4))
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
servo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
else Serial.println(“Capteur4: BLANC”);
delay(1000);
servo1.write(180);

I have a problem

But I'm not going to tell you what it is...

I do not manage to include the function map

But, I'm not going to tell you why...

I'm also not going to post my code properly, not can I be bothered to format it correctly.

Did I miss anything?

I have a servo which is inverted but the problem it is which turns on itself but I would want that it goes straight

I am sorry, i am french, my english is catastrophic

Your code pears to me to be incomplete.
Please repost, using code tags.

what it is a code pears ?

I have a servo which is inverted but the problem it is which turns on itself but I would want that it goes straight

Servos rotate, for the ,most part. Only linear servos can go straight. I doubt that what you have is a linear servo.

    for(pos = 0; pos < 90; pos+=1)     // goes from 180 degrees to 0 degrees

Not in my world.

Perhaps you should ask in the French section, or get someone, even google to help with the translation.

Ok, thanks this is what I did

#include <Servo.h> 
int capteur1 = 3;    // Connecté au Pin 3
int capteur2 = 4;
int capteur3 = 5;
int capteur4 = 6;
Servo servo;
Servo servo1;
Servo servo2;
int pos = 0;
void setup()   {                
  pinMode(capteur1, INPUT);
  pinMode(capteur2, INPUT);
  pinMode(capteur3, INPUT);
  pinMode(capteur4, INPUT);
  servo.attach(9);
  servo1.attach(10);
  servo2.attach(11);
  Serial.begin(9600); 
}
void loop()                     
{
  if(HIGH == digitalRead(capteur1))
    for(pos = 0; pos < 45; pos += 1) // goes from 45 degrees to 0 degrees, he turn right
    {                                 
    servo.write(45);       
    delay(15);                        
  }
    else  Serial.println("Capteur1: BLANC");
    delay(1000);
  if(HIGH == digitalRead(capteur2))
    for(pos = 0; pos < 27; pos+=1)     // goes from 27 degrees to 0 degrees, he turn right
  {                                
    servo.write(27);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
    else Serial.println("Capteur2: BLANC");
    delay(1000);
    if(HIGH == digitalRead(capteur3))
    for(pos = 27; pos>=1; pos-=1)     // goes from 0 degrees to 37 degrees 
  {                                
    servo.write(27);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
    else Serial.println("Capteur3: BLANC");
    delay(1000);
    if(HIGH == digitalRead(capteur4))
    for(pos = 45; pos>=1; pos-=1)     // goes from 0 degrees to 45 degrees, he turn left
  {                                
    servo.write(45);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
    else Serial.println("Capteur4: BLANC");
    delay(1000);
    
}
    for(pos = 0; pos < 27; pos+=1)     // goes from 27 degrees to 0 degrees, he turn right
  {                                
    servo.write(27);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }

shouldn’t “servo.write(27);” be “servo.write(pos);”?

little-monkey:
what it is a code pears ?

It could be:-
http://simplebits.com/notebook/2012/02/07/pears/
or it could be that it is a typo and he missed the a off the front of the word.

for(pos = 0; pos < 27; pos+=1)     // goes from 27 degrees to 0 degrees, he turn right
  {                                
    servo.write(27);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }

NO if you want to turn a servo slowly then do:-

for(pos = 0; pos < 27; pos+=1)     // goes from 0 degrees to 27 degrees, he turn right
  {                                
    servo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }

If you don’t want it to turn slowly then do not put it in a loop.

Thanks, my robot does not move :~

little-monkey: Thanks, my robot does not move :~

So do not start with such long code. Write something that will just turn the servos a few times, do they move? Then write something to read your switches, are they returning the values you expect?

Only when you have checked out your hardware can you build up your code a small piece at a time.

made in, I just the cable from the information placed on the arduino uno then I put the wire + and - external battery

little-monkey: I have a servo which is inverted but the problem it is which turns on itself but I would want that it goes straight

The below is one way some times used to reverse a servo command. Often used on bots that use continuous rotation servos to drive the wheels where the servos are on opposite sides of the bot.

 myservo1.write(n);
 myservo2.write(180-n);

I inserted the servo.write function, my robot still does not advance, but it captures the line

#include <Servo.h> 
int capteur1 = 3;    // Connecté au Pin 3
int capteur2 = 4;
int capteur3 = 5;
int capteur4 = 6;
Servo servo;
Servo servo1;
Servo servo2;
int pos = 0;
int n =0;
void setup()   {                
  pinMode(capteur1, INPUT);
  pinMode(capteur2, INPUT);
  pinMode(capteur3, INPUT);
  pinMode(capteur4, INPUT);
  servo.attach(9);
  servo1.attach(10);
  servo2.attach(11);
  
  Serial.begin(9600); 
}
void loop()                     
{
  if(HIGH == digitalRead(capteur1))
    for(pos = 0; pos < 45; pos += 1) // goes from 45 degrees to 0 degrees, he turn right
    {                                 
    servo.write(pos);       
    delay(15);                        
  }
    else  Serial.println("Capteur1: BLANC");
    delay(1000);
  if(HIGH == digitalRead(capteur2))
    for(pos = 0; pos < 27; pos+=1)     // goes from 27 degrees to 0 degrees, he turn right
  {                                
    servo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
    else Serial.println("Capteur2: BLANC");
    delay(1000);
    if(HIGH == digitalRead(capteur3))
    for(pos = 27; pos>=1; pos-=1)     // goes from 0 degrees to 37 degrees 
  {                                
    servo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
    else Serial.println("Capteur3: BLANC");
    delay(1000);
    if(HIGH == digitalRead(capteur4))
    for(pos = 45; pos>=1; pos-=1)     // goes from 0 degrees to 45 degrees, he turn left
  {                                
    servo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
    else Serial.println("Capteur4: BLANC");
    delay(1000);
  {  
  servo1.write(n);
  servo2.write(180-n);
  }
}

Your if blocks are constructed wrongly. In this code, and other places, which commands should be executed when the if test is true ?

  if(HIGH == digitalRead(capteur1))
    for(pos = 0; pos < 45; pos += 1) // goes from 45 degrees to 0 degrees, he turn right
    {                                 
      servo.write(pos);       
      delay(15);                        
    }

An if test should have the commands to be executed in braces like this

if (something == TRUE)
{
   //execute the code here
}

If you leave out the braces as you have then only the next line after the test will be executed because there is nothing to indicate which commands to execute.

UKHeliBob:
If you leave out the braces as you have then only the next line after the test will be executed because there is nothing to indicate which commands to execute.

Strictly speaking it’s the next statement which is executed, and the code looks syntactically correct. However, without braces or consistent indentation to make it clear which statement(s) the coder intended to be associated with each condition, the code is a recipe for disaster. I agree with UKHeliBob that you should always use braces ({ and }) with any conditional statement to make it explicit and unambiguous which code it is intended to control. Also put each { and } on separate lines with matchng pairs indented by the same amount and the code between them indented one extra level. The IDE will apply the indentation for you if you run the Tools / Auto Format command.