Hi All,
I'm having trouble getting this code to work...can anyone shed some light?
/*
* Christmas.ino
* countdown the days, hours and minutes till christmas.
*/
#include <Time.h>
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 rtc;
//Libraries for Dot Matrix
#include <SPI.h>
#include <DMD.h>
#include <TimerOne.h>
DMD dmd(1, 1);
#define SPEAKERPIN 4
byte handx[]={12,13,14,15,16,17,18,19,20,21,21,22,
22,23,23,23,23,23,22,22,21,21,20,19,
18,17,16,15,14,13,12,10,9,8,7,6,
5,4,3,2,2,1,1,0,0,0,0,0,
1,1,2,2,3,4,5,6,7,8,9,10};
byte handy[]={0,0,0,0,1,1,1,2,2,3,4,4,
5,6,7,8,8,9,10,11,11,12,13,13,
14,14,14,15,15,15,15,15,15,15,14,14,
14,13,13,12,11,11,10,9,8,8,7,6,
5,4,4,3,2,2,1,1,1,0,0,0};
int dmode=0; //display mode
int brightness=2; //display brightness
int bcount=0; //variable used to keep track of pwm phase
#define BSTEPS 7
void ScanDMD(){ //also implements a basic pwm brightness control
dmd.scanDisplayBySPI();
bcount=bcount+brightness;
if(bcount<BSTEPS){digitalWrite(9,LOW);}
bcount=bcount%BSTEPS;
}
void setup () {
Wire.begin();
Serial.begin(9600);
Timer1.initialize( 500 ); //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
Timer1.attachInterrupt( ScanDMD ); //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()
dmd.clearScreen( true ); //clear/init the DMD pixels held in RAM
digitalWrite(SPEAKERPIN,LOW); //speaker off
rtc.begin();
}
void loop () {
setSyncProvider(RTC.get);
time_t daysleft,christmasdate; // setup the fields needed.
christmasdate = 1482670799; // December 25, 2016
daysleft = christmasdate - now(); // subtract todays date from the christmas date to get the days left.
// Display the days left before christmas.
dmd.selectFont( SystemFont5x7 );
dmd.drawString( 0,0, "Days,", 4, GRAPHICS_NORMAL );
dmd.drawString( 2,9, displayDaysDigits(daysleft / SECS_PER_DAY);, 3, GRAPHICS_NORMAL );
The idea is for the Dot Matrix Display...
(32x16 Red Dot Matrix Display | Freetronics)
(Using Your Freetronics DMD | Freetronics)
To countdown the days until Christmas. I'd like it to eventually display the days, hours, minutes, seconds. But should be able to figure that out when this piece of code works.
My current error messages are:
#warning CHANGE THESE TO SEMI-ADJUSTABLE PIN DEFS!
^
In function 'void loop()':
Countdown:59: error: 'RTC' was not declared in this scope
setSyncProvider(RTC.get);
^
Countdown:59: error: 'setSyncProvider' was not declared in this scope
setSyncProvider(RTC.get);
^
Countdown:62: error: 'now' was not declared in this scope
daysleft = christmasdate - now(); // subtract todays date from the christmas date to get the days left.
^
Countdown:66: error: 'SystemFont5x7' was not declared in this scope
dmd.selectFont( SystemFont5x7 );
^
Countdown:68: error: 'SECS_PER_DAY' was not declared in this scope
dmd.drawString( 2,9, displayDaysDigits(daysleft / SECS_PER_DAY);, 3, GRAPHICS_NORMAL );
^
Countdown:68: error: 'displayDaysDigits' was not declared in this scope
dmd.drawString( 2,9, displayDaysDigits(daysleft / SECS_PER_DAY);, 3, GRAPHICS_NORMAL );
^
Countdown:68: error: expected primary-expression before ',' token
dmd.drawString( 2,9, displayDaysDigits(daysleft / SECS_PER_DAY);, 3, GRAPHICS_NORMAL );
^
Countdown:68: error: expected '}' at end of input
dmd.drawString( 2,9, displayDaysDigits(daysleft / SECS_PER_DAY);, 3, GRAPHICS_NORMAL );
^
exit status 1
'RTC' was not declared in this scope
I'm using all of the following components
Nano Board
XC4621 Red LED Matrix
XC4450 Real Time Clock Module
https://www.jaycar.com.au/arduino-compatible-real-time-clock-module/p/XC4450
Assistance is greatly appreciated