I have a clock sketch using 60 Neopixel LEDs and a OLED display. The sketch compiles but doesn't run in a Nano, it does in a Mega. I was running out of memory so it was recommended to try using a Nano Every. I added the Every using the board manager but now when it goes to compile I get the following error.
Arduino: 1.8.9 (Windows 10), Board: "Arduino Nano Every, ATMEGA328"
Build options changed, rebuilding all
In file included from C:\Users\lampo\Documents\Arduino\My_Test_Clock_OLED\My_Test_Clock_OLED.ino:4:0:
C:\Users\lampo\Documents\Arduino\libraries\FastLED\src/FastLED.h:14:21: note: #pragma message: FastLED version 3.004.000
# pragma message "FastLED version 3.004.000"
^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from c:\users\lampo\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:677:0,
from c:\users\lampo\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,
from C:\Users\lampo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/String.h:31,
from C:\Users\lampo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/Print.h:24,
from C:\Users\lampo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/Stream.h:25,
from C:\Users\lampo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/Client.h:22,
from C:\Users\lampo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/ArduinoAPI.h:29,
from C:\Users\lampo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/Arduino.h:23,
from sketch\My_Test_Clock_OLED.ino.cpp:1:
My_Test_Clock_OLED:11:12: error: expected ')' before '*' token
RTC_DS3231 RTC; // Establishes the chipset of the Real Time Clock
^
My_Test_Clock_OLED:11:12: error: expected ')' before '*' token
C:\Users\lampo\Documents\Arduino\My_Test_Clock_OLED\My_Test_Clock_OLED.ino: In function 'void setup()':
My_Test_Clock_OLED:45:7: error: 'RTC_t {aka struct RTC_struct}' has no member named 'begin'
RTC.begin(); // Starts communications to the RTC
^~~~~
My_Test_Clock_OLED:53:22: error: 'RTC_t {aka struct RTC_struct}' has no member named 'now'
DateTime now = RTC.now();
^~~
C:\Users\lampo\Documents\Arduino\My_Test_Clock_OLED\My_Test_Clock_OLED.ino: In function 'void loop()':
My_Test_Clock_OLED:73:22: error: 'RTC_t {aka struct RTC_struct}' has no member named 'now'
DateTime now = RTC.now(); // Fetches the time from RTC
^~~
C:\Users\lampo\Documents\Arduino\My_Test_Clock_OLED\My_Test_Clock_OLED.ino: In function 'void updateDisplay()':
My_Test_Clock_OLED:113:22: error: 'RTC_t {aka struct RTC_struct}' has no member named 'now'
DateTime now = RTC.now(); // Fetches the time from RTC
^~~
exit status 1
expected ')' before '*' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I have read of others having similar problems but none seem to be what this problem is. Here's my sketch
[code]
// My test clock
// added OLED display
#include <FastLED.h> // FastSPI Library from http://code.google.com/p/fastspi/
#include <Wire.h> //This is to communicate via I2C. On arduino Uno & Nano use pins A4 for SDA (yellow/orange) and A5 for SCL (green). For other boards ee http://arduino.cc/en/Reference/Wire
#include <RTClib.h> // Include the RTClib library to enable communication with the real time clock.
// Include Adafruit Graphics & OLED libraries
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
RTC_DS3231 RTC; // Establishes the chipset of the Real Time Clock
// Reset pin not used but needed for library
#define OLED_RESET 4
//Adafruit_SSD1306 display(OLED_RESET);
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define LEDStripPin 6 // Pin used for the data to the LED strip
#define menuPin 0 // Pin used for the menu button (green stripe)
#define numLEDs 60 // Number of LEDs in strip
// Setting up the LED strip
struct CRGB leds[numLEDs];
int timeHour;
int timeMin;
int timeSec;
int LEDOffset = 0;
long int updateTime = millis();
int updateDelay = 1000;
void setup() {
// Start LEDs
LEDS.addLeds<WS2811, LEDStripPin, GRB>(leds, numLEDs); // Structure of the LED data. I have changed to from rgb to grb, as using an alternative LED strip. Test & change these if you're getting different colours.
LEDS.setBrightness(10);
// Start RTC
Wire.begin(); // Starts the Wire library allows I2C communication to the Real Time Clock
RTC.begin(); // Starts communications to the RTC
// initialize OLED with I2C addr 0x3C
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
Serial.begin(9600); // Starts the serial communications
// create a loop that calcuated the number of counted milliseconds between each second.
DateTime now = RTC.now();
Serial.print("Hour time is... ");
Serial.println(now.hour());
Serial.print("Min time is... ");
Serial.println(now.minute());
Serial.print("Sec time is... ");
Serial.println(now.second());
Serial.print("Year is... ");
Serial.println(now.year());
Serial.print("Month is... ");
Serial.println(now.month());
Serial.print("Day is... ");
Serial.println(now.day());
} // end void setup
void loop() {
DateTime now = RTC.now(); // Fetches the time from RTC
// clear LED array
memset(leds, 0, numLEDs * 3);
unsigned char hourPos = ((now.hour() % 12) * 5 + (now.minute() + 6) / 12);
leds[(hourPos + LEDOffset + 59) % 60].r = 255;
leds[(hourPos + LEDOffset + 59) % 60].g = 0;
leds[(hourPos + LEDOffset + 59) % 60].b = 0;
leds[(hourPos + LEDOffset) % 60].r = 255;
leds[(hourPos + LEDOffset) % 60].g = 0;
leds[(hourPos + LEDOffset) % 60].b = 0;
leds[(hourPos + LEDOffset + 1) % 60].r = 255;
leds[(hourPos + LEDOffset + 1) % 60].g = 0;
leds[(hourPos + LEDOffset + 1) % 60].b = 0;
leds[(now.minute() + LEDOffset) % 60].r = 0;
leds[(now.minute() + LEDOffset) % 60].g = 255;
leds[(now.minute() + LEDOffset) % 60].b = 0;
leds[(now.second() + LEDOffset) % 60].r = 0;
leds[(now.second() + LEDOffset) % 60].g = 0;
leds[(now.second() + LEDOffset) % 60].b = 255;
// Update LEDs
LEDS.show();
if (millis() > (updateTime + updateDelay))
{
updateDisplay();
updateTime = millis();
} // end updateDisplay time
} // end void loop
void updateDisplay() {
DateTime now = RTC.now(); // Fetches the time from RTC
// Clear the display
display.clearDisplay();
//Set the color - always use white despite actual display color
display.setTextColor(WHITE);
//Set the font size
display.setTextSize(2);
//Set the cursor coordinates
display.setCursor(0, 10);
// display.print("Time");
display.setCursor(10, 15);
display.print(now.hour());
display.print(":");
display.print(now.minute());
display.print(":");
display.print(now.second());
display.setCursor(0, 40);
// display.print(F("Date"));
display.setCursor(10, 45);
display.print(now.month());
display.print("/");
display.print(now.day());
display.print("/");
display.print(now.year());
display.display(); // Update screen
} // end updateDisplay
[/code]
Thanks for the help
John