new user need help on modifying countdown timer project

Hello, I am a high school senior in the middle of this huge project we have to complete in order to graduate basically. Quick explanation of what I am trying to do: I want to install a sensor into a basketball rim (much like the arcade game), but instead of keeping score I want it to stop time whenever the ball is sensed going through the rim, then be able to start the time again with push button.

I found the countdown timer project online and I thought I could make it work with what I am trying to do. However, I honestly have no idea how to program the arduino or modify it or anything. I was wondering if someone could help me out. Is there any way I could incorporate the sensor into the circuit with the timer and a pushbutton?

If anyone could help me out that would be great! I am open to any suggestions. Thanks a lot.

Interesting problem.
Is this a regulation size hoop that is twice the diameter of a ball?
You also have the possibility of the ball circling the rim & flying out.

Got a link to the"countdown timer project"?
Most code is set up like this:

pre-setup:
call out any libraries
declare pins being used
declare variables being used

void setup(){
pinMode( ) call outs to declare pins as inputs or outputs
start up any comm libraries
}

void loop(){
code that runs repeatedly
for example, reading a pin connected to a pushbutton, starting countdown if timer is stopped, or stopping countdown if time is stopped
or, reading a sensor & stopping time
or, if time is stopped, resetting the time
if next time interval is passed, update the displayed time
}
any function calls if used{
they get called from setup or loop to update the displayed time for example
}

So adapting the countdown timer project to add reading some buttons is probably not hard.
Making a set of sensors that can catch a ball going thru the entire area of the rim, and not falsely triggering when the ball hits the rim, or circles the rim, or a player grabs the rim, that will be little harder.
What have you considered for sensor(s) so far?

I am planning on using an arcade sized hoop, nothing too fancy though. I was thinking of placing the sensor underneath the circular part of the rim. I looked into using a capacitive proximity sensor and modifying the ball so that it has thin metal strips that can be sensed. I haven't really messed around with the sensor yet since I just started trying to order parts and other things. In my mind it makes sense, but I may be way in over my head. Honestly, I just need it to work for me well during my presentations and I'll be happy.

A link to the countdown timer:
http://www.hobbytronics.co.uk/arduino-countdown-timer

Or I also found a stopwatch project:
http://arduinoprojects101.com/arduino-stopwatch/

I think the stopwatch might be a little easier to use. Any thoughts?

On the countdown software, whatever. Really just blink without delay to decrement your counting by 1 or 0.1 or 0.01 every pass thru void loop if the elapsed time had gone by, changing the display when something changed, and the rest of the time (the vast makority of the time) checking your sensor for something to happen.

void loop(){
currentTime = millis();
if ( (currentTime - previousTime) >=interval && timeRunning == 1){
previousTime = previousTime + interval;
// digit decrementing & rollover code
displayUpdate = 1;
}
if ( (sensor trigger is detected) && timeRunning == 1){ // stop timer - this is the only difficult part - sensing a moving ball going by
timeRunning = 0;
}
if ( (timeRunning ==0) && digitalRead(buttonPin == 0){  // restart timer, buttonPin closed to Gnd to start time
timeRunning = 1;
}
if (displayUpate == 1){
displayUpdate = 0; // clear flag
// display update code - could be series of Serial print statements to start.
// replace with LCD code, LED code, whatever
}
} // end loop

Sorry for the late reply, but thank you so much! I will play around with the code. Hopefully I get to accomplish what I'm trying to do. But thanks again. Great help :slight_smile: