mbasile:
what should i enter then for the time if it was say 6:38pm? thats 1838hrs military time, thats why i put that, obviously i was wrong.
Well, if the DateTime library is where you are getting the hour from, maybe you could go look at that and THINK about it. Or I guess you could just ask and make us tell you that there is also a minutes function.
@BulldogLowell's code was for your original specification that it should happen at 6 oclock. Now you want it between 6 and 7, so you're going to have to do some more thinking. His code isn't going to work if you're not looking for the point where the hour just changed. You're going to have to think about how to write this differently to look at hours and minutes.
mbasile:
what should i enter then for the time if it was say 6:38pm? thats 1838hrs military time, thats why i put that, obviously i was wrong.
So, looking at @BulldogLowell's code where he just used 6 and 18, do either of those look like he was talking about military time? Or just the hour part of it? If it were military time don't you think he would have used 600 and 1800?
Again, this is going to require some thought on your part.
just tried to implement the code with the motor.. the only thing that happened was the seconds dissapeared from the lcd and it said "time" but no motor spin
if anyone could offer assistance as to why the motor still wont turn on and why i cant get it to turn on at 10am and at 630pm for 30 seconds at a time..... i really need some help and i have done a ton of research that still hasnt helped much
You've got a dozen or more other lines in this sketch to print to the LCD. If you really can't figure out how to add one to that function then this project is way over your head and you need to go back and study the basics and stop asking us to write this for you. I would suggest making it the first line in that function and putting a delay of a second or two after it to make sure you have time to see it. You can take it out after you know that function is being called.
Alright, so now you know that function is being called. Now move it inside the if(millis... right after where it is now and see if it is getting into that if.
Do you see what we are doing here? Tracking down where the code is going?
i understand what we are trying to do, but i am confused as to how to print the function inside of the milis... i just tried and got a error preventing me from running it.
im sure i did not put it in the right place, i tried putting it under the if statement but that didnt work, this was the only way to not have an error that i found... and it just had the same result as the last run....
mbasile:
i understand what we are trying to do, but i am confused as to how to print the function inside of the milis... i just tried and got a error preventing me from running it.
something like this (untested, to make it even more fun):
if by does the motor run when i write high or low, when i put in a code to simply run the motor high and low, (a seperate code) yes the motor runs,
i made these changes to the code and the only thing that changed was when it used to override the seconds on the lcd display, it now reads part of the "turnFeeder"
void loop ()
{
DateTime now = RTC.now();
int currentHour = now.hour();
int currentMinute = now.minute();
if (lastHour != currentHour && (currentHour == 9 || currentHour == 21)) // if the hour just changed to 6 or 18
if (lastMinute != currentMinute && (currentMinute == 57)) //if the minute is 30
{
feedTime = millis();
feedPet = true;
lastHour = currentHour;
lastMinute = currentMinute;
}
if (feedPet)
{
turnFeeder();
}
lcd.setCursor(0, 1);
lcd.print("Time: ");
lcd.print(now.hour(), DEC);
lcd.print(":");
lcd.print(now.minute(), DEC);
lcd.print(":");
lcd.print(now.second(), DEC);
lcd.print(" ");
if (millis() - lastPrintTime > 1000UL)
{
lcd.setCursor(0, 0);
lcd.print("DATE: ");
lcd.print(now.month(), DEC);
lcd.print("/");
lcd.print(now.day(), DEC);
lcd.print("/");
lcd.print(now.year(), DEC);
lastPrintTime = millis();
}
}
void turnFeeder(void)
{
static byte pinState = HIGH;
if (millis() - feedTime < 6000UL) // 60 seconds
{
if (pinState == HIGH)
lcd.setCursor(0, 0);
lcd.print("turnFeeder");
{
digitalWrite(motorPin, pinState);
pinState = LOW;
}
}
else
{
digitalWrite(motorPin, pinState);
pinState = HIGH;
feedPet = false;
}
}