Hi,
I am Siva Raman. I am a beginner to Arduino Projects. I can understand all the schematics and do the hardware, but when it comes to programming I am a novice. I am doing a project watching a Youtube video Maxint R&D.
The link is Made: JLCPCB TinyDev TM1637 modular LED matrix clock with ATtiny85 - YouTube. Here he runs a clock using 6x5 LED matrix with TM1637 chip and RTC with ATtiny85.
I run the test code in TM1637 6x5 display it works fine, but when I try to upload the clock code to Attiny85 via USbasp I am getting the following errors. I am really a novice in programming, please help me in this regard. I need to program this to Attiny85. Thank you.
Code
// Digital clock **********************************************
const int RTCaddress = 0x68;
const int DisplayAddress = 0x70;
int Colon = 2;
char Segment[10] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F};
void SetClock (int hr, int min) {
TinyI2C.start(RTCaddress, 0);
TinyI2C.write(0);
TinyI2C.write(0);
TinyI2C.write(min);
TinyI2C.write(hr);
TinyI2C.stop();
}
void InitDisplay () {
TinyI2C.start(DisplayAddress, 0);
TinyI2C.write(0x21);
TinyI2C.restart(DisplayAddress, 0);
TinyI2C.write(0x81);
TinyI2C.restart(DisplayAddress, 0);
TinyI2C.write(0xe1);
TinyI2C.stop();
}
void WriteWord (uint8_t b) {
TinyI2C.write(b);
TinyI2C.write(0);
}
// Setup **********************************************
void setup() {
TinyI2C.init();
InitDisplay();
SetClock(0x12, 0x34); // Set the time to 12:34
}
void loop () {
// Read the time from the RTC
TinyI2C.start(RTCaddress, 0);
TinyI2C.write(1);
TinyI2C.restart(RTCaddress, 2);
int mins = TinyI2C.read();
int hrs = TinyI2C.read();
TinyI2C.stop();
// Write the time to the display
TinyI2C.start(DisplayAddress, 0);
TinyI2C.write(0);
WriteWord(Segment[hrs / 16]);
WriteWord(Segment[hrs % 16]);
WriteWord(Colon);
WriteWord(Segment[mins / 16]);
WriteWord(Segment[mins % 16]);
TinyI2C.stop();
// Flash the colon
Colon = 2 - Colon;
delay(1000);
}
Error
C:\Users\Siva Raman\Desktop\DigitalClock\DigitalClock.ino: In function 'void SetClock(int, int)':
DigitalClock:20:3: error: 'TinyI2C' was not declared in this scope
TinyI2C.start(RTCaddress, 0);
^~~~~~~
C:\Users\Siva Raman\Desktop\DigitalClock\DigitalClock.ino: In function 'void InitDisplay()':
DigitalClock:29:3: error: 'TinyI2C' was not declared in this scope
TinyI2C.start(DisplayAddress, 0);
^~~~~~~
C:\Users\Siva Raman\Desktop\DigitalClock\DigitalClock.ino: In function 'void WriteWord(uint8_t)':
DigitalClock:39:3: error: 'TinyI2C' was not declared in this scope
TinyI2C.write(b);
^~~~~~~
C:\Users\Siva Raman\Desktop\DigitalClock\DigitalClock.ino: In function 'void setup()':
DigitalClock:46:3: error: 'TinyI2C' was not declared in this scope
TinyI2C.init();
^~~~~~~
C:\Users\Siva Raman\Desktop\DigitalClock\DigitalClock.ino: In function 'void loop()':
DigitalClock:53:3: error: 'TinyI2C' was not declared in this scope
TinyI2C.start(RTCaddress, 0);
^~~~~~~
exit status 1
'TinyI2C' was not declared in this scope