evil_jinx
Published

It's the Final Countdown!

A cool countdown on a 7-segment display, with a "red-alert" LED! It goes from 5 to 0, then the LED kicks in. The code is all explained.

BeginnerFull instructions provided316
It's the Final Countdown!

Things used in this project

Story

Read more

Schematics

Here's the very simple circuit schematic

Code

The code that powers this project.

C/C++
This code is very simple, in fact. Clear all text in the Arduino software, then copy + paste this code.
// variables to decide which digital pins correspond to which letter
int pinA = 2;
int pinB = 3;
int pinC = 4;
int pinD = 5;
int pinE = 6;
int pinF = 7;
int pinG = 8;
int pinH = 9;
int pinI = 10;
int pinJ = 11;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pins as outputs.
  pinMode(pinA, OUTPUT);     
  pinMode(pinB, OUTPUT);     
  pinMode(pinC, OUTPUT);     
  pinMode(pinD, OUTPUT);     
  pinMode(pinE, OUTPUT);     
  pinMode(pinF, OUTPUT);     
  pinMode(pinG, OUTPUT);   
  pinMode(pinH, OUTPUT);  
  pinMode(pinI, OUTPUT);  
  pinMode(pinJ, OUTPUT);
   }
     
void loop() {
  // display number 5 
  digitalWrite(pinA, HIGH);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, LOW);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, LOW);
  digitalWrite(pinH, HIGH);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, HIGH);   
  delay(1000);               // wait for a second
  
// display number 4
  digitalWrite(pinA, HIGH);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, LOW);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, LOW);
  digitalWrite(pinH, LOW);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, HIGH);   
  delay(1000);               // wait for a second
  
// display number 3
  digitalWrite(pinA, HIGH);   
  digitalWrite(pinB, LOW);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, LOW);
  digitalWrite(pinH, HIGH);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, HIGH);   
  delay(1000);               // wait for a second
  
// display number 2
  digitalWrite(pinA, HIGH);   
  digitalWrite(pinB, LOW);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, HIGH);
  digitalWrite(pinH, HIGH);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, LOW);   
  delay(1000);               // wait for a second
  
// display number 1
  digitalWrite(pinA, LOW);   
  digitalWrite(pinB, LOW);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, LOW);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, LOW);
  digitalWrite(pinH, LOW);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, HIGH);   
  delay(1000);               // wait for a second
  
// display number 0
  digitalWrite(pinA, LOW);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, HIGH); // pinF boots the LED   
  digitalWrite(pinG, HIGH);
  digitalWrite(pinH, HIGH);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, HIGH);   
  delay(500);               // wait for half a second
  
// turn the LED off
  digitalWrite(pinA, LOW);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, HIGH);
  digitalWrite(pinH, HIGH);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, HIGH);   
  delay(500);               // wait for half a second

// turn the LED on
  digitalWrite(pinA, LOW);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, HIGH);   
  digitalWrite(pinG, HIGH);
  digitalWrite(pinH, HIGH);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, HIGH);   
  delay(500);               // wait for half a second
  
// turn the LED off
  digitalWrite(pinA, LOW);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, HIGH);
  digitalWrite(pinH, HIGH);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, HIGH);   
  delay(500);               // wait for half a second 

// turn the LED on
  digitalWrite(pinA, LOW);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, HIGH);   
  digitalWrite(pinG, HIGH);
  digitalWrite(pinH, HIGH);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, HIGH);   
  delay(500);               // wait for half a second
  
// turn the LED off
  digitalWrite(pinA, LOW);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, HIGH);
  digitalWrite(pinH, HIGH);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, HIGH);   
  delay(500);               // wait for half a second
  
//turn the LED on
  digitalWrite(pinA, LOW);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, HIGH);   
  digitalWrite(pinG, HIGH);
  digitalWrite(pinH, HIGH);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, HIGH);   
  delay(500);               // wait for half a second
  
// turn the LED off
  digitalWrite(pinA, LOW);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, HIGH);
  digitalWrite(pinH, HIGH);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, HIGH);   
  delay(500);               // wait for  half a second

//turn the LED on for 4 seconds
  digitalWrite(pinA, LOW);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, HIGH);   
  digitalWrite(pinG, HIGH);
  digitalWrite(pinH, HIGH);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, HIGH);   
  delay(4000);               // wait for 4 seconds 

  digitalWrite(pinA, LOW);   
  digitalWrite(pinB, LOW);   
  digitalWrite(pinC, LOW);   
  digitalWrite(pinD, LOW);   
  digitalWrite(pinE, LOW);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, LOW);
  digitalWrite(pinH, LOW);
  digitalWrite(pinI, LOW);
  digitalWrite(pinJ, LOW);   
  delay(10000);               // wait for 10 seconds 
  }

Credits

evil_jinx

evil_jinx

1 project • 0 followers

Comments