I managed to eliminate a number of errors in my code but I have two left. I have been working on them for a while now but I just can't figure them out.
Here are the errors:
E:\My 60 Pixel Ring Clock Version 3\My_60_Pixel_Ring_Clock_Version_3\My_60_Pixel_Ring_Clock_Version_3.ino: In function 'void loop()':
My_60_Pixel_Ring_Clock_Version_3:129:71: error: 'getTimeDate' was not declared in this scope
getTimeDate(yearval, monthval, dayval, hourval, minuteval, secondval) {
^
My_60_Pixel_Ring_Clock_Version_3:129:73: error: expected ';' before '{' token
getTimeDate(yearval, monthval, dayval, hourval, minuteval, secondval) {
^
exit status 1
'getTimeDate' was not declared in this scope
Here is the code:
//My 60 Pixel Ring Clock Version 3
//March 15, 2019 9:23p.m.
//#include <Wire.h>
#include <Adafruit_NeoPixel.h>
#include <NTPClient.h>
#include <ESP8266WiFi.h>
#include <WiFi.h>
#include <WiFiUdp.h>
#define PIN 4
#define PIXEL 60
#define getNTPtime
int LED = 0;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL, PIN, NEO_GRB + NEO_KHZ800);
int hourval, minuteval, secondval, yearval, monthval, dayval;
//Variables to save date and time
String formattedDate;
String dayStamp;
String timeStamp;
//Assign SSID and Password to a constant
const char* ssid = "mySSID"; // your network SSID (name)
const char* password = "myPassword"; // your network password
//Define NTP client to get time
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP);
void setup() {
//Initialize the serial monitor
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
//Initialize an NTPClient to get time
timeClient.begin();
//Set offset time in seconds to adjust for current time zone
timeClient.setTimeOffset(18000);
while (timeClient.update()) {
timeClient.forceUpdate();
}
//Call the function to get time and date
getTimeDate();
//Used to verify values of variables holding time and date.
//Comment out before uploading permanently
Serial.print("The year is: ");
Serial.println(yearval);
Serial.print("Month is: ");
Serial.println(monthval);
Serial.print("Day is: ");
Serial.println(dayval);
Serial.println("");
Serial.print("The hour is: ");
Serial.println(hourval);
Serial.print("Minute is: ");
Serial.println(minuteval);
Serial.print("Second is: ");
Serial.println(secondval);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
strip.setBrightness(20);
}
void loop() {
switch (hourval) { //Synchronize the LEDs for 12 hour clock.
case 1: case 13:
LED = 5;
break;
case 2: case 14:
LED = 10;
break;
case 3: case 15:
LED = 15;
break;
case 4: case 16:
LED = 20;
break;
case 5: case 17:
LED = 25;
break;
case 6: case 18:
LED = 30;
break;
case 7: case 19:
LED = 35;
break;
case 8: case 20:
LED = 40;
break;
case 9: case 21:
LED = 45;
break;
case 10: case 22:
LED = 50;
break;
case 11: case 23:
LED = 55;
break;
case 12: case 0:
LED = 0;
break;
}
strip.setPixelColor(minuteval, 0x008000); // Turn on LED for minutes.
strip.setPixelColor(secondval, 0x0000ff); // Turn on LED for seconds.
strip.setPixelColor(LED, 0xff0000); // Turn on LED for hours.
strip.show();
strip.setPixelColor(LED, 0x000000); // Turn off LED for minutes.
strip.setPixelColor(minuteval, 0x000000); // Turn off LED for seconds.
strip.setPixelColor(secondval, 0x000000); // Turn off LED for hours.
//Function to separate time and date from formattedDate string and assign to variables
getTimeDate(yearval, monthval, dayval, hourval, minuteval, secondval) {
/*The formattedDate comes with the following format:
2019-03-28T16:00:13Z
We need to extract the date and time
*/
formattedDate = timeClient.getFormattedDate();
//Extract date
int splitT = formattedDate.indexOf("T");
dayStamp = formattedDate.substring(0, splitT);
//Extract time
timeStamp = formattedDate.substring(splitT + 1, formattedDate.length() - 1);
char theyear = dayStamp.substring(0, 4);
char themonth = dayStamp.substring(5, 7);
char theday = dayStamp.substring(9, 11);
char thehour = timeStamp(0, 2);
char theminute = timeStamp.substring(3, 5);
char thesecond = timeStamp.substring(6, 8);
//Convert string to integer and assign date to variables theyear, themonth, theday
yearval = theyear.toint();
monthval = themonth.toint();
dayval = theday.toint();
///Convert string to integer and assign time to variables hourval, minuteval, secondval
hourval = thehour.toint();
minuteval = theminute.toint();
secondval = thesecond.toint();
}
}