Rotation of servo motor

Hi I would like to ask if it is possible to program the rotation of the servo motor 180 degrees for 5 minutes and then back to its original position and do that twice everyday, I heard arduino uno has a built in time, perhaps I could take advantage of that since I cant afford to buy another device just to program the rotation. If not possible, how about dc motor is it also possible? thanks!

Yes

Have a look at the servo sweep example that comes with the Arduino IDE and at how the servo is controlled in the demo Several Things at a Time

...R

In most cases, a servo motor is a DC motor, combined with an h-bridge driver, and some form of feedback. This usually called a SERVO... or specifically...

A ’servo’ is a system of elements combined to form a controlled process. In this case an RC servo performing simple rotation between two points.

The reason an RC servo can move to a position and ‘hold’ that position is due to the internal reduction gear ‘holding’ the last position.

You could use a simple DC motor, but when it’s stopped (no power), it’s very easy to bump the position away... hence the ‘servo’ loop always monitors the feedback and pushes the motor back where it should be.

Moving a servo 180 degrees and back is easy (you'll have to get the right servo because they won't all go a full 180, some only do 120 or 150 degrees).

The bit that needs think about is your timing. How accurate do the 5 minutes and the "twice a day" need to be? Arduinos do have a basic timing mechanism but it isn't exactly very accurate over long periods. That's why anything need timing in hours/days etc will normally use an add-on RTC (real time clock). These are far more accurate and only cost peanuts.

Steve

You should be able to make simple looping code using the millis() function to do what you want to do. Look at the “blink without delay” example to see how it is used. Below is some simple servo test code you can use with the serial monitor to check the servo setup.

// zoomkat 7-30-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

void setup() {
  Serial.begin(9600);
  myservo.attach(9);
}

void loop() {

  while (Serial.available()) {

    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
      delay(3);
    } 
  }

  if (readString.length() >0) {
    Serial.println(readString);
    int n = readString.toInt();
    Serial.println(n);
    myservo.writeMicroseconds(n);
    //myservo.write(n);
    readString="";
  } 
}