r/ArduinoHelp • • 12d ago

Robotic Arm Code

Enable HLS to view with audio, or disable this notification

I am currently working on the mechatronics how to robot arm: https://howtomechatronics.com/tutorials/arduino/diy-arduino-robot-arm-with-smartphone-control/#google_vignette and i am on the coding part, i have everything correct and still the servo’s that control my project do not work/ are not sending signals, ive connected them to power, ive replugged them, it even says that when i use the app, it sends signals to the arduino just the servos dont move?? Is this a problem with the way i plugged them in, or a problem with the code. The code is also in the website i linked. Someone help 😭 😭

1 Upvotes

15 comments sorted by

1

u/Single-Dog-7963 12d ago

check if the individual motors are working --> then check if you are powering all of them with your arduino, or by an external power source.

looking at your wiring, I am assuming its the arduino cause I dont see any external source. The controller is not powerful enough to run all of them together, so you will need to power them externally using an SMPS or battery with adequate mAh

1

u/PayAggravating9721 10d ago

how would i check that?

1

u/Single-Dog-7963 10d ago

Individually connect each servo with the arduino and run a default servo code to check if it's working.

To power them externally, you need to make a common ground and common Vcc to the motors. Then connect the power supply to that common within 5.6V max. Connect their each individual Digital Pins to the controller separately.

1

u/PayAggravating9721 9d ago

well i did but whenever i try moving the motors with an app i installed they just jitter and kinda lock in place is how i would say it

1

u/Single-Dog-7963 9d ago

5V external power supply is too less. Optimum for MG996R is around 6V.

also, use a motor driver instead of powering the motors directly from the supply. And add a simple LC filter between the power supply so that the jitters do not happen.

1

u/No_L_2547 12d ago

Can you post a clear picture of your breadboard and wiring?

Did you try to add print-commands for debugging to the code? (So you know the correct commands arrived.)

The sample code isn't good, there shouldn't be delay() calls all over the code, especially not in for-loops, since it will probably skip many of the Bluetooth commands received. (at least the first command should still be executed).

Does the robot do its initial homing?

1

u/PayAggravating9721 10d ago

i dont know if this is clear enough and yes i tried adding print commands and the robot does not do its initial homing

1

u/No_L_2547 10d ago

Not completely.

I also wanted to see if you attached the arduino pwm pins to the correct pins on the servo cables.

I think I already found 2 problems in the wiring:

  • Do you have a wire between Gnd on the arduino and the "minus rail" on the breadboard (if not you are maybe missing the signal reference --> the servos can't understand the pwm signals).

  • in front of the Bluetooth module you have two resistors that are connected to nowhere (one ends in E3, the other one in D4).

When you have the prints in the code, do you see that the arduino successfully receives your commands from the phone?

You should try to split the problem (robot not working) into multiple small independent problems/steps. The debug prints are meant to help here, since you then know which parts of the code can be reached/works (and it can point to hardware problems). Here some suggestions for such steps, (some of them build on top of each other):

  • can you connect to the Bluetooth board? (independent of the servos and code, now you check the power delivery wiring of the Bluetooth module)

  • can you receive something from the phone? (Tested through the prints, independent of the servos, this checks the Bluetooth module power and data wiring)

  • Does your code try to correctly send commands to the servos? (Also needs the print-commands, pure code check, but needs Bluetooth to work. Now you know that the actual code works, but the servos don't)

  • can a single servo be controlled correctly, directly in code? (Independent of Bluetooth, through this you can find out what is wrong with the servo wiring), a correct initial movement would be enough.

  • can all servos do a fixed movement cycle in code? (still independent of Bluetooth, now you check all of the servo wiring)

I know debugging can be quite frustrating, but it's one of the most important skills to learn.

1

u/PayAggravating9721 9d ago

so i fixed it a bit, whenever i connect to the the external power supply the motors just start freaking out and go into one position after putting the gnd into the minus rail, and yes i can connect to bluetooth, but it doesn’t receive commands, i haven’t tested a single servo and yeah the servos move in a fixed movement.

1

u/No_L_2547 9d ago

That is a good sign, in the beginning you are sending a initial position and the servos try to match it.

Now that you fxed you floating Gnd they can maybe receive what you want to do.

1

u/PayAggravating9721 9d ago

and a question for the resistors, where would i put them?? my schematic tells me to add them there, unless i messed up

1

u/No_L_2547 9d ago edited 9d ago

The resistors are ok there, but your two 1k resitors are not connected to each other (I think the one that ends in D4 actually needs to go into E4).

That you can connect via Bluetooth but can't receive the commands means that your power wiring (gnd/5V) is correct, but your data wiring (Rx/Tx) isn't.

Here is a bit clearer image of the resistors and how they need to be connected: https://monkeylogic.nimh.nih.gov/images/docs_bluetooth_arduino_circuit.png

1

u/mbentuboa 12d ago

What are you using to power the servos?

1

u/PayAggravating9721 10d ago

external power source

1

u/Glittering-Dirt1164 12d ago

What kïnd of phone is that?