I would like to connect it to the pin 5 of the shield (the orange one). But when I do that nothing happend with this program:
int MOTOR_OUT = 5;
void setup()
{
pinMode(MOTOR_OUT, OUTPUT); //Initiates Motor Channel A pin
}
void loop()
{
digitalWrite(MOTOR_OUT, HIGH); //Establishes forward direction of Channel
}
I have seen that when I when I do a digitalWrite on the pin 5 to LOW or HIGH I have the 5V between the middle one (ground) and the left one or the right one depending of this value.
If I understand correctly the servo work with a pulse to turn. but how can I change the program to turn to 90 degrees for example?
I also have an external charger (5V - 1A) that I have plug on the the GND and Vin port on the blue pin.
I know that it is really basic but I don't find any example with other pin than the blue one.
The vendor site for the servos is not in English . We need something like a datasheet or a document that shows the wiring and connections to a driver. If you don't have a document , make one or take a photo. Either way we need to know EXACTLY how these servos connect to a driver. (how many wires and where do they connect to ?).
Why aren't you using analogWrite ? Do you or do you not know about PWM ?
I think you need to use the Servo library. It looks like you have a motor for the wheel and a servo to pan the Ultrasonic sensor but
I don't know if you understand the difference between the two as far as how you control them. Please give us a report that states
what you do or do not understand about controlling the wheel motor and the pan servo and what exactly you have tried.
I don't see any servo code so obviously the servo isn't working (at least not the way you are trying to control it).
I am really a beginner and I don't understand how to turn my servo with the motor shield.
You do not need to use the motor shield to operate the continious rotation servo. Wire the servo up like below, and then you can use the bottom code to test the speed/direction of your servo.
// zoomkat 3-28-14 serial servo incremental test code
// using serial monitor type a character (s to increase or a
// to decrease) and enter to change servo position
// (two hands required, one for letter entry and one for enter key)
// use strings like 90x or 1500x for new servo position
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.
#include<Servo.h>
String readString;
Servo myservo;
int pos=1500; //~neutral value for continous rotation servo
//int pos=90;
void setup()
{
myservo.attach(7, 400, 2600); //servo control pin, and range if desired
Serial.begin(9600);
Serial.println("serial servo incremental test code");
Serial.println("type a character (s to increase or a to decrease)");
Serial.println("and enter to change servo position");
Serial.println("use strings like 90x or 1500x for new servo position");
Serial.println();
}
void loop()
{
while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
delay(2); //slow looping to allow buffer to fill with next character
}
if (readString.length() >0) {
if(readString.indexOf('x') >0) {
pos = readString.toInt();
}
if(readString =="a"){
(pos=pos-1); //use larger numbers for larger increments
if(pos<0) (pos=0); //prevent negative number
}
if (readString =="s"){
(pos=pos+1);
}
if(pos >= 400) //determine servo write method
{
Serial.println(pos);
myservo.writeMicroseconds(pos);
}
else
{
Serial.println(pos);
myservo.write(pos);
}
}
readString=""; //empty for next input
}
NOTE: Servos that can rotate continuously have to absolute position information available. The exact Pulsewidth that makes the motor stop is usually not exactly equal to the "90 degrees" value of a positional type servo. If you want your robot to stop completely you will have to determine the needed value. (We will add example code to help with that).