having problems connecting single servo with push button (pics)

Greetings,
So this is my first project and read/watched a few guides. So now Im pulling the trigger on my project.
Using my Arduino Uno, my goal is to push and hold a button that will move a servo to position. When releasing the button, the servo moves back to original position.

After reading guides, I figured that it would be easier to just use pre-made wiring diagram and sketch of something similar, and just altering it a bit. But doing this, caused some problems and was wondering if someone could help me out to fix or make this work.

The servo im working with is a Corona CS-239HV slim servo
4.6kg / .13sec / 22g
Operating Voltage: 6.0V/7.4V
Operating Current: 300mA / 400mA
Operating Speed: 0.14sec.60º/ 0.13sec.60º
Stall Torque: 4.0kg.cm / 4.6kg.cm
Dead Band: ?5uSec
Operating Travel: 40º/one side pulse traveling 400us
Potentiometer: 3 slider/Direct Drive
Ball bearing: MR85x2
Gear: Metal
Operating Temperature Range: -20c+60c

With my tact button (50mA, 12VDC)

This is how I hooked it up to my Arduino Uno

The sketch I used is this:

#include <Servo.h>

Servo myservo; // create servo object to control a servo
Servo myservo1;

const int buttonPin = 2; // the pin that the pushbutton is attached to
const int ledPin = 5; // the pin that the LED is attached to

int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
int ledState = 0; // remember current led state
int pos = 0; // variable to store the servo positions
int pos1 = 180;

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo1.attach(10); // attaches the servo 1 on pin 10 to the servo object
pinMode(buttonPin, INPUT); // initialize the button pin as a input
pinMode(ledPin, OUTPUT); // initialize the button pin as a output
}

void loop()
{
buttonState = digitalRead(buttonPin); // read the pushbutton input pin
if (buttonState != lastButtonState) // compare buttonState to previous state
{
if (buttonState == 1)
{
if(ledState == 1)
{
delay(30); ledState = 0;
for(pos = 0; pos <= 180; pos += 10) // goes from 0 degrees to 180 degrees
{ // in steps of 10 degrees
myservo.write(pos); // tell servo to go to position ‘pos’
}
for(pos1 = 180; pos1 >= 0; pos1 -= 10) // goes from 180 degrees to 0 degrees
{ // in steps of 10 degrees
myservo1.write(pos1); // tell servo to go to position ‘pos1’
}
delay(15); // waits 15ms for the servo to reach the position
}
else
{
delay(30); ledState = 1;
for(pos = 180; pos >= 0; pos -= 10) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position ‘pos’
}
for(pos1 = 0; pos1 <= 180; pos1 += 10) // goes from 0 degrees to 180 degrees
{
myservo1.write(pos1); // tell servo to go to position ‘pos1’
}
delay(1000);
}
}

lastButtonState = buttonState; // remember the current state of the button
}
// turns LED on if the ledState =1 or off if ledState = 0
digitalWrite(ledPin, ledState);
myservo.write(pos); // goes from 0 degrees to 180 degrees
myservo1.write(pos1); // goes from 180 degrees to 0 degrees

delay(20);
}

The problem I had with this was:

  1. When connected to power, the servo moved but stopped. Nothing happened when button is pressed
  2. When remove button and plugged back in, servo moves but nothing happens when button is pressed
  3. the 10ohm resistor is extremely hot. I quickly removed from power and USB.

Can someone help me?

With the utmost respect, don't expect a huge amount of help with a photo like that as opposed to a schematic... don't expect members to unravel that wiring mentally to see what's going on.

That said, I haven't looked at the code (which by the way should be in # code tags) yet, but I'm assuming the black red and white wires which disappear bottom right are to the servo? If that's the case, it seems you're powering the servo from the breadboard rails which are powered from the Uno by the looks of things.

First you shouldn't do that even with a 4.8-6v servo (which would probably run at 5v, given its own supply) and Second, you shouldn't expect a 6-7.4v servo to run on 5v anyway. Give the servo its own 6-7.4v supply, with the ground of that supply hooked to the Arduino's ground.

Hello,
I apologize and hope this helps a bit. I didnt make this, but its from the same guide. Its originally for two servos and an LED, but Im only using one servo and no LED.

Oh ok, i understand. I was just following the guide, but will give the servo its own power source.

[edit]
I think I understand why this wont work. I made a huge but silly mistake of using a 10ohm instead of a 10kohm.

Cool... yep, that resistor is just the pulldown to keep the D pin at 0v unless the switch is closed. When it's closed, you would have had 5v to ground thru the very small resistor, hence the heat as you found.

But even if it works now, it's really not good to power the servo from the Arduino.... and certainly when you have 2 of them, you'll very likely pop something.

JimboZA:
Cool... yep, that resistor is just the pulldown to keep the D pin at 0v unless the switch is closed. When it's closed, you would have had 5v to ground thru the very small resistor, hence the heat as you found.

But even if it works now, it's really not good to power the servo from the Arduino.... and certainly when you have 2 of them, you'll very likely pop something.

Yeah once I get the correct resistor, I will give the servo its own power source for sure, and give it another shot. Thanks for the help