Pages: [1]   Go Down
Author Topic: 60 Second countdown using a 2 digit Seven second display  (Read 1841 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys,

so I'm trying to make a 60 second countdown timer using an arduino uno.  i want it to start the countdown when a push button is pushed, and stop at 0 until the push button is hit again.  thus making it start at 60 and count to 0 again.  I literally have no idea how to do this. i found some code counting down from 9 - 0 using a 1 digit seven segment display, but it loops and i have no idea how to adjust it to make it 2 digits and count from 60.  Any ideas or tips would help alot! This is my first time using an arduino! only other microcontroller i programmed was a 8051 and that was assembly code! much different from C code. Thanks for any help that you can provide!!
Logged

London
Offline Offline
Edison Member
*
Karma: 47
Posts: 1436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code????????
Schematic????????
Do you think we're mindreaders?
Logged

Offline Offline
Faraday Member
**
Karma: 67
Posts: 2692
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
found some code counting down from 9 - 0 using a 1 digit seven segment display
Show us this code and the schematic that goes with it.
Logged

The way you have it in your schematic isn't the same as how you have it wired up!

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1273
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have some code on my repository (link below) for a countdown timer that may be useful for you.
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I literally have no idea how to do this.

Do you have any interest in knowing or do you just want a gadget? Learning to do it will require a lot of time (but you'll be able to do other things as well as timers).
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I havent really started coding it yet.  its my first time using an arduino so im not sure how to code a timer for it. i know how to make a timer and i know C code im just having difficulty bridging the two. The following Code is code i have for a countdown from 9 to 0, but im not sure how to get it to 60 and i dont want it to loop. but i can only seem to get it to work in a loop

// Define the LED digit patters, from 0 - 9
// Note that these patterns are for common cathode displays
// For common anode displays, change the 1's to 0's and 0's to 1's
// 1 = LED on, 0 = LED off, in this order:
//                                    Arduino pin: 2,3,4,5,6,7,8
byte seven_seg_digits[10][7] = {
  {
    0,0,0,0,0,0,1   }
  ,  // = 0
  {
    1,0,0,1,1,1,1   }
  ,  // = 1
  {
    0,0,1,0,0,1,0   }
  ,  // = 2
  {
    0,0,0,0,1,1,0   }
  ,  // = 3
  {
    1,0,0,1,1,0,0   }
  ,  // = 4
  {
    0,1,0,0,1,0,0   }
  ,  // = 5
  {
    0,1,0,0,0,0,0   }
  ,  // = 6
  {
    0,0,0,1,1,1,1   }
  ,  // = 7
  {
    0,0,0,0,0,0,0   }
  ,  // = 8
  {
    0,0,0,1,1,0,0,0,1,1   }   // = 9
};

void setup() {               
  pinMode(2, OUTPUT);   
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  writeDot(0);  // start with the "dot" off
}

void writeDot(byte dot) {
  digitalWrite(9, dot);
}

void sevenSegWrite(byte digit) {
  byte pin = 2;
  for (byte segCount = 0; segCount < 7; ++segCount) {
    digitalWrite(pin, seven_seg_digits[digit][segCount]);
    ++pin;
  }
}

void loop() {
  for (byte count = 10; count > 0; --count) {
    delay(1000);
    sevenSegWrite(count - 1);
  }
  delay(4000);
}

Logged

Online Online
Faraday Member
**
Karma: 65
Posts: 2509
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Place your code inside "code tags"
  • Copy your code
  • Click the # gadget (post/message toolbar) and then paste your code between the two html prompts [ code ] [ /code ]

This will countdown once:
Code:
boolean passthru = false;
byte tens;
byte ones;

void setup ()
{
  Serial.begin(9600);
}

void loop ()
{
  if (passthru == false)
  {
    for (int counts=60; counts > -1; counts--)
    {
      tens = counts/10;
      ones = counts % 10;
      Serial.print(tens,DEC);
      Serial.print(" ");
      Serial.print(ones,DEC);
      Serial.print("\r\n");
      delay (1000);   
    }
    passthru = true;
  }
  // digitalRead switch for "do again"
  // >>> make passthru = false
}

Upload it, click the Serial Monitor button, and observe.

Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Pages: [1]   Go Up
Jump to: