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