wait until question

Hi my name is francisco and im working on a chronometer that will count backwards.
im force to use 7 segments display because the chronometer its going to be huge so the numbers will be really big.
Now im working with the arduino uno but im going to buy the arduino mega so i can handle the 35 OUTPUT
becouse they are 5 display.
Also im using a matrix keyboard 1-9 and *,# (7 pin keyboard) ...

the idea is print the an X time in the display Ex: 1.00.00 h and then press * and run backwards until 0.00.00

so far my code only read the number in the keyboard and print it in one display (remember that im using arduino uno with 14 outs // 7 for the keyboard and 7 for 1 display

with one display ill be happy selecting a 9 then press * or # and count til 0...
I upload a pic with my circuit.

any sugestions?

thanks.

#include <Keypad.h>

//inicia codigo necesario
const byte filas = 4; //cuatro filas
const byte columnas = 3; //tres columnas
byte pinsFilas[filas] = {8, 7, 6, 5};  // en orden F1. F2. F3 F4
byte pinsColumnas[columnas] = {4, 3, 2}; //en orden C1. C2. C3

char teclas[filas][columnas] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};

Keypad teclado = Keypad( makeKeymap(teclas), pinsFilas, pinsColumnas, filas, columnas );
//termina codigo necesario

char tecla;
int numero;
int  cero = 0;
int  uno =  1;
int  dos =  2;
int  tres = 3;
int  cuatro = 4;
int  cinco =  5;
int  seis =   6;
int  siete =  7;
int  ocho =   8;
int  nueve =  9;

const int a = 11;    
const int b = 10;      
const int c = 0;     
const int d = 1;      
const int e = 9;     
const int f = 12;   
const int g = 13;  
boolean start = (true);

void setup() {
  start = -13;
  pinMode(a, OUTPUT);
  pinMode(b, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(e, OUTPUT);
  pinMode(f, OUTPUT);
  pinMode(g, OUTPUT);
 
  
  
}

void loop () {
  tecla = teclado.getKey();
   numero = tecla - 48; //convertimos el caracter a valor numerico //turn char into int so we can use numbers 
  if(numero == cero){ // si se presiona 0
  digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(g, LOW);
     }
  if(numero == uno){ // si se presiona 1
   digitalWrite(a, LOW);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, LOW);
  digitalWrite(e, LOW);
  digitalWrite(f, LOW);
  digitalWrite(g, LOW); 
   
  }
   if(numero == dos){ // si se presiona 2
   digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, LOW);
  digitalWrite(d, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(f, LOW);
  digitalWrite(g, HIGH);
   
  }
   if(numero == tres){ // si se presiona 3
   digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
  digitalWrite(e, LOW);
  digitalWrite(f, LOW);
  digitalWrite(g, HIGH);
   
  }
   if(numero == cuatro){ // si se presiona 4
    digitalWrite(a, LOW);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, LOW);
  digitalWrite(e, LOW);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
   
  }
   if(numero == cinco){ // si se presiona 5
  digitalWrite(a, HIGH);
  digitalWrite(b, LOW);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
  digitalWrite(e, LOW);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
   
  }
   if(numero == seis){ // si se presiona 6
   digitalWrite(a, HIGH);
  digitalWrite(b, LOW);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
   
  }
   if(numero == siete){ // si se presiona 7
  digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, LOW);
  digitalWrite(e, LOW);
  digitalWrite(f, LOW);
  digitalWrite(g, LOW);
   
  }
   if(numero == ocho){ // si se presiona 8
   digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, HIGH);
  digitalWrite(e, HIGH);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH);
   
  }
   if(numero == nueve){ // si se presiona 9
   
   digitalWrite(a, HIGH);
  digitalWrite(b, HIGH);
  digitalWrite(c, HIGH);
  digitalWrite(d, LOW);
  digitalWrite(e, LOW);
  digitalWrite(f, HIGH);
  digitalWrite(g, HIGH); 
   
  }
  
  
}

any sugestions?

Sure. Ask a question.

PaulS thanks for answer... any sugestion on how to proceed? i mean i got to the point in which i can print the number on the display the next step will be press * or # and start to count backwards...
that`s why i thought in use a "wait until" "#" or "*" be press and then start counting back but i dont know how to use that with the hole program...
the thing is that I need to storage 5 digits and then making them count back... how do yo do that?
im an electronic guy and my programing is not very good XD...

i thougth in some like this:

there is 5 display

D1-D2-D3-D4-D5  in that order being D1 the h number[-->0.00.00]

every display use a group of 7 pins

D1 = 1,2,3,4,5,6,7
D2 = 8,9,10,11,12,13,14
D3 = 15,16,17,18,19,20,21
D4 = 22,23,24,25,26,27,28
D5 = 29,30,31,32,33,34,35

every display have their own disposition of pins to print numbers from 0 to 9

for Ex:

D1

to print 0


1 = HIGH
2 = HIGH
3 = HIGH
4 = LOW
5 = HIGH
6 = HIGH
7 = HIGH
delay(1000)

an go on until 9 ... then for D2 to D5

then use the keyboard (lets try with one hour 1.00.00 h) 

i press the number 1 so the grup of pins that form D1 will print 1
 
then i press 0 and the grup of pins that form D2 will print 0
 
then i press 0 and the grup of pins that form D3 will print 0
 
then i press 0 and the grup of pins that form D4 will print 0
 
then i press 0 and the grup of pins that form D5 will print 0

so the program will jump from group to group

so then wait until press #

and the program read the state of numbers (group of pins) [1.00.00] and write a 0 [0.00.00] then print on D2,D3,D4,D5 [0.59.59]

and then when the [seconds] get to -->00 will subtract from D3 [0.-->58<--.00]

and go on until everything is [0.00.00]

i know it sounds really easy when you say it like this... and is waay hard...

but if you can help me or show me a diferent way to do it... still with 7 segment display... i will be really grateful...

and again... thanks for responding

Chopancho:
PaulS thanks for answer... any sugestion on how to proceed?

Never mind about computer code for the moment.

Write down in plain language , step by step what you want to happen. Put each step on a new line.

When you have that done and are satisfied that you have taken account of all the ifs and buts that are required you will be surprised how easy it is to turn it into computer code. The Thread planning and implementing a program illustrates this idea.

...R

Robin has some very good advice. The only thing I'd add is that you need to change your thinking from "wait until" to "do when". Instead of trying to make the Arduino do nothing until some even happens, make it do something when the event happens. There may, or may not, be other things for the Arduino to do before the event of interest happens.

If you think about your case, there ARE things the Arduino should be doing. On EVERY pass through loop(), it needs to see if, among other things, you've pressed a key. It needs to see if it is time to decrement the time remaining and update the display.

So, you can see that "wait until", like the use of delay(), is NOT the best approach. A "do when" approach is far better.

Thanks for responding i will study that and maybe ill post this in the progect area so i can get feedback on how to do it

thanks again

Chopancho:
Thanks for responding i will study that and maybe ill post this in the progect area so i can get feedback on how to do it

Put all your posts about this project here.

...R