enter image description hereHello. Currently I'm working on creating an automatic dog food dispenser. I'm using a Arduino Uno R3, an L298N stepper driver, a DS1307 RTC breakout board, a Nema 17 stepper motor, and a breadboard to disperse the power to each board. I'm using a 9V battery to power it temporarily. I've tested motor control without it being determined by the current time and it works perfectly however when I have the motor run at a specific time (4:45 and 6:45 in the code) the motor doesn't move. How can I move the motor at these specific times?

#include <RTClib.h>
#include <Stepper.h>
#include <SoftwareSerial.h>

RTC_DS1307 rtc;

Stepper myStepper(200 , 9 , 10 , 11 , 12);

void setup() {                                                
  rtc.adjust(DateTime(2021 , 7 , 14 , 4 , 44 , 0));

void loop() {

  DateTime now = rtc.now();

  if ((now.hour() == 4 and now.minute() == 45) or (now.hour() == 6 and now.minute() == 45)) {



2 Answers 2


You are pushing the limit of the L298N, probably will exceed it. A typical stepper motor like a NEMA 17 is probably rated at voltage of about 2.8 Volts and a maximum current of 1.68 Amps. This basically means if you hook it up to 2.8 Volts it will draw 1.68 Amps. If you try to run it at a higher voltage it will draw more current and get excessively hot. Driver Model: L298N has a Motor Supply Current (Maximum): 2A, Logic Voltage: 5V, Driver Voltage: 5-35V. The motor was rated at about 2.8V, powering it with more will very quickly exceed your bridge capacity. The Arduino will give you 5V and 3.3V but using either to power your motor will probably destroy the Arduino. The Arduino a power supply it is NOT! I suggest you use a seperate power supply for the motor. If you power the Arduino via Vin and use a buck converter from the 12V it should work fine.

  • Could I run a 9V battery into a breadboard and have both the motor and arduino using the same power supply?
    – Carter
    Jul 15, 2021 at 2:00
  • @Carter If you mean those standard 9V block batteries, then no. They barely provide enough current for the Arduino itself, let alone any motor.
    – chrisl
    Jul 15, 2021 at 8:09

I’m new at this but looks to me like your rtc is uses i2c comms. I don’t see that you’ve included wire.h or issued the wire.begin to initiate communication between the rtc and arduino. See other rtc examples and good luck!

  • I'm new at this also and I found a few examples (all of which using an lcd screen) using wire.h but thought they were linked to the lcd. Its good to know that my guess was incorrect. Thanks for your help!
    – Carter
    Jul 15, 2021 at 3:49
  • No problem. Will be curious if that solves the issue. Thanks.
    – Vince
    Jul 15, 2021 at 4:35
  • 1
    The I2C communication is probalby already done by the RTC library. Thus there is no need for Wire in the main sketch
    – chrisl
    Jul 15, 2021 at 8:11
  • @chrisl. You would think, but RTClib shows wire as a dependency.
    – Vince
    Jul 15, 2021 at 13:30
  • 1
    @Vince The point is that RTClib already #includes Wire.h. You only need to include libraries where they are used. Since Wire is not called in the main sketch, it doesn't need to be included there. Wire is called in the RTClib library, so that it included it at the start of its implementation.
    – chrisl
    Jul 15, 2021 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.