Daphne YangEthan PhamRithik JainMichael Kelley
Published

Quarantine Countdown

Keep track of how many days you've been quarantined with just a simple press of a button!

IntermediateFull instructions provided2 hours305
Quarantine Countdown

Things used in this project

Hardware components

EK-TM4C123GXL TM4C Tiva LaunchPad
Texas Instruments EK-TM4C123GXL TM4C Tiva LaunchPad
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×13
7 Segment LED Display, InfoVue
7 Segment LED Display, InfoVue
×1
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×1
Tilt Switch, SPST
Tilt Switch, SPST
×1

Software apps and online services

Energia
Texas Instruments Energia

Story

Read more

Schematics

QuarantineCountdownSchematic

Code

QuarantineCountdown

C/C++
// QuarantineCountdown

// 2D array to display particular letters and numbers
byte seven_segment_digits[15][7] = { { 0,0,0,0,0,0,1 }, // display '0'
                                     { 1,0,0,1,1,1,1 }, // display '1'
                                     { 0,0,1,0,0,1,0 }, // display '2'
                                     { 0,0,0,0,1,1,0 }, // display '3'
                                     { 1,0,0,1,1,0,0 }, // display '4'
                                     { 0,1,0,0,1,0,0 }, // display '5'
                                     { 0,1,0,0,0,0,0 }, // display '6'
                                     { 0,0,0,1,1,1,1 }, // display '7'
                                     { 0,0,0,0,0,0,0 }, // display '8'
                                     { 0,0,0,1,1,0,0 }, // display '9'
                                     { 0,0,0,1,0,0,0 }, // display 'A'
                                     { 1,1,0,0,0,0,0 }, // display 'b'
                                     { 0,1,1,0,0,0,1 }, // display 'C'
                                     { 1,0,0,0,0,1,0 }, // display 'd'
                                     { 0,1,1,0,0,0,0 }  // display 'E'
                                   };

// initialize states
const int buttonPin = 19;
const int tiltPin = 18;
int breadboardButtonState = 0;
int tiltState = 0;
int count = 15;

void setup() {
  Serial.begin(9600);
  // initialize the breadboard push button pin as an input:
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(tiltPin, INPUT_PULLUP);

  pinMode(3, OUTPUT); // set segment A as output
  pinMode(4, OUTPUT); // set segment B as output
  pinMode(5, OUTPUT); // set segment C as output
  pinMode(6, OUTPUT); // set segment D as output
  pinMode(7, OUTPUT); // set segment E as output
  pinMode(8, OUTPUT); // set segment F as output
  pinMode(9, OUTPUT); // set segment G as output
  pinMode(10, OUTPUT); // set dot as output
  for(int i = 3; i < 10; i++) { // start with segments off
    digitalWrite(i, HIGH);
  }
  digitalWrite(10, HIGH);  // start with the dot off
}

void loop() {

  tiltState = digitalRead(tiltPin);
  // reset the countdown if the switch is tilted
  if(tiltState == 1){
    count = 15;
  }
    
  breadboardButtonState = digitalRead(buttonPin);
  // reset the countdown if the button is pressed when the
  // display reads 0
  if(count == 0){
    count = 15;
  }
  // if the button is pushed, change the display
  if (breadboardButtonState == 0) {
    int pin = 3;
    // set the segments
    for (int segCount = 0; segCount < 7; ++segCount) {
      digitalWrite(pin, seven_segment_digits[count-1][segCount]);
      ++pin;
    }
    // change the next number to be displayed
    count--;
    // delay before checking for another button press
    delay(200);
  }
}

Credits

Daphne Yang

Daphne Yang

1 project • 1 follower
Ethan Pham

Ethan Pham

0 projects • 2 followers
Rithik Jain

Rithik Jain

0 projects • 1 follower
Michael Kelley

Michael Kelley

0 projects • 0 followers

Comments