I’m working on an Arduino project and could use some advice. My goal is to have a single button press trigger both a XY160D linear actuator and two hobby servos at the same time. Here’s what I have so far:
• The XY160D actuator is powered by a 12V wall adapter through its barrel connector.
• I’ve been controlling it with the Arduino by connecting 5V and GND from the Arduino to the actuator for signal purposes. This works fine for moving the actuator.
• I now want to add two servos to the project, but I’m not sure how to integrate them because:
• Servos also need 5V power, and I only have one 5V pin on the Arduino.
• I want to make sure I don’t overload the Arduino or cause voltage drops.
My main questions:
1. What’s the best way to wire both servos and the actuator so they can all be triggered by the Arduino without damaging anything?
2. Can I safely use the Arduino’s 5V for the servos, or should I use a separate 5V power supply?
3. Are there any tips for coding this so that a single button press moves the actuator and the two servos in sequence or simultaneously?
I’d really appreciate advice on both the wiring and Arduino code side. I’m hoping to make this a smooth, one-button operation without risking the Arduino or components.
Here are some simple guidelines that if violated tend to destroy the Arduino and make the Arduino sales person happy.
Gil's Crispy Critter Rules for Processor Hardware:
Rule #1: An Arduino is NOT a Power Supply!
Rule #2: Never connect anything inductive (motors, speakers) directly to an Arduino!
Rule #3: Avoid connecting or disconnecting wires while the power is on.
Rule #4: Do not apply power to any pin unless you are certain of what you're doing.
Rule #5: Do not exceed the maximum voltage or current ratings.
Rule #6: Many Arduinos cannot power transmitters directly.
Rule #7: Before powering your project, take a break and double-check the wiring.
Rule #8: Bad soldering makes for project failure.
LaryD’s Corollaries:
Coro #1: When starting out, add a 220Ω resistor in series with both input and output pins to protect against shorts.
Coro #2: Invest in a Digital Multi-Meter (DMM) to measure voltages, currents, and resistance.
Note: Violating these rules can turn your Arduinos into crispy critters. For optimal performance, keep your wires under 25 cm (10 inches).
Additional Tips:
The L293 motor driver, though common, is inefficient as it can lose around 3V as heat when driving both legs of a motor. Consider using a motor driver with MOSFET outputs to reduce heat loss and conserve battery power.
Not all motor drivers work with each motor, they have to be compatible.
The nRF24 radios do not work very well when powered with an Arduino even if the 5V adapter is used.
You could use step down converter from 12V to 5-6V for your servos. If your 12V power supply is rated for that (undescribed) current draw.
You can run code for both with same arduino.
Hey, yeah. By same code, I mean combining my 2 servos into what I currently have set up (my linear actuator connected to my XY160D H-Bridge, and arduino). I don’t know how to add two servos to my current circuit. I have code to tell the linear actuator to go up and down. But as it goes up I’d like my servos to rotate one way, and then as it comes down I’d like it to rotate the other way.
Adding servos would just take a couple more lines of code. Your favorite search engine, armed with a search phrase like "arduino servo", will find countless examples.