Code to program a server motor

so how do I write the code for a server motor that turns clockwise 180 degrees, then back anticlockwise (180 degrees) straight after? and this needs to happen once every hour (to show the passing of time)

First off 'you' need to familiarize yourself with servos and the servo library.
https://arduino-info.wikispaces.com/Servos

Then you need to master the BWD (Blink Without Delay) example found in the IDE.

Next write code to position the servo, wait 60 minutes, then repeat.

.

Hello,

I need the code to program a server motor to turn clockwise 90 degrees, and then back (anticlockwise) 90 degrees (1 second after). This needs to occur once every hour.

help would be appreciated :slight_smile:

thanks.

Do you mean 'servo motor'? If so, then you can use the built-in servo example code on the Arduino IDE (Open>Servo>Sweep) and modify it to do what you want. The once every hour part might require some math, because the Arduino boards generally operate in milliseconds.

-Dangerously Explosive

Hi,

Files, Examples, Servo.

There are two examples there that will help you.

Is this post the same as this?

http://forum.arduino.cc/index.php?topic=464293.msg3204575#msg3204575

Tom... :slight_smile:

@caitlinlh, please do not cross-post. Threads split / merged.

As I mentioned in the other thread, BlinkWithoutDelay may be useful. But if the sketch needs literally to only move the servo every hour and never do anything else, then the technique in File > Examples > Basic > Blink will show how to delay for whatever time. Then instead of turning the LED off or on, you move the servo one way or the other.

You have to do some of the work here: nobody's likely to post you a fully working example. But if you try something and get stuck, and explain what you're stuck with and describe what your sketch is (not) doing, you'll probably get loads of assistance.

And something that many of the tutorials do not show - do not power your servo from the Arduino. Give it a power source that can provide the needed current. The specs on the servo will list that.

vinceherman:
And something that many of the tutorials do not show - do not power your servo from the Arduino.

In fact the IDE tutorials show that you may
> vinceherman:
> .... provide the needed current. The specs on the servo will list that.
Very few servo spec sheets give the current, that I've seen anyway. It can be calculated from three numbers always quoted though, the torque, rotation speed and voltage.

S/he does not seem to have got the message

...R