RTC on Arduino UNO

hey Im new in programming Arduino, so I have a question I wrote a source code for a RTC. But now I have a problem whit bringing the Buttons and the LCD together so does anybody have a Idea how to handle this?

I just want to know how to start my clock whit buton A and stop it whit B.

Thank you

#include <LiquidCrystal.h>
#include <Wire.h>
#include "RTClib.h"
#include <Time.h>

int ledPin = 5;
int buttonApin = 3;
int buttonBpin = 2;
byte leds = 0;

RTC_DS3231 rtc;
//###########################################################LCD Setup
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
while (!Serial);

Serial.begin(9600);
if (! rtc.begin()){
Serial.println("Konnte RTC nicht finde"); //
while(1);
}

Serial.println("RTC hat noch keine Uhrzeit");
rtc.adjust(DateTime(F(DATE), F(TIME))); //Initialisiert Zeit
Serial.println("RTC einstellen");

// #################################################LCD Setup
lcd.begin(16, 2);

//##################################################Button
{
pinMode(ledPin, OUTPUT);
pinMode(buttonApin, INPUT_PULLUP);
pinMode(buttonBpin, INPUT_PULLUP);
}
}
void Taster()
{
if (digitalRead(buttonApin) == LOW)
{
digitalWrite(ledPin, HIGH);
}
if (digitalRead(buttonBpin) == LOW)
{
digitalWrite(ledPin, LOW);
}
}

void zeit() {

DateTime now = rtc.now();
{
lcd.setCursor(0,0);
lcd.print("Date:");
}
{
lcd.setCursor(0,1);
lcd.print("Time:");
}
{
lcd.setCursor(5,0);
lcd.print(now.day());
}
{
lcd.setCursor(7,0); // (now.day());
lcd.print("/");
}
{
lcd.setCursor(8,0);
lcd.print(now.month());
}
{
lcd.setCursor(10,0);
lcd.print('/');
}
{
lcd.setCursor(11,0);
lcd.print(now.year());
}
{
lcd.setCursor(5,1);
lcd.print(now.hour());
}
{
lcd.setCursor(7,1);
lcd.print('/');
}
{
lcd.setCursor(8,1);
lcd.print(now.minute());
}
{
lcd.setCursor(10,1);
lcd.print('/');
}
{
lcd.setCursor(11,1);
lcd.print(now.second());
}
delay(1000);

}

void loop()
{
if (digitalRead(buttonApin) == LOW)
{

}
}

Madmax1234:
I just want to know how to start my clock whit buton A and stop it whit B.

I'm not sure what you mean by starting and stopping your clock, since a real time clock runs all the time.

Do you mean to turn the displaying of the time off and on with those buttons? Or to start and stop some kind of countdown timer?

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

What model Arduino are you using?

Thanks.. Tom... :slight_smile: