I need help with TimeLib

I was planning to make a time control with an Arduino One.
All well and good.
I have set pin 2 to be switched on for 10:30.
At 20:30 it also switched on. What could be the problem?
Thanks in advance.

The problem is in the code. Post it, using code tags.

void time() {
  tmElements_t tm;
  if (RTC.read(tm)) {
    if (tm.Hour = 10) {
      if (tm.Minute == 00) {
        digitalWrite(2, LOW);
      }
      if (tm.Minute == 30) {
        digitalWrite(2, HIGH);
      }
      if (tm.Minute == 29) {
        digitalWrite(3, LOW);
      }
      if (tm.Minute == 59) {
        digitalWrite(4, LOW);
      }

    }

    if (tm.Hour = 11) { 
      if (tm.Minute == 00) {
        digitalWrite(3, HIGH);
      }
      if (tm.Minute == 30) {
        digitalWrite(4, HIGH);
      }
    }


  } else {
    if (RTC.chipPresent()) {
      Serial.println("The DS1307 is stopped.  Please run the SetTime");
      Serial.println("example to initialize the time and begin running.");
      Serial.println();
    } else {
      Serial.println("DS1307 read error!  Please check the circuitry.");
      Serial.println();
    }
    delay(1000);
  }
  delay(1000);
}

If you are using this TimeLib: https://www.pjrc.com/teensy/td_libs_Time.html
Then there is a TimeAlarms library: https://www.pjrc.com/teensy/td_libs_TimeAlarms.html

When the Arduino is turned on, you have to check in your setup() function if something needs to be on at that moment. That is not automatically done.

Set the RTC to 24 hour mode. Always post ALL the code.

Hint: it is much easier to use "minutes past midnight" for alarms and switch closures.

I can't find out
how do I change it to 24h mode?

Why have you not posted all your code, and have not identified the libraries you are using?

wait a second

#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#include <IRremote.h>
IRrecv irrecv(11);
decode_results results;

void setup() {
  Serial.begin(9600);
  Serial.println("\n@wofuername\n\n");
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(13, OUTPUT);
  digitalWrite(2, HIGH);
  digitalWrite(3, HIGH);
  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(13, LOW);
  irrecv.enableIRIn();
}

void loop() {
time();
{

if (irrecv.decode(&results)) {


if(results.value == 16738455){
  if(digitalRead(2) == 1){
    digitalWrite(2, LOW);
    } else {
     digitalWrite(2, HIGH);
    }
  }
  
if(results.value == 16750695){
  if(digitalRead(3) == 1){
    digitalWrite(3, LOW);
    } else {
     digitalWrite(3, HIGH);
    }
  }
  
if(results.value == 16756815){
  if(digitalRead(4) == 1){
    digitalWrite(4, LOW);
    } else {
     digitalWrite(4, HIGH);
    }
  }
  
if(results.value == 16724175){
  if(digitalRead(5) == 1){
    digitalWrite(5, LOW);
    } else {
     digitalWrite(5, HIGH);
    }
  }
  
if(results.value == 16718055){
  if(digitalRead(6) == 1){
    digitalWrite(6, LOW);
    } else {
     digitalWrite(6, HIGH);
    }
  }

if(results.value == 16743045){
  if(digitalRead(7) == 1){
    digitalWrite(7, LOW);
    } else {
     digitalWrite(7, HIGH);
    }
  }

if(results.value == 16716015){
  if(digitalRead(8) == 1){
    digitalWrite(8, LOW);
    } else {
     digitalWrite(8, HIGH);
    }
  }

if(results.value == 16728765){
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
  }


  
irrecv.resume();

}
  } }
void time() {
  tmElements_t tm;
  if (RTC.read(tm)) {
    if (tm.Hour = 10) {
      if (tm.Minute == 00) {
        digitalWrite(2, LOW);
      }
      if (tm.Minute == 30) {
        digitalWrite(2, HIGH);
      }
      if (tm.Minute == 29) {
        digitalWrite(3, LOW);
      }
      if (tm.Minute == 59) {
        digitalWrite(4, LOW);
      }

    }

    if (tm.Hour = 11) { // Prüft Stunde
      if (tm.Minute == 00) {
        digitalWrite(3, HIGH);
      }
      if (tm.Minute == 30) {
        digitalWrite(4, HIGH);
      }
    }


  } else {
    if (RTC.chipPresent()) {
      Serial.println("The DS1307 is stopped.  Please run the SetTime");
      Serial.println("example to initialize the time and begin running.");
      Serial.println();
    } else {
      Serial.println("DS1307 read error!  Please check the circuitry.");
      Serial.println();
    }
    delay(1000);
  }
  delay(1000);
}

== for comparison

You have several of these errors.

thanks :slight_smile:
i try it out tomorrow

Those are always true. You meant to write:
if (tm.Hour == 10) {
if (tm.Hour == 11) { // Prüft Stunde

It's a common error. Some programming languages use '=' for both assignment and comparison. C and C++ use '=' for assignment and '==' for comparison.