Variables from RTC

Hey everyone,

with this Code i can write the time on the "Serial Monitor"

//###################################################################
//#
//# Basis Programm von adafruit
//# Check Understanding the Code | DS1307 Real Time Clock Breakout Board Kit | Adafruit Learning System
//#
//#
//#
//###################################################################

// Einfügen der Bibliotheken
#include <Wire.h>
#include <RTClib.h>
RTC_DS1307 RTC;

// Variabel deklarieren
int Blau = 9; // LED Pin 9 = Blau
int Warmweiss = 10; // LED Pin 10 = Warmweiss
int Kaltweiss = 11; // LED Pin 11 = Kaltweiss
int brightness = 0; // Helligkeit der LED
int fadeAmount = 5; // In was für schritten soll die LED gedimmt werden
const byte UP_H = 9; // Konstante "Licht an Stunde"
const byte UP_M = 15; // Konstante "Licht an Minute"
const byte DN_H = 21; // Konstante "Licht aus Stunde"
const byte DN_M = 30; // Konstante "Licht aus Minute"
static int fadevalue = 255; // Standard Tages Wert
static int fading = 0 ; // 1 ... 2040 = up , -2040 ... -1 = down, 0 = fadevalue bleibt stehen

//########## Programm vorbereitungen
void setup ()
{
Serial.begin(57600); //Serial Monitor mit einer Baudrate von 57600 ansteuern
Wire.begin(); // ?!?!?!?!?!?
RTC.begin(); //Uhrzeit ausgabe starten

// Pins deklarieren
pinMode (Blau, OUTPUT); // Pin 9 als Ausgang deklariert
pinMode (Warmweiss, OUTPUT); // Pin 10 als Ausgang deklariert
pinMode (Kaltweiss, OUTPUT); // Pin 11 als Ausgang deklariert
}
//########## Programm Zyklus
void loop ()

//## Uhrzeit auf dem Serial Monitor ausgeben
{
DateTime now = RTC.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();

//## Dimmen der LEDs

if ( now.minute > UP_M ) analogWrite(Warmweiss, brightness);
analogWrite(Warmweiss, brightness); // set the brightness of pin 9:
brightness = brightness + fadeAmount; // change the brightness for next time through the loop:
if (brightness == 0 || brightness == 255) { // reverse the direction of the fading at the ends of the fade:
fadeAmount = -fadeAmount ;
}

delay(1000); //Eine Sekunge warten bis der nächste Programm Zyklus startet
}

But when i want to work with "now.hour" or something else i geht Errors... i think i must declare this right, but i found nothing that helps me.

Try

if ( now.minute**()** > UP_M ) analogWrite(Warmweiss, brightness);

Thank you, it works! :slight_smile: