Automatic cat feeder update and few questions about servo

Tinkering bit with Arduino nano, got a little grasp about the coding.
Setup is simple Arduino nano controls servo to open and close the valve 4 times a day.
This the code I'm currently running.

#include <Servo.h>
unsigned long time = 21600000;
Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 90;    // variable to store the servo position

void setup() {
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
 {
   delay(1000);                    //valve open time
   }
 for (pos = 45; pos <= 135; pos ++) { // goes from 45 degrees to 135 degrees
   // in steps of 1 degree
   myservo.write(pos);              // tell servo to go to position in variable 'pos'
   delay(15);                       // waits 15ms for the servo to reach the position
 }
 {
   delay(time);                    //valve closed time
   }
 for (pos = 135; pos >= 45; pos --) { // goes from 135 degrees to 45 degrees
   myservo.write(pos);              // tell servo to go to position in variable 'pos'
   delay(15);                       // waits 15ms for the servo to reach the position
 }
}

Few questions about servo, it's humming when it should be idle and there is very little warmth when I touch the servo sides. Should I use external power to supply the servo and where is this humming coming from?
I will try to find CTR to control the time better, but really hard to find these stuff in our country (probably have to order from abroad). But just simple setup I think this would work just fine. By the way, what type of CTR should I look into? is PCF8523 compatible with arduino nano?

Thanks!

You need to power your servo from an external supply. The arduino can not power motors. What servo are you using? Is it 5V? If so, a good choice for a supply is a phone charger.

As for PCF8523, there is an arduino library to support that.

You should also specify your delay as an unsigned long value

unsigned long time = 21600000UL;

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.