Bulding a swimming timer for 6 lanes

Hi guys,

I want to make a timer that starts with a button and have 6 stop buttons, one for each lane. So if I press the lane 1 button, it gives the time for lane 1, if i press de lane 4 button, it gives the time for lane 4. I want to see all the different lane times in the computer. I saw this topic ( Arduino Ideas: Swimming Timer ), wich have a code but when I push the start button, nothing happens.

Do you have any idea what is wrong with the code in the link? I also atached the code in a txt file.

code.txt (12.8 KB)

How are the buttons wired ?
What do you see if you print the result of reading the switch states ? Are they what you expect ?

Note that

  pinMode(RESET_SWITCH, INPUT);
  pinMode(START_GATE,   INPUT);
  digitalWrite(RESET_SWITCH, HIGH);    // enable pull-up resistor
  digitalWrite(START_GATE,   HIGH);    // enable pull-up resistor

Is more easy to understand if written as

  pinMode(RESET_SWITCH, INPUT_PULLUP);
  pinMode(START_GATE,   INPUT_PULLUP);

Do you have 5 lanes, or 6? The code says 5; your post says 6.

when I push the start button, nothing happens.

How IS your switch wired?

What do your Serial.print() statements tell you is happening?

UKHeliBob:
How are the buttons wired ?
What do you see if you print the result of reading the switch states ? Are they what you expect ?

Note that

  pinMode(RESET_SWITCH, INPUT);

pinMode(START_GATE,  INPUT);
  digitalWrite(RESET_SWITCH, HIGH);    // enable pull-up resistor
  digitalWrite(START_GATE,  HIGH);    // enable pull-up resistor



Is more easy to understand if written as


pinMode(RESET_SWITCH, INPUT_PULLUP);
  pinMode(START_GATE,  INPUT_PULLUP);

One of the button's terminal is conected to ground and the other terminal is conected to digital inputs (from 2 to 7). I have 5 buttons, one for each lane and one conected to each pin. The project have a LED that should turn on when the start button is pressed but it doesn't happen.

When I press the start button, nothing happens but when I press the reset button, I receive this in the serial:


Swim Timer V1.1a

Run number: 1

Lane Times:

1 - NO TIME 0
2 - NO TIME 0
3 - NO TIME 0
4 - NO TIME 0
5 - NO TIME 0

Results:

P1: L NO TIME
P2: L NO TIME
P3: L NO TIME
P4: L NO TIME
P5: L NO TIME

======================

PaulS:
Do you have 5 lanes, or 6? The code says 5; your post says 6.
How IS your switch wired?

What do your Serial.print() statements tell you is happening?

One of the button's terminal is conected to ground and the other terminal is conected to digital inputs (from 2 to 7). I have 5 buttons, one for each lane and one conected to each pin. The project have a LED that should turn on when the start button is pressed but it doesn't happen.

When I press the start button, nothing happens but when I press the reset button, I receive this in the serial:


Swim Timer V1.1a

Run number: 1

Lane Times:

1 - NO TIME 0
2 - NO TIME 0
3 - NO TIME 0
4 - NO TIME 0
5 - NO TIME 0

Results:

P1: L NO TIME
P2: L NO TIME
P3: L NO TIME
P4: L NO TIME
P5: L NO TIME

======================

What do you see if you print the result of

digitalRead(START_GATE);

UKHeliBob:
What do you see if you print the result of

digitalRead(START_GATE);

The project have a LED that should turn on when the start button is pressed but it doesn't happen.

When I press the start button, nothing happens but when I press the reset button, I receive this in the serial:


Swim Timer V1.1a

Run number: 1

Lane Times:

1 - NO TIME 0
2 - NO TIME 0
3 - NO TIME 0
4 - NO TIME 0
5 - NO TIME 0

Results:

P1: L NO TIME
P2: L NO TIME
P3: L NO TIME
P4: L NO TIME
P5: L NO TIME

======================

When I press the start button, nothing happens

So you don't get anything on the Serial monitor when you print the result of
digitalRead(START_GATE); ?

Please post the code you tried

UKHeliBob:
So you don't get anything on the Serial monitor when you print the result of

digitalRead(START_GATE);

?

Please post the code you tried

By press the start button, nothing happens in the serial. When I press the reset button, I receive this in the serial:


Swim Timer V1.1a

Run number: 1

Lane Times:

1 - NO TIME 0
2 - NO TIME 0
3 - NO TIME 0
4 - NO TIME 0
5 - NO TIME 0

Results:

P1: L NO TIME
P2: L NO TIME
P3: L NO TIME
P4: L NO TIME
P5: L NO TIME

======================

I ca't write all the code here because it is too large. There is a txt file or a link in the topic question where you can see all the code that I tryed. This is the link: Arduino Ideas: Swimming Timer

The initialize() function should print to the serial port. I do not see its output in what you showed. Add another Serial.print() statement to the start of initialize() to confirm that it is called.

Add a print() call, to print the value of mode in loop().

You are still not answering the question

There is a txt file or a link in the topic question where you can see all the code that I tryed.

That code does not print the value that you get when you digitalRead() the START_GATE pin

PaulS:
The initialize() function should print to the serial port. I do not see its output in what you showed. Add another Serial.print() statement to the start of initialize() to confirm that it is called.

Add a print() call, to print the value of mode in loop().

How can I do it? Could you send me what I need to change? I'm new in arduino programming.

I'm new in arduino programming.

If you can't add a call to Serial.print() to some code someone else wrote, then you need to put that project away for a while, until you understand more about what the code is doing. Work through some (lots!) of examples, and learn how to use the online Reference material to study the functions and methods available to you.

I think UKHeliBob suggests you try reading the return value of digitalRead(START_GATE).
try:

byte temp = digitalRead(START_GATE);

then,

Serial.print(temp);