If this is your first time using the Pro Trinket microcontroller, you’ll want to begin with our guide for setting that up. The Pro Trinket works a little differently from “normal” Arduinos are requires some extra installation and a different upload procedure:
Introducing Pro Trinket
To confirm that you have the driver installed and IDE properly configured, load the basic Arduino “blink” example sketch and try uploading to the board. If it won’t cooperate, work carefully through each of the steps in the guide linked above.
Using the realtime clock and LED displays requires a few extra libraries. These can be installed using the Arduino IDE’s Library Manager: Sketch→Include Library→Manage Libraries…
Scroll down or use the search field to install RTClib, Adafruit_GFX, Adafruit_BusIO, and Adafruit_LEDBackpack.
The code below will set the initial time on the DS3231 realtime clock. You only need to run this once, or a few years down the line when replacing the clock’s backup battery. Copy and paste the code into a new Arduino sketch and upload to the Pro Trinket.
A SOLID RED status LED on the Pro Trinket means the realtime clock was found and time was set. Off or blinking indicates a problem (troubleshooting tips below).
// Clock-setting utility for "Mindfulness Clock." Sets DS3231 battery- // backed RTC time based on compilation time or a specific data/time value. // Only needs to be run once to set the clock, or when battery is replaced. #include <Wire.h> #include <RTClib.h> RTC_DS3231 rtc; void setup() { Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); if(rtc.begin()) { // This line sets RTC to date & time this sketch was compiled: rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // Or this line sets the RTC with an explicit date & time, // for example to set January 21, 2014 at 3am you would call: // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); Serial.println(F("RTC time set")); digitalWrite(LED_BUILTIN, HIGH); // LED steady on = RTC set } else { Serial.println(F("Couldn't find RTC")); for(boolean b; ; b = !b) { // Blinking = RTC error digitalWrite(LED_BUILTIN, b); delay(250); } } } void loop() { } // Not used -- it's all in setup()!
- Confirm the correct board is selected (“Pro Trinket 5V/16MHz (USB)” or “Pro Trinket 3V/12MHz (USB)”, whichever you’re using).
- Confirm the RTClib library is correctly installed.
- This usually indicates a communication problem between the Pro Trinket and the RTC. Check all four connections: BUS, GND, A4/SDA/D and A5/SCL/C, make sure the latter two aren’t reversed.
- Look the circuit over for accidental solder bridges or cold solder joints.
- Is the coin cell battery installed on the RTC board?
Success! That means the clock has been set. Proceed to the next page to load the actual countdown software.
Text editor powered by tinymce.