Good evening, I am trying to build a robotic arm controllable by keyboard with 6 servomotors, 3 SG90 and the other 3 are MG996R. They are connected to the PCA9685 board and powered by a 5V 1.2A power supply, but when I upload the code, the servos do not move. I thought the problem was that the power supply was insufficient for all 6 servos, but even when trying to power just one servo motor, it does not move. I don't understand if the problem is the power supply or the code. This code should move a servo using keyboard characters. Thank you very much to anyone who can help me.
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver servo = Adafruit_PWMServoDriver();
#define SERVOMIN 150
#define SERVOMAX 600
char tasto = '0';
int angBase = 150;
int angSpalla = 90;
int angGomito = 90;
int angPolso = 90;
int angMano = 90;
int angDita = 90;
// POSIZIONE SERVO
int servoBase = 0;
int servoSpalla = 2;
int servoGomito = 3;
int servoPolso = 4;
int servoMano = 5;
int servoDita = 6;
int angolo;
void setup() {
Serial.begin(9600);
servo.begin();
servo.setPWMFreq(60);
delay(100);
}
void loop() {
if(Serial.available() > 0) {
tasto = Serial.read();
Serial.print(tasto);
switch(tasto) {
case 'a':{
angBase++;
servo.setPWM(servoBase, 0, angBase);
delay(10);
}
case 'A':{
angBase--;
servo.setPWM(servoBase, 0, angBase);
delay(10);
}
}
}
}
Yes, I tried using examples where the code was correct, but it still didn't work. I tried adding some Serial.print statements, for example inside the case blocks, and all of them were visible on the terminal, but the servos didn't move.
Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
Can you post some images of your project?
So we can see your component layout.
I tried with this code and the connections identical to the design, without going through the PCA9685 board, and it works.
Thank you very much for help me.
Don't think so.
red + black from the supply should be connected to the screw terminal.
5volt and ground from the Uno connect to VCC and ground of the PCA9685.
Purple and green are correct.
The supply should be able to deliver 10A (~650mA per SG-90, 2.5A per MG996).
Leo..
Initially, I connected them with the screw, but then the power light on the board didn't turn on, so I thought it wasn't working and that it was broken. Then I connected them to the terminals. I think it's the same thing, but correct me if I'm wrong. I managed to find another power supply that is more powerful, 2A. The problem is that even when connecting just one SG90 servo, it doesn't move. Thank you very much.
I tried powering it through the screws, but the power light on the board doesn't turn on, and while uploading the sketch, I get an error saying stk500_recv() the board is missing or not connected.
I managed to fix it. I was connecting the external power but not powering the Arduino. The code is correct. Thank you very much to everyone who helped me.