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)
{
}
}