Hello everyone, I have a problem with servo motors. I'm building a robotic arm with 6 servo motors, specifically 3 MG90S and 3 MG996R servos. After connecting everything as shown in the diagram, the servo motors seem to be confused and lack the power to move.
#include <SoftwareSerial.h>
#include <Servo.h>
Servo myservo1, myservo2, myservo3, myservo4, myservo5, myservo6;
int bluetoothTx = 10; // bluetooth tx to 10 pin
int bluetoothRx = 11; // bluetooth rx to 11 pin
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup()
{
myservo1.attach(3);
myservo2.attach(4);
myservo3.attach(5);
myservo4.attach(6);
myservo5.attach(7);
myservo6.attach(8);
Serial.begin(9600);
//Setup Bluetooth serial connection to android
bluetooth.begin(9600);
}
void loop()
{
if(bluetooth.available()>= 2 )
{
unsigned int servopos = bluetooth.read();
unsigned int servopos1 = bluetooth.read();
unsigned int realservo = (servopos1 *256) + servopos;
Serial.println(realservo);
if (realservo >= 1000 && realservo <1180) {
int servo1 = realservo;
servo1 = map(servo1, 1000, 1180, 0, 180);
myservo1.write(servo1);
Serial.println("Servo 1 ON");
delay(10);
}
if (realservo >= 2000 && realservo <2180) {
int servo2 = realservo;
servo2 = map(servo2, 2000, 2180, 0, 180);
myservo2.write(servo2);
Serial.println("Servo 2 ON");
delay(10);
}
if (realservo >= 3000 && realservo <3180) {
int servo3 = realservo;
servo3 = map(servo3, 3000, 3180, 0, 180);
myservo3.write(servo3);
Serial.println("Servo 3 ON");
delay(10);
}
if (realservo >= 4000 && realservo <4180) {
int servo4 = realservo;
servo4 = map(servo4, 4000, 4180, 0, 180);
myservo4.write(servo4);
Serial.println("Servo 4 ON");
delay(10);
}
if (realservo >= 5000 && realservo <5180) {
int servo5 = realservo;
servo5 = map(servo5, 5000, 5180, 0, 180);
myservo5.write(servo5);
Serial.println("Servo 5 ON");
delay(10);
}
if (realservo >= 6000 && realservo <6180) {
int servo6 = realservo;
servo6 = map(servo6, 6000, 6180, 0, 180);
myservo5.write(servo6);
Serial.println("Servo 6 ON");
delay(10);
}
}
}
The devices You mention are named servo, not "servo motors". It's a great difference.
To what pin are those 4 x 1.5 volt connected? For Vin it is too little and for 5 volt it is too much.
Using a breadboard to distribute 6x servo current is not good. Use protoboard and soldering.
LiPo batterie will do better for sure than a 9V battery used in smoke detectors - the mileage you’ll get from it depends on their intrinsic characteristics (mAH / C …) and of course usage
Only for the high power ones use wires with a larger section than the cheap far east made DuPont cables that have only a handful of strands. Electric cable will do - I suppose you don’t have long sections anyway
Don’t buy batteries without first analyzing your needs
Not for the servos but nothing wrong with using the 9v for powering the Arduino. Years ago they would power portable AM radios for weeks. And that was with carbon-zinc. The alkaline batteries are even more capable.
I was try to connect servos with phone chargers 5V 2A and Arduino had other external power but the are still glitching. Maybe new batteries and eletric cable will help?
I believe that phone chargers will only deliver the 2 amps after negotiating a power setting with the attached device. Someone correct me if I am wrong please.
4 or 5 Ni-mh cells or two LiFePO4 cells are used for hobby servos in models. Some can handle the LiPo 2 cell voltage. 4 good AA alkaline cell will work too. But for long term use with the number of servos you are using you should get a 10 amp power supply. And use a different method to power them instead of the breadboard you are using.