/*************************************************** This is a library for our I2C LED Backpacks Designed specifically to work with the Adafruit LED 7-Segment backpacks ----> http://www.adafruit.com/products/881 ----> http://www.adafruit.com/products/880 ----> http://www.adafruit.com/products/879 ----> http://www.adafruit.com/products/878 These displays use I2C to communicate, 2 pins are required to interface. There are multiple selectable I2C addresses. For backpacks with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks with 3 Address Select pins: 0x70 thru 0x77 Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, all text above must be included in any redistribution ****************************************************/ #include // Enable this line if using Arduino Uno, Mega, etc. #include #include "Adafruit_LEDBackpack.h" Adafruit_7segment matrix = Adafruit_7segment(); int cdMinutes = 4; int cdSecFirst = 5; int cdSecSecond = 9; int timerDecrement = 1000; int powerPin = 18; int powerButton = 0; int triggerPin = 20; int triggerButton = 0; int triggerLEDPin = 7; int boom = 0; void setup() { #ifndef __AVR_ATtiny85__ Serial.begin(9600); Serial.println("7 Segment Backpack Test"); #endif matrix.begin(0x70); // initialize the LED pin as an output: pinMode(triggerLEDPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(powerPin, INPUT); pinMode(triggerPin, INPUT); } void loop() { matrix.clear(); // Clears display for initial loop matrix.setBrightness(15); matrix.writeDisplay(); digitalWrite(triggerLEDPin, LOW); do { powerButton = digitalRead(powerPin); // Checks to see if power button is on } while (powerButton == 0); // Continues checking power button until it is turned on boolean drawDots = true; matrix.writeDigitNum(0, 0); matrix.writeDigitNum(1, 5); matrix.drawColon(drawDots); matrix.writeDigitNum(3, 0); matrix.writeDigitNum(4, 0); matrix.writeDisplay(); do // Keeps checking for trigger press { triggerButton = digitalRead(triggerPin); } while (triggerButton == 0); digitalWrite(triggerLEDPin, HIGH); do { matrix.writeDigitNum(0, 0); matrix.writeDigitNum(1, cdMinutes); matrix.drawColon(drawDots); matrix.writeDigitNum(3, cdSecFirst); matrix.writeDigitNum(4, cdSecSecond); matrix.writeDisplay(); delay(timerDecrement); if ((cdSecFirst == 0) && (cdSecSecond == 0)) { cdSecFirst = 6; --cdMinutes; } if (cdSecSecond == 0) { cdSecSecond = 10; --cdSecFirst; } --cdSecSecond; if (cdMinutes < 0) { boom = 1; } } while (boom == 0); do { powerButton = digitalRead(powerPin); // Checks to see if power button is off } while (powerButton == 1); cdMinutes = 4; cdSecFirst = 5; cdSecSecond = 9; boom = 0; }