1

Ok, newguy with a little VBA coding experience going to pull hair out soon. It is probably a simple thing I have missed but I would like someone to point out where I went wrong. I modified a sketch that used an lcd to use the serial monitor instead but I sometimes run into this "not declared in this scope" issue. Doing something wrong, please point me in the correct direction.

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

RTC_DS3231 rtc;
DateTime now;
char daysOfTheWeek[7][12] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};

void showDate(void);
void showTime(void);
void showDay(void);

void showDate()
{
  serial.print(now.day());
  serial.print('/');
  serial.print(now.month());
  serial.print('/');
  serial.print(now.year());
}

void showDay()
{
  serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
}

void showTime()
{
  serial.print("Time:");
  serial.print(now.hour());
  serial.print(':');
  serial.print(now.minute());
  serial.print(':');
  serial.print(now.second());
  serial.print("    ");
}

void setup ()
{
Serial.begin(9600);

  serial.println("working....")
  //wire.begin();
  //delay(2000);
  if (! rtc.begin())
  {
    Serial.println("Couldn't find RTC Module");
    while (1);
  }

  if (rtc.lostPower())
  {
    Serial.println("RTC lost power, lets set the time!");
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}


void loop ()
{
  now = rtc.now();
  showDate();
  showDay();
  showTime();
}
0
3

Case matters in C/C++. You should write Serial rather than serial.

4
  • OMG, I will not live that down!!!
    – retiredguy
    Jan 15 '19 at 16:35
  • Sorry, I will be more careful with that. I am used to VBA where if you @@$ up syntax it highlights it. Thanks for your quick answer. Hiding head now, lol
    – retiredguy
    Jan 15 '19 at 16:36
  • As a nebie I also noticed that when syntax is valid the color of the code is red/orange. Are functions highlighted in the IDE?
    – retiredguy
    Jan 15 '19 at 16:46
  • Built-in functions appear to be highlighted in orange, reserved words in blue-ish. Strings in Green-ish? Pretty sure it doesn't parse your code to highlight specific to your project. Jan 15 '19 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.