fish feeder

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);
}

Don't be afraid to try it!

Paul

I don't think you want to initialize the Serial port to 9600 and then 4 lines later initialize it again to 9200.

Your if() statement within loop() does not contain brackets '{}' so there is only 1 statement that will be executed if the if() statement is true (the print statement). All the other statements will always be executed (e.g. your stepper will run every time through the loop).

i removed the 9200, i dont understand what u mean by the brackets. can u show me?
I tried it but it does not work

Indenting code does not define a code block in arduino IDE.

You need to enclose the code to be executed when if() = true within braces {} to define it as a code block.

Willem.

void loop()
{
   if(yaddaYadda == whatever)
      {
         //place everything you want to happen when
         //your IF is true between curly brackets
       }
}