Urgent help with project

Hi Guys
Trying to make my project work and finding a lot of difficulty

I am trying to connect a servo motor to two buttons where each button makes the servo rotate by 90 degrees

the coding is this:

#include <Servo.h>
Servo myservo;
byte myservoPin = 9;
byte myservoGoOneWayButton = 2; //wire buttons from pin to ground
byte myservoGoOtherWayButton = 3;
byte minPos = 5; //I like to keep away from the end stops
byte maxPos = 175;

void setup()
{
Serial.begin(9600);
Serial.println(".... servo controlled by two buttons ....");
Serial.print("Created: ");
Serial.print(TIME);
Serial.print(", ");
Serial.println(DATE);
Serial.print("File: ");
Serial.println(FILE);

//by default will start at midpoint=90
// uncomment one of these next lines if you want to start at one side
//myservo.write(minPos);
//myservo.write(maxPos);
myservo.attach(myservoPin);

pinMode(myservoGoOneWayButton, INPUT_PULLUP); //wire buttons from pin to ground
pinMode(myservoGoOtherWayButton, INPUT_PULLUP);

Serial.println("press a button..."); Serial.println(" ");
} //setup

void loop()
{
if (digitalRead(myservoGoOneWayButton) == LOW) //buttons with input_pullup are low when pressed
{
myservo.write(minPos);
// this approach just zooms the servo at full speed, see https://www.arduino.cc/en/Tutorial/Sweep if that's a problem
Serial.println("going one way");
}
else if (digitalRead(myservoGoOtherWayButton) == LOW) //buttons with input_pullup are low when pressed
{
myservo.write(maxPos);
// this approach just zooms the servo at full speed, see https://www.arduino.cc/en/Tutorial/Sweep if that's a problem
Serial.println("going other way");
}

} //loop

Finally i have wired the servo to the vin, ground and d9, i have also wired each button to d2 and d3 and both to the same ground, i have also wired the ground to the panel mount barrel jack and also to the vin, when plugged in and turned on the power light on the arduino is lit however the buttons do not work

Any help would be very appreciated

Cheers

Jake

Show us a good schematic of your circuit.
Show us a good image of your wiring.
Give links to components.
Posting images:
https://forum.arduino.cc/index.php?topic=519037.0

And properly posting code

Type
** **[code]** **

Paste your code after that
Type
** **[/code]** **
after that

You haven’t double posted have you?

This is the third thread from a squeaky wheel who in the second one thread asked if he's shit.

Let's see.

  • Has already been given valid answers though maybe after this thread was started.
  • Can't be bothered to read the Read Before Using This Forum even to learn wtf code tags are yet has no problem pushing other members threads off the page to get attention.

If he can't learn and change then maybe he is.

Yeah sorry guys im obviously very inexperienced and realise that im being stupid on here, i didnt mean to cause any hassle so ill stop posting and try to work out how to delete them, sorry again

A moderator will come along, merge the threads and warn ya not to do it again.

Hey, as long as you're not being deliberate and get the How to use this forum - please read. thread.. it really helps because code posted without tags can be interpreted by HTML different to what you want and then it's harder to help you.

You know to not power servos from Arduino pins? LOL to the Arduino Seuss reply! That was GOLD! +1

jakemulvahil:
i have also wired the ground to the panel mount barrel jack and also to the vin

Draw a real schematic and post it. Otherwise we might think you really have done something completely stupid like wiring ground to Vin and shorting everything out.

The servo should not be powered from the Arduino...and even more it should definitely NOT be powered from Vin. Though if you really have shorted Vin to ground I'm not sure there's much more damage left that you can do!

Steve

Talk to this guy - he seems to have a very similar problem, and a very similar phobia of code tags.