Hello, New to Arduino's Im ising a arduino uno for my project. I want to control 6 rc servos that are 120 degrees I believe the value I wznt is 30,150 want to use all 6 ports on arduino. This is for a motion simulator for racing. I dont know how to write code for these I've searched and read but don't really understand it. If someone could write me a code that I could start with thst would be great. Let me know if I need to give more info. Thanks
Did you read the forum posting guide before posting?
No, Im doing it now. Thanks
Thanks. Be aware that people do not usually write scratch code for people here. If you don't know at all how to do it you can either
- learn how by following the Arduino learning materials
- pay someone to write it
I personally recommend (1).
Ok. Thanks for the info.
Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is for problems with the IDE, not for advice on (nor for problems with) your project.
Take one of the 'examples' that you have found and ask about things that you don't understand.
The easy way is with an Adafruit 16-channel servo board.
You can just plug the servos into the headers on the board. and there is a connector for servo power. Example code on the Adafruit site.
Leo..
In addition to the good advice already given, please keep in mind that the Arduino itself is not a source of voltage/current for your servos. Ever. Not even for testing. You need to supply the +- pins of your servos from a separate power supply, connecting the - of that supply to the Arduino - so that the PWM signals from the Arduino are referenced. That will ensure success with your servo project. Good luck, c'mon back with more questions, lots of servo-experienced people here.
Thank you for your response.
#include <Servo.h>
Servo Servos[6];
const byte ServoPins[6] = {4, 5, 6,7,8, 9}; // Or any. 6 digital pins you like
void setup()
{
for (int i=0; i<6; i++)
Servos[i].attach(ServoPins[i]);
}
void loop()
{
for (int i=0; i<6; i++)
{
Servos[i].write(random(30, 151)); // number from 30 to 150 degrees
}
delay(1000);
}
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.