Help a NOOB with his first project

OK so for anyone out there that has seen the Chappelle Show you may be familiar with the WRAP IT UP BOX . Essentially it is a box with a speaker and blinking red light that plays crescendo orchestra music giving people the hit that they have gone on too long with whatever they are talking about, or doing (just like a long winded speech at a Hollywood award show). So I figured this would be a good first project for me and the arduino (hopefully this will end up on a teensy) . I figured all I really need to do is blink a light, because I have a 2 minute greeting card style music player module to get the audio going. So that is not the problem. I also found a way to make the light blink for the two minutes and then shut off. However I know I am going about this all wrong. I assume I should be using a counter or something instead of just repeating pin on, pin off a bunch of times. Also, I know there should be a debouncing function. Now, if I can get really fancy I would like it to stop blinking if you press the button (momentary switch) while it is blinking because the music stops on the greeting card module if pressed a second time and I am using the same button to control both. There is probably a better way to go about that as well but it seems to work for now.

That seemed long winded so to recap. I would like to use a momentary switch to blink a LED on/off about once per second for about 2 minutes. If the switch is pressed during the two minutes the led would turn off. If pressed again (while off) the blinking would start again for two minutes, and so on.

Here is the code I have so far. I took out some of the lines that repeat over and over but I would like this to go on for about 2 minutes ideally.

int switchPin = 8;
int ledPin = 11;

void setup()
{
  pinMode(switchPin, INPUT);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
  digitalWrite(switchPin, LOW);
  }

void loop() {
if(digitalRead(switchPin) == HIGH)
{
    digitalWrite(switchPin, HIGH);
    digitalWrite(ledPin, HIGH);
    delay(433);
    digitalWrite(ledPin, LOW);
    delay(433);
    digitalWrite(ledPin, HIGH);
    delay(433);
    digitalWrite(ledPin, LOW);
    delay(433);
    digitalWrite(ledPin, HIGH);
    delay(433);
    digitalWrite(ledPin, LOW);
    delay(433);
    digitalWrite(ledPin, HIGH);
    delay(433);
    digitalWrite(ledPin, LOW);
    delay(433);
    digitalWrite(ledPin, HIGH);
    delay(433);
    digitalWrite(ledPin, LOW);
    delay(433);
    digitalWrite(ledPin, HIGH);
    delay(433);
    digitalWrite(ledPin, LOW);
    delay(433);
    digitalWrite(ledPin, HIGH);
    delay(433);
    digitalWrite(ledPin, LOW);
    delay(433);
    digitalWrite(ledPin, HIGH);
    delay(433);
    digitalWrite(ledPin, LOW);
    delay(433);
    digitalWrite(ledPin, HIGH);
    delay(433);
    digitalWrite(ledPin, LOW);
    delay(433);
    digitalWrite(ledPin, HIGH);
    delay(433);
    digitalWrite(ledPin, LOW);
    delay(433);
    digitalWrite(switchPin, LOW);
    
}
else
digitalWrite(ledPin, LOW);
}

Thanks any help in the right direction would be appreciated.

Also, if you are curious about the original skit just google 'wrap it up box' and there should be a vimeo video. Parental discretion advised

Have a look at how the LEDs are managed in Several Things at a Time

...R

Thank you for the suggestion, but that is wayyy beyond my comprehension. I think you need an ** next to the tag line 2-3 hours of thinking and reading solves most programming problems.... I believe that only applies if you have a clue as to what you are doing. I do not fall into that category, I have never done any coding of any kind or made a website... I don't even have a facebook. It took me about a week to get the code I posed after watching all the Jeremy Blum videos on Youtube. I'm sure that is seen a quite pitiful around here but I'm a welder not a computer guy. I feel like this world is kind of like being dropped off in the shallow end of a pool to someone who has no idea what water is, while everyone else is on the high dive. At least the arduino is not a big investment. I do very much appreciate your response though. Please don't mistake that. p.s. it took me a half hour to find and use the 'code' button.

Jessehn:
but I'm a welder not a computer guy.

A lot depends on whether or not you want to become a computer guy - at least as a hobby.

I quite understand if you don't. But then maybe you just need to pay someone to do the programming for you - if so you can ask in the Gigs and Collaborations section.

If you do want to learn to program an Arduino then all the people here will be very willing to assist your learning. And maybe you should start with a simpler project. I suspect you did not weld a fine cosmetic repair to a car body or a solid repair to a 30 tonne excavator on the first day at welding school.

...R

Definitely sounds like this was too ambitious as a first project. However from what I read before I bought the arduino making a light blink was about as easy as it gets. I didn't realize I would be overwhelmed by trying to get the light to stop blinking. That's exactly what I am trying to do is learn. I have had success with cut and paste, despite my ignorance.

The link I gave you in Reply #1 has blinking LEDs.

If you want one of them to stop blinking then stop calling the function (for example updateLed_A_State() ) that changes the state at the relevant intervals.

For example you could have code something like this

if (ledAshouldBeBlinking == true) {
   updateLed_A_State();
}

You may also be interested in Planning and Implementing a Program although it was not written for a complete beginner.

...R

It's about perfect difficulty for a beginner. The problem you have at the moment is while you are delaying, the arduino isn't doing anything. Have a look at the blink without delay example that's included in the IDE.

Well I think its time to bust out the old 556 timer. Programming is not very forgiving.

I have used 556 timers in the past. I find programming much easier. But it's fun that we are all different.

...R