Hi all, so I'm brand new and just bought my first Arduino Uno. I'm hoping to hook up 4 servo motors to sweep 1-180, starting about a half second apart, with a delay and then loop. The hooking up electronically (power supply, which pins to connect etc) makes sense to me, but for code- I have no idea how to begin. Is there sample code out there for similar movements I can figure out how to modify? I've seen basic tutorials on controlling one, but not much I've seen about setting them up to move at different times. I have no coding experience but I'd really like to learn. It's for a moving cosplay prop.
Any help is super appreciated, hope this is all in line with the rules.
Search YouTube for Arduino/Servo examples.
Homework:
No Arduino board is a power supply. Despite what so many tutorials on the web show, you you cannot power a servo, let alone multiple servos, with an Arduino. Use an external supply. Connect the external supply ground to the servo and Arduino ground.
I recommend you get a copy of the Arduino Cookbook, skim it cover to cover then read the sections pertinent to your project. Important: Rule #1 A Power Supply the Arduino is NOT! I recommend you also learn how to draw schematics, the language of electronics. You can get many different free CAD (Computer Aided Design) programs online, I use KiCad.
Oh yeah, I do understand the basic electronic aspect, it's just coding the movement I have trouble with. Thanks though!
The Arduino IDE has a "servo sweep" example built in.
One thing to start with is to clearly identify "exactly" what the code should do. By this I mean you must start with a good overall diagram of something that shows every little step. I like to start with a flow chart, that might not work for everyone.
Remember the Uno is stupid but will follow instructions exactly.
You should start with what your servo's need as signals from the UNO. Select the PWM frequency etc.
You mention you saw a program for one servo. Does the UNO have the resources to replicate that 3 more times?
Sample code.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.