Jump to content

Ardunio not working with Servo

Hey guys, I'm new to Arduino and I can't seem to figure out how to get my servo working, making a RFID door lock. I loaded everything successfully to the board however nothing happens... The servo is between 4.8 and 5 volts, I attached a 12 volt back just for some extra power, not sure you can do that... Not sure it matters but my board is an elegoo uno r3, a clone but I heard good things about them and it was cheaper than an Arduino. Thanks for any help in advance.

 

 

#include <Servo.h>

Servo myservo;

void setup() {
  myservo.attach(7);
  // put your setup code here, to run once:

}

void loop() {
  myservo.write(170);
  delay(1000);
  myservo.write(10);
  delay(100);
  // put your main code here, to run repeatedly:

}

20170723_222629.thumb.jpg.fbfd4dcefb4e525e5627765553cee1ee.jpg

 

Link to comment
Share on other sites

Link to post
Share on other sites

I'd add some decoupling caps on that breadboard, let's say 100uF and 100nF in parallel on the servo power supply. Should help keep the servo noise away from the microcontroller.

Link to comment
Share on other sites

Link to post
Share on other sites

I would suggest using pin 9 or 10 for the servo, as when you use the servo library, both pins PWM control is removed for some reason, even if you aren't using those pins for the servo, minor gripe but if you are doing other things with the arduino at the same time, which includes PWM (analogwrites, etc.) then it is best not to use them for the servo in order for you to get the maximum remaining PWM pins for other things

The owner of "too many" computers, called

The Lord of all Toasters (1920X 1080ti 32GB)

The Toasted Controller (i5 4670, R9 380, 24GB)

The Semi Portable Toastie machine (i7 3612QM (was an i3) intel HD 4000 16GB)'

Bread and Butter Pudding (i7 7700HQ, 1050ti, 16GB)

Pinoutbutter Sandwhich (raspberry pi 3 B)

The Portable Slice of Bread (N270, HAHAHA, 2GB)

Muffinator (C2D E6600, Geforce 8400, 6GB, 8X2TB HDD)

Toastbuster (WIP, should be cool)

loaf and let dough (A printer that doesn't print black ink)

The Cheese Toastie (C2D (of some sort), GTX 760, 3GB, win XP gaming machine)

The Toaster (C2D, intel HD, 4GB, 2X1TB NAS)

Matter of Loaf and death (some old shitty AMD laptop)

windybread (4X E5470, intel HD, 32GB ECC) (use coming soon, maybe)

And more, several more

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×