#2 Апаратні питання » Помогите,'digitalClockDisplay' was not declared in this scope » 2020-04-05 19:38:46

123Oleg
відповідей: 3

Вот скетч:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#include <TimeLib.h>
#include<Time.h>
#include <DS1307RTC.h>
//dvij
#define pirPin 2
int telay = 4;
int pirVal;

void setup() {
Serial.begin(9600);
while (!Serial);
  lcd.init();
  lcd.backlight();
setSyncProvider(RTC.get);
if(timeStatus()!= timeSet)
     {Serial.println("Unable to sync with the RTC");}
  else
     {Serial.println("RTC has set the system time");
pinMode(pirPin, INPUT);
pinMode(telay, OUTPUT);
pinMode(3, OUTPUT);
digitalWrite(3, HIGH);
int pirVal = digitalRead(pirPin);
}
}
void loop(){

if (timeStatus() == timeSet)
    {
      digitalClockDisplay();
   
if(pirVal == HIGH){   
Serial.print(1);
digitalWrite(telay, HIGH);
delay(10000);
}

else {
    digitalWrite(telay, LOW);
 
}
    }
   
   else {
    Serial.println("The time has not been set.  Please run the Time");
    Serial.println("TimeRTCSet example, or DS1307RTC SetTime example.");
    Serial.println();
    delay(4000);
    }
void digitalClockDisplay(){
  // digital clock display of the time
  lcd.print(hour());
  lcd.print(":");
  lcd.print(minute());
  lcd.print(" ");
  lcd.print(year());
  lcd.print("-");
  lcd.print(month());
  lcd.print("-");
  lcd.print(day());
}
}


И вот полная ошибка:
C:\Users\olega\Desktop\podsvetka\dvijenie\dvijenie.ino: In function 'void loop()':

dvijenie:34:7: error: 'digitalClockDisplay' was not declared in this scope

       digitalClockDisplay();

       ^~~~~~~~~~~~~~~~~~~

dvijenie:54:27: error: a function-definition is not allowed here before '{' token

void digitalClockDisplay(){

                           ^

exit status 1
'digitalClockDisplay' was not declared in this scope

smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile smile

Підвал форуму