Hello,
I am new here. I am working on an automated sprinkler system using ds3231. I chose to use an oled display as the display. but when I try to upload it, there is an error message always.
this is my code,
#include "DS3231lib.h"
#include "Wire.h"
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"
#include "SPI.h"
int Relay = 4;
DS3231lib rtc(SDA, SCL);
Time t;
const int OnHour1 = 06;
const int OnMin1 = 00;
const int OnHour2 = 18;
const int OnMin2 =00;
const int OffHour1 = 06;
const int OffMin1 = 15;
const int OffHour2 = 18;
const int OffMin2 = 15;
void setup() {
Serial.begin(115200);
rtc.begin();
pinMode(Relay, OUTPUT);
digitalWrite(1,OUTPUT);
digitalWrite(Relay, LOW);
SPI.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.display();
testscrolltext();
display.clearDisplay();
display.display();
}
void loop() {
t = rtc.getTime();
display.display(); // this is the error line
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(2);
display.setCursor(20,0);
display.print(" hour - ");
display.print(t.hour);
display.println(" minute - ");
display.print(t.min);
delay (5000);
display.clearDisplay();
display.display();
if(t.hour == OnHour1 && t.min == OnMin1){
digitalWrite(Relay,HIGH);
Serial.println("Sprinkler turning on");
}
else if(t.hour == OffHour1 && t.min == OffMin1){
digitalWrite(Relay,LOW);
Serial.println("Sprinkler turning off");
}
if (t.hour == OnHour2 && t.min == OnMin2 ){
digitalWrite(Relay, HIGH);
Serial.println("Sprinkler turning on");
}
else if (t.hour == OffHour2 && t.min == OffMin2){
digitalWrite(Relay, LOW);
Serial.println("Sprinkler turning off");
}
}
The error message is 'display' was not declared on this scope.
please help me