Controlling 5 servos with 5 potentiometers

Please read below. Because this is how I feel.

I have been doing embedded systems for a while and have been coming across posts from this forum (typically through a google search) for several years now. My take away from reading threads on here is almost always that I would not want to be part of that community because it appears to discourage people from learning this technology?

Why does it appear that there is a large population of members who's only contribution is pouncing on new members to assert their knowledge of forum etiquette in a condescending tone? Why do so many posts contain a member demanding that the poster provide the full code and schematics then the member never contributes to the original request, even when it is pretty obvious that the entire code and schematics are not necessary to help the poster with their request?

I get it. This is how people act everywhere to some degree. But why does it seem to an outsider like me that this behavior is more prevalent on this site than others similar sites?

Is that truly how this community wants to be portrayed and represented? Is it really in the best interest of this community to treat new members badly because they did not follow rule #142 correctly or something?

As I alluded to before, I get the impression that the goal of this community is to discourage newcomers from learning and adopting the arduino platform. I don't really believe that, but it sure seems that way to an outsider and I can only imagine how it feels to someone who is struggling to learn a new technology and on the brink of giving up when they come here for guidance and community but instead find rude nerds trying to display their dominance in forum rules knowledge.

Many will not return for a second dose of abuse and for those who do join, a precedent has been set that impolite behavior towards new members is tolerated and accepted/expected.

I personally suspect that this community would flourish if the negative and rude attitudes towards new members were reigned in. You have no way of quantifying how many people read those posts from google search results and decide that they are better off without joining forum.arduino.cc.

Thanks for reading.
Ian
All of you that responded to my original post should take a moment to read the above members thoughts. I'm just trying to interact. I thought I was just being helpful. I took the time and effort to edit a sketch that I found. I made mention in both the post and the sketch the name of the person who made the original sketch. I wasn't trying to piss people off.
With that said, I have been working on the 5 Servo Robotic Arm DIY. I only have 2 of the 5 servos built onto the arm. I'm awaiting additional potentiometers to arrive to complete the build. I will post the project in it's entirety once I have it up and running. Just wanted to see if anyone might be working towards the same pursuit. "Black Flag" me or what ever! Just remember when you started out. And how you were treated.
What comes around, goes around! Everyone have a great day.

// Controlling 5 servos using 5 potentiometers (variable resistor) 
// by Daniel Wright 2010-01-14 (Original)
// Updated by Richard Feist 2023-10-29
// based on the Daniel Wright sketch

#include <Servo.h> 

Servo myservo1;  // create servo object to control the first servo 
Servo myservo2;  // create servo object to control the second servo 
Servo myservo3;  // create servo object to control the third servo
Servo myservo4;  // create servo object to control the forth servo 
Servo myservo5;  // create servo object to control the fifth servo  

int potpin1 = 0;  // analog pin used to connect the first potentiometer
int val1;    // variable to read the value from the first analog pin 
int potpin2 = 1;  // analog pin used to connect the second potentiometer
int val2;    // variable to read the value from the second analog pin 
int potpin3 = 2;  // analog pin used to connect the third potentiometer
int val3;    // variable to read the value from the third analog pin
int potpin4 = 3;  // analog pin used to connect the forth potentiometer
int val4;    // variable to read the value from the forth analog pin
int potpin5 = 4;  // analog pin used to connect the fifth potentiometer
int val5;    // variable to read the value from the fifth analog pin

void setup() 
{ 
  myservo1.attach(3);  // attaches the first servo on pin 3 to the servo object 
  myservo2.attach(5);  // attaches the second servo on pin 5 to the servo object 
  myservo3.attach(6);  // attaches the third servo on pin 6 to the servo object 
  myservo4.attach(9);  // attaches the forth servo on pin 9 to the servo object
  myservo4.attach(10);  // attaches the fifth servo on pin 10 to the servo object
} 


void loop() 
{ 
  val1 = analogRead(potpin1);            // reads the value of the first potentiometer (value between 0 and 1023) 
  val1 = map(val1, 0, 1023, 0, 180);     // scale it to use it with the first servo (value between 0 and 180) 
  myservo1.write(val1);                  // sets the first servos position according to the scaled value 
  delay(15);                           // waits for the first servo to get there 
//  
  val2 = analogRead(potpin2);            // reads the value of the second potentiometer (value between 0 and 1023) 
  val2 = map(val2, 0, 1023, 0, 180);     // scale it to use it with the second servo (value between 0 and 180) 
  myservo2.write(val2);                  // sets the second servos position according to the scaled value 
  delay(15);                           // waits for the second servo to get there 
//  
  val3 = analogRead(potpin3);            // reads the value of the third potentiometer (value between 0 and 1023) 
  val3 = map(val3, 0, 1023, 0, 180);     // scale it to use it with the third servo (value between 0 and 180) 
  myservo3.write(val3);                  // sets the third servos position according to the scaled value 
  delay(15);                           // waits for the second servo to get there
//  
  val4 = analogRead(potpin4);            // reads the value of the forth potentiometer (value between 0 and 1023) 
  val4 = map(val4, 0, 1023, 0, 180);     // scale it to use it with the forth servo (value between 0 and 180) 
  myservo4.write(val4);                  // sets the forth servos position according to the scaled value 
  delay(15);                           // waits for the second servo to get there
//  
  val5 = analogRead(potpin5);            // reads the value of the fifth potentiometer (value between 0 and 1023) 
  val5 = map(val5, 0, 1023, 0, 180);     // scale it to use it with the fifth servo (value between 0 and 180) 
  myservo5.write(val5);                  // sets the fifth servos position according to the scaled value 
  delay(15);                           // waits for the second servo to get there      

}
Have I posted the code above correctly? Trying to learn!

Please just post the code. If necessary, see "How to get the best..." for a refresher on why.

You know I try to be helpful and this is your response. If you don't find what I posted as helpful, then move on! I'm not trying to earn credit in a English class. I created a topic that I thought might be helpful to others. But you take exception! Go do something, Ok. Post something helpful. Or, maybe you could try to explain why you find this post to be somehow inappropriate or worded incorrectly. Here is my advise to you. Shut up!

Meh. The sad reality is, many won't trust a posted file, or bother to read it. If you want readership, expose the code? I wasn't going to potshoot it, I was curious, but since you're combative, we'll just black-flag you and move on.

@rfeist11 Calm down or risk being suspended from the forum for a while

The advice to post the code here is part of the forum guidelines which, as a long standing member of the forum, I would expect you to be aware of

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

I'll make it easy for you Bob. Later

When you reply please tell us what happens when you upload the code, which Arduino you are using and how the servos are powered. Not from the Arduino 5V pin I hope

Always show us a good schematic of your proposed circuit.
Show us good images of your ‘actual’ wiring.
Give links to components.


In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

Use the < CODE / > icon from the ‘posting menu’ to attach the copied sketch.

  • You need to learn when joining a group, that group has rules you need to follow.

  • Scolding volunteers who are here offering free help to you will gain you a reputation. :thinking:

  • The simplest of the rules is to read the posting guidelines before you ask questions.

Are you able to provide a short form of your information request?

No. It won't be powered by 5V pin. I will be using a 9V battery. As for my original post, I really thought I was uploading the code in the correct format. Plus I thought once a person read the code it would be apparent that I would be using the Uno or Nano platform. Seriously it was not my intent to upset anyone. As I have said I will post the project when I have completed it. Because I was no able to find any code on this forum, I just thought I would attempt to help out. Maybe even start up a conversation. Might learn something. Just wasn't ready for the comments that were made. I'm just trying to have a little fun messing with all of the electronics and software. I will try to abide by the rules on this platform.
Thanks for your assistance.

I hope that is not the type that is designed for use in smoke detectors because, if so, it will not last long

To be clear, I was quite taken aback that you thought my comment rude. Why? Because before I responded, I actually looked at your history. You've been a member for 6 years, albeit not a steady participant. So I looked upon you far differently than a new member - perhaps that's my bad, but your history is below. Hardly a new member, I'd be surprised if your participation to date doesn't rank you in the top 5%. So, I expected different(I won't say better).
Hatchet buried, from my viewpoint. And, kudos to you for at least trying to help, and give back!

No. I have misspoke on the 9V battery. I will be using 4-pack 1.5V batteries. This is the first project that I have attempted to use external power to the extent of powering five sg90 servos. Most of my projects up to this point have been fairly simple except for the Ben Eater project "Writing and reading a EEprom 28C16". But after completing it and running a few different sets of hexadecimal values, I decided to delve into a TFT 2.8 Touch screen. Now I'm doing this DIY Robotic Arm. Thanks for your reply back. I have been very fortunate to run into people on this forum that were very helpful. And I certain by the way I express myself, it's pretty clear I am a novice. But I will endeavor to persevere. Thanks for your input.

Yea. I've been off and on the forum for quiet sometime. And I will be more observant on the rules. Thanks for your input.

Sorry for the misunderstanding Larry. It was not my intent to ask a question, just share the code I had created and see what input I might receive back. I will try to follow the rules as closely as possible. Thanks for your input.

Thanks for the help!

Will do!

If you feel that suspending me will help, I guess that is up to you. I don't have any power here. Just trying to interact. Thanks for your input.

A first comment is this can be shortened.
What you have is okay but can be easier.


val1 = map(val1, 0, 1023, 0, 180);

Change to:

val1 = val1 / 4;

  • The sketch below is wrong, / 4 is not what is needed, stick with the original map function
// Controlling 5 servos using 5 potentiometers (variable resistor)
// by Daniel Wright 2010-01-14 (Original)
// Updated by Richard Feist 2023-10-29
// based on the Daniel Wright sketch

#include <Servo.h>

// create servo object to control the servo
Servo myservo1;  
Servo myservo2;  
Servo myservo3;  
Servo myservo4;  
Servo myservo5;  

// analog pin used to connect the potentiometer
const byte potpin1 = A0;  
const byte potpin2 = A1;  
const byte potpin3 = A2;  
const byte potpin4 = A3;  
const byte potpin5 = A4;  

// variable to read the value from the analog pin
int val1;    
int val2;    
int val3;    
int val4;    
int val5;


void setup()
{
  myservo1.attach(3);  // attaches the first servo on pin 3 to the servo object
  myservo2.attach(5);  // attaches the second servo on pin 5 to the servo object
  myservo3.attach(6);  // attaches the third servo on pin 6 to the servo object
  myservo4.attach(9);  // attaches the forth servo on pin 9 to the servo object
  myservo4.attach(10);  // attaches the fifth servo on pin 10 to the servo object
}

void loop()
{
  val1 = analogRead(potpin1);            // reads the value of the first potentiometer (value between 0 and 1023)
  val1 = val1 / 4;                       // scale it to use it with the first servo (value between 0 and 180)
  myservo1.write(val1);                  // sets the first servos position according to the scaled value
  delay(15);                             // waits for the first servo to get there

  val2 = analogRead(potpin2);           
  val2 = val2 / 4;                       
  myservo2.write(val2);                 
  delay(15);                           

  val3 = analogRead(potpin3);           
  val3 = val3 / 4;                       
  myservo3.write(val3);                 
  delay(15);                           

  val4 = analogRead(potpin4);            
  val4 = val4 / 4;                      
  myservo4.write(val4);                  
  delay(15); 
                            
  val5 = analogRead(potpin5);            
  val5 = val5 / 4;
  myservo5.write(val5);                  
  delay(15);                          

}