I'm able to output it on my LCD's and the serial monitotr but not on the 4 matrices and it really bugs me.
the real problem is that i don't understand how to write it to the display when the numbers are bigger then 9 because it will then take 2 matrices to show the value
the serial monitoris very simple because its as simple as taken from the official example
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
void setup () {
Serial.begin(57600);
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop () {
DateTime now = RTC.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.print(" since midnight 1/1/1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");
// calculate a date which is 7 days and 30 seconds into the future
DateTime future (now.unixtime() + 7 * 86400L + 30);
Serial.print(" now + 7d + 30s: ");
Serial.print(future.year(), DEC);
Serial.print('/');
Serial.print(future.month(), DEC);
Serial.print('/');
Serial.print(future.day(), DEC);
Serial.print(' ');
Serial.print(future.hour(), DEC);
Serial.print(':');
Serial.print(future.minute(), DEC);
Serial.print(':');
Serial.print(future.second(), DEC);
Serial.println();
Serial.println();
delay(3000);
}
how do i get this "Serial.print(now.day(), DEC);" and split the digits if there are 2 :S so i can put in this
#include <Wire.h>
unsigned char RainbowCMD[5];
unsigned char State = 0;
unsigned long timeout;
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
}
void loop()
{
ShowChar(4,DIGIT1,0,0,15,0);ShowChar(3,DIGIT2,0,0,15,0);ShowChar(2,DIGIT3,0,0,15,0);ShowChar(1,DIGIT4,0,0,15,0); // time NOT working
delay(1000);
}
//--------------------------------------------------------------------------
//Name:ShowColor
//function: Send a conmand to Rainbowduino for showing a color
//parameter: Address: rainbowduino IIC address
// red,green,blue: the color RGB
//----------------------------------------------------------------------------
void ShowColor(int Address,unsigned char red , unsigned char green, unsigned char blue)
{
RainbowCMD[0]='R';
RainbowCMD[1]=0x03;
RainbowCMD[2]=red;
RainbowCMD[3]=((green<<4)|(blue));
SentCMD(Address);
}
//--------------------------------------------------------------------------
//Name:ShowImage
//function: Send a conmand to Rainbowduino for showing a picture which was pre-set in Rainbowduino Flash
//parameter: Address: rainbowduino IIC address
// number: the pre-set picture position
// shift: the picture shift bit for display
//----------------------------------------------------------------------------
void ShowImage(int Address, unsigned char number,unsigned char shift)
{
RainbowCMD[0]='R';
RainbowCMD[1]=0x01;
RainbowCMD[2]=(shift<<4);
RainbowCMD[4]=number;
SentCMD(Address);
}
//--------------------------------------------------------------------------
//Name:ShowColor
//function: Send a conmand to Rainbowduino for showing a color
//parameter: Address: rainbowduino IIC address
// red,green,blue: the color RGB
// shift: the picture shift bit for display
// ASCII:the char or Number want to show
//----------------------------------------------------------------------------
void ShowChar(int Address,unsigned char ASCII,unsigned char red, unsigned char blue ,unsigned char green,unsigned char shift)
{
RainbowCMD[0]='R';
RainbowCMD[1]=0x02;
RainbowCMD[2]=((shift<<4)|(red));
RainbowCMD[3]=((green<<4)|(blue));
RainbowCMD[4]=ASCII;
SentCMD(Address);
}
//--------------------------------------------------------------------------
//Name:SentCMD
//function: Send a 5 byet Rainbow conmand out
//parameter: NC
//----------------------------------------------------------------------------
void SentCMD(int Add)
{ unsigned char OK=0;
unsigned char i,temp;
while(!OK)
{
switch (State)
{
case 0:
Wire.beginTransmission(Add);
for (i=0;i<5;i++) Wire.send(RainbowCMD[i]);
Wire.endTransmission();
delay(5);
State=1;
break;
case 1:
Wire.requestFrom(Add,1);
if (Wire.available()>0)
temp=Wire.receive();
else {
temp =0xFF;
timeout++;
}
if ((temp==1)||(temp==2)) State=2;
else if (temp==0) State=0;
if (timeout>5000)
{
timeout=0;
State=0;
}
delay(5);
break;
case 2:
OK=1;
State=0;
break;
default:
State=0;
break;
}
}
}
i really don't know :S