I am attempting to upload a sketch that is currently running on a Nano to a ATTiny85 board. So far, no success. I have installed the necessary drivers for the ATTiny85 board in the Arduino IDE software, and uploaded a test sketch (blink), which does work. So the board is OK. But when uploading the desired sketch to the ATTiny, it won't finish compiling. This sketch does work (it is for a digital clock with custom display). Is it too large to fit on the ATTiny85? Or does it need to be modified? Any assistance would be appreciated.
#include "Wire.h"
#include "DS3231.h"
#define DS3231_I2C_ADDRESS 0x68
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
Adafruit_8x16matrix matrix = Adafruit_8x16matrix();
byte decToBcd(byte val) // Convert normal decimal numbers to binary coded decimal
{
return( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val) // Convert binary coded decimal to normal decimal numbers
{
return( (val/16*10) + (val%16) );
}
void setDS3231time(byte second, byte minute, byte hour);
void setup()
{
Wire.begin();
matrix.begin(0x70); // pass in the address
Serial.begin(9600);
// set the initial time here:
// DS3231 seconds, minutes, hours
setDS3231time(45,59,23);
}
void loop()
{
displayTime(); // display the real-time clock data on the Serial Monitor,
delay(500); // every second
}
static const uint8_t PROGMEM
colon_bmp[] =
{
B0,
B1,
B0,
B1,
B0,
B0,
B1,
B0,
B1,
B0
};
static const uint8_t PROGMEM
digit_bmp[10][5] = {
{ B1110,
B1010,
B1010,
B1110,
B0100 }, // Zero
{ B1000,
B0000,
B0000,
B1110,
B0100 }, // One
{ B1100,
B0000,
B0000,
B1110,
B0100 }, // Two
{ B1110,
B0000,
B0000,
B1110,
B0100 }, // Three
{ B1110,
B1000,
B0000,
B1110,
B0100 }, // Four
{ B1110,
B1100,
B0000,
B1110,
B0100 }, // Five
{ B1110,
B1110,
B0000,
B1110,
B0100 }, // Six
{ B1110,
B1110,
B1000,
B1110,
B0100 }, // Seven
{ B1110,
B1110,
B1100,
B1110,
B0100 }, // Eight
{ B1110,
B1110,
B1110,
B1110,
B0100 } // Nine
};
void setDS3231time(byte second, byte minute, byte hour) // sets time data to DS3231
{
Wire.beginTransmission(DS3231_I2C_ADDRESS);
Wire.write(0); // set next input to start at the seconds register
Wire.write(decToBcd(second)); // set seconds
Wire.write(decToBcd(minute)); // set minutes
Wire.write(decToBcd(hour)); // set hours
Wire.endTransmission();
}
void readDS3231time
(byte *second,
byte *minute,
byte *hour)
{
Wire.beginTransmission(DS3231_I2C_ADDRESS);
Wire.write(0); // set DS3231 register pointer to 00h
Wire.endTransmission();
Wire.requestFrom(DS3231_I2C_ADDRESS, 7); // request seven bytes of data from DS3231 starting from register 00h
*second = bcdToDec(Wire.read() & 0x7f);
*minute = bcdToDec(Wire.read());
*hour = bcdToDec(Wire.read() & 0x3f);
}
void displayTime()
{
byte second, minute, hour; // retrieve data from DS3231
readDS3231time(&second, &minute, &hour); // send it to the serial monitor
if( hour == 0 )
hour = 12; // 12 midnight
else if(hour > 12)
hour = hour - 12 ;
Serial.print(hour, DEC); // convert the byte variable to a decimal number when displayed
Serial.print(":");
if (minute<10)
{
Serial.print("0");
}
Serial.print(minute, DEC);
Serial.print(":");
if (second<10)
{
Serial.print("0");
}
Serial.print(second, DEC);
Serial.print(" ");
matrix.clear();
matrix.drawBitmap(0, 0, colon_bmp, 8, 10, LED_ON);
matrix.drawBitmap(-3, 0, digit_bmp[hour / 10], 7, 5, LED_ON);
matrix.drawBitmap(0, 0, digit_bmp[hour % 10], 7, 5, LED_ON);
matrix.drawBitmap(-3, 5, digit_bmp[minute / 10], 7, 5, LED_ON);
matrix.drawBitmap(0, 5, digit_bmp[minute % 10], 7, 5, LED_ON);
matrix.drawBitmap(-3, 10, digit_bmp[second / 10], 7, 5, LED_ON);
matrix.drawBitmap(0, 10, digit_bmp[second % 10], 7, 5, LED_ON);
matrix.writeDisplay();
delay(500);
}