Hello don`t know how this sh.. is even possible... I am trying to figure out for almost 2 hours where is the problem. I am making pet feeder and I use to control stepper motor with RTC module and Arduino Uno. Yesterday the code worked just fine, today I only edited time when it turns the stepper and suddenly there is no "feeding on" serial message and stepper isn't moving.. I edited it back and still nothing.. Like what the f...?! There are NO ERRORS in the code, same code as yesterday.. Every component is fine nothing is shorting / broken.
#include <DS3231.h>
#include <Stepper.h>
const int stepsPerRevolution = 2050;
Stepper myStepper (stepsPerRevolution, 2, 5, 3, 4);
DS3231 rtc(SDA, SCL);
Time t;
// 1. feeding
const int OnHour = 12;
const int OnMin = 23;
const int OffHour = 12;
const int OffMin = 24;
// 2. feeding
const int OnHourr = 18;
const int OnMinn = 31;
const int OffHourr = 18;
const int OffMinn = 35;
// 3. feeding
//const int OnHour3 = X;
//const int OnMin3 = X;
//const int OffHour3 = X;
//const int OffMin3 = X;
void setup() {
Serial.begin(115200);
rtc.begin();
myStepper.setSpeed(14);
}
void loop() {
t = rtc.getTime();
Serial.print(t.hour);
Serial.print(" hour ,");
Serial.print(t.min);
Serial.print(" minute ,");
Serial.println("");
delay (1000);
if(t.hour == OnHour && t.min == OnMin){
myStepper.step(500);
delay(200);
myStepper.step(-300);
delay(200);
myStepper.step(1000);
delay(200);
myStepper.step(-300);
delay(200);
myStepper.step(1200);
delay(1000);
Serial.println("Feeding on");
}
else if(t.hour == OffHour && t.min == OffMin){
Serial.println("Feeding off");
}
if(t.hour == OnHourr && t.min == OnMinn){
Serial.println("Feeding on");
myStepper.step(500);
delay(200);
myStepper.step(-300);
delay(200);
myStepper.step(1000);
delay(200);
myStepper.step(-300);
delay(200);
myStepper.step(1200);
delay(1000);
}
else if(t.hour == OffHourr && t.min == OffMinn){
Serial.println("Feeding off");
}
//if(t.hour == OnHour3 && t.min == OnMin3){
//Serial.println("Feeding on");
//Feed (3);
// }
//else if(t.hour == OffHour3 && t.min == OffMin3){
//Serial.println("Feeding off");
}
void Feed (int times){
for (int i; i<times; i++) {
myStepper.step(500);
delay(200);
myStepper.step(-300);
delay(200);
myStepper.step(1000);
delay(200);
myStepper.step(-300);
delay(200);
myStepper.step(1200);
delay(1000);
}
}