Need help with Sketch, Boxing Interval Timer

Hi, I need help with my Projekt. I want to Build a Boxing Timer the Function ist that i have a 3 position swith, 1 piezo, one Red LED and one Green Led. When Switch 1 = High and Switch 2 = LOW the timer intervall should be 1 minute to 1 minute. When Switch 1 = LOW and Switch 2 = LOW the Timer intervall should be 2 min to 1 minute. When Switch 1 = LOW and Switch 2 = High the Timer intervall should be 3 min to 1 minute. In the interval the red led should be blinking in 1sec rate in the 1,2 and 3 min intervall and in the brake of 1 minute the green led should be blinking. At the beginning and end of the 1, 2 or 3 min intervall the piezzo should be active for 1 sec. If the Switch does not change the intervall is a never ending loop, if the switch changes the new intervall starts.

I starter with this:

const switch1 = 2; // switch connected to pin 2
const switch1 = 3; // switch connected to pin 3
const led1 = 7; // led connected to pin 7
const led2 = 8; // led connected to pin 8

void setup(){
pinMode (switch1, INPUT);
pinMode (switch2, INPUT);
pinMode (led1, OUPUT);
pinMode (led2, OUPUT);
}

void loop(){
if (digitalRead(switch1) == HIGH digitalRead (switch2 == LOW){
do {
for (int x=0; x<60; x++){
digitalWrite (led1, HIGH);
delay (1000);
digitalWrite (led1, LOW);
delay (1000);
}
digitalRead (2);
}while (x<60);
}
}

Im still not sure in getting started with the whole thing.
I need some help!!!

I'm having some trouble understanding what you're trying to achieve. I suggest describing what you want to do in "boxer terms" rather than trying to describe what you want to do in "programmer terms".

For example, you use the phrase "the timer interval should be 1 minute to 1 minute". I have no idea what "1 minute to 1 minute" means. But I suspect someone familiar with boxing would know. ;)

CodingBadly: :stuck_out_tongue: (click on razz-smiley :wink: )

Anyhow, mischa_t, to see if I understand your question: you have two buttons, and you want three possible timing events
sw1:on , sw2:off : buzz 1sec red blink 1min, buzz 1sec, green blink 1min
sw1:off, sw2:off : buzz 1sec red blink 2min, buzz 1sec, green blink 1min
sw1:off, sw2:on : buzz 1sec red blink 3min, buzz 1sec, green blink 1min
sw1:on, sw2:on : nothing presumably

Well, if above is right then having written it like this the program is almost done. The program can be done fancy and optimized, but for this problem I think it can be written almost as above

void setup() { ...
  // pin output setup 
}


void loop() {
// sense switches, and I think it is nicer with a switch/case, so get it as one number
Timer = 0 ;
if (digitalRead(SW1)==LOW) Timer += 1 ; 
if (digitalRead(SW2)==LOW) Timer += 2 ; // This leaves timer with 0, 1, 2, or 3

// choose pattern
switch (Timer) {
  case 0: buzz() ; redblink(2); buzz() ; greenblink(1) ; break ;
  case 1: buzz() ; redblink(1); buzz() ; greenblink(1) ; break ;
  :
  }

}

void buzz() { 
  digitalWrite(...) ;
  delay(1000) ;
  digitalWrite(...) ;
}

void redblink( int minute ) {
  for (int s=minute*30-1; s>0; s-- ) { // compensate for one second lost in buzz()
  digitalWrite(...) ;
  delay(1000) ;
  digitalWrite(...) ;
}

Normally I abhor the use of delay(), but no rule without an exception. This means that changing the switches will not interrupt a running sequnce. Also the timing may be off by a second or so, but tweak away.

CodingBadly: smiley-razz (click on razz-smiley smiley-wink )

No thanks. I have better things to do than wade through "descriptions" like these...

Mode for HIIT Tabata Protocol (8 repetitions of 20/10) Boxing Timer is an application designed for your boxing training, sparring and workouts Ideal for workouts using heavy bags, speed bags, jump ropes, double-end bags or other types of interval training at the gym or home

:D

Thank Msquare, i will try what you suggested in your Sketch. And to the description it should be an easy round Timer, one round last 1, 2 or 3 minutes and after this you have 1 minute brake, after that the whole thing starts again and again. To the switch it is a switch with 3 pins and 3 positions, which means that once you have contact between the middle and upper contact, then you have once the middle and lower cantact and the third step is that you have no canct at all! But I thank you for the Help.

Hello Coding Badly, to what you wrote:

"No thanks. I have better things to do than wade through "descriptions" like these..."

Why do you even answer if it doenst interest you, wouldnt it be easyier to say nothing, you could save energy, but even thow thanks.

Why do you even answer if it doenst interest you

If your application did not interest me, my reply would not be #1.

What does not interest me is wading through pages of advertisements.

wouldnt it be easyier to say nothing, you could save energy

In my experience, the best quality applications are those rooted in the words of the end-user (you, in this case). So, even if I did have vast knowledge of boxing timers, it is still worth hearing, from you, what you would like to achieve.

but even thow thanks.

You are welcome. I wish you success.