hi i want to run my auger based fish feeder by a stepper motor at various specific times . later i would also like to add a button so that the stepper wil keep running as long as the button is pressed.
wil my code work? im veery new at this
thanks.
#include <DS1302.h>
#include <Stepper.h>
const int stepsPerRevolution = 2048;
// Create stepper object called 'myStepper', note the pin order:
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);
Time t;
int Hour;
int Min;
int Sec;
// Init the DS1302
DS1302 rtc(2, 3, 4);
void setup()
{
// Set the speed to 5 rpm:
myStepper.setSpeed(5);
// Begin Serial communication at a baud rate of 9600:
Serial.begin(9600);
// Set the clock to run-mode, and disable the write protection
rtc.halt(false);
rtc.writeProtect(false);
Serial.begin(9200);
// The following lines can be commented out to use the values already stored in the DS1302
rtc.setDOW(SUNDAY); // Set Day-of-Week to SUNDAY
rtc.setTime(9, 59, 50); // Set the time to 12:00:00 (24hr format)//8
rtc.setDate(1, 15, 2020); // Set the date to August 25th, 2019
}
void loop()
{
t = rtc.getTime();
Hour = t.hour;
Min = t.min;
Sec = t.sec;
// Serial.print(Hour);
// Serial.print(":");
// Serial.print(Min);
// Serial.print(":");
// Serial.println(Sec);
//set the time for fish feeding
if ((Hour== 10 && Min== 5 && Sec== 2)||(Hour== 10 && Min== 10 && Sec== 2))
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(500);
}