Using the Introducing Trinket tutorialto set up the Arduino integrated development environment (IDE) on your system and add Adafruit AVR board support (which includes Trinket) to your IDE.
When you load a program, you must press the hardware reset button on the Trinket then quickly press upload in the Arduino software to upload a sketch. If you get an error, try the reset-upload process again. If you continually cannot load the blink sketch, check to make sure the Trinket is connected (without any wires connected to pins #3 and #4) and the Arduino IDE software has all the required changes.
For preparing the Arduino IDE for the clock program, we need a software library to access the real time clock. We'll be using the following Arduino libraries:
- The built-in Arduino I2C Wire library.
- The Adafruit RTClib library
Here’s a tutorial that walks through the process of correctly installing Arduino libraries.
Now you are ready to copy the sketch on the next page for your clock.
For errors in the Arduino IDE software:
- Ensure you have installed the Adafruit AVR boards support and have selected Trinket 8 MHz as the board.
- Ensure you have installed the RTClib library downloaded fresh from the Adafruit GitHub site.
- Ensure you push the Trinket on board reset button before uploading your sketch, the red LED will blink when ready for upload, there is a 10 second window to do this.
- If you place a large amount of code or other libraries in a sketch, it is very easy to exceed the available code space on the Trinket. If your program absolutely will not fit, consider switching to an Arduino Uno, Adafruit Boarduino, Pro Trinket, or Adafruit Flora with standard libraries.
- If you get errors similar to the one below, you may have included decimal numbers and the floating point library was added by the Arduino IDE, exceeding the amount of program space available.
arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn85.o:(.init9+0x2):relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in /arduino-1.0.1/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25\libgcc.a(_exit.o)
The code on the next page still leaves a good deal of space for additional functionality, especially once the serial code is no longer needed. If you declare large arrays, define large text strings, add decimal/floating point numbers, or other libraries, the space may fill up or overflow.