Using RTC DS3132

Hi everyone, so i'm a complete newbie in arduino, i have a tiny bit of experience with picaxe chips but that's all,

I'm trying to use a rtc module (the DS3132) to make an automatic cat feeder, and i am trying to figure out how to activate the servo on a certain time (like everytime the time is something 10 seconds it turns) so I've been trying different commands but can't get it done.. this is most probably a stupid mistake but as i said... newbie here :slight_smile:

basically my test is:

if (now.seconds() = 10) {

servo.write(90)

else

servo.write(0)

}

but it's not accepting now.seconds() as a number.. it there a way to do this?

if (now.seconds() = 10) {

oops


DS3132 != DS3231


Use CTRL T to format your code.
Attach your ‘complete’ sketch between code tags, use the </> icon in the posting menu.
[code]Paste your sketch here[/code]

oops ^^

here's the code

#include <Wire.h>
#include "RTClib.h"
#include <Servo.h>

RTC_DS3231 rtc;
Servo roue;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () 
{
  roue.attach(5);
  Serial.begin(9600);
  delay(3000); // wait for console opening

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  if (rtc.lostPower()) {
    Serial.println("RTC lost power, lets set the time!");
  
  // Comment out below lines once you set the date & time.
    // Following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  
    // Following line sets the RTC with an explicit date & time
    // for example to set January 27 2017 at 12:56 you would call:
    // rtc.adjust(DateTime(2017, 1, 27, 12, 56, 0));
  }
}

void loop () 
{
    DateTime now = rtc.now();
    
    Serial.println("Current Date & Time: ");
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(" (");
    Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
    Serial.print(") ");
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
    
    if (now.seconds() = 10) {
    roue.write(0);
    delay(470);
    roue.write(90);
    delay(1000);
    }
}

if (now.seconds() = 10) {

Change to:

if (now.second() == 10) {


seconds != second

thank you so much :smiley: i feel kinda stupid lol that was really simple... but hey! that's how you learn :slight_smile: