OK heres the jist...... 4th grade son needs to do an "invention". what does he want to do? I see you tinkering with stuff all the time....How about a timer that counts down when I'm playing video games and than shuts off the TV? WHOA, slow down. Let me do some research first.
Many days later.........
How about we just do a countdown timer? Sounds super simple right?
Well here is where i need help. FAST (due tomorrow!!!!)
I have a
http://nootropicdesign.com/digitshield/which is actually just a 4 digit 7 segment display with the transistors and time shifters built in on a protoshield board.
I can easily get a countdown timer going with no problem, But 2 things.......
All i want to do is add:
1) a piezo buzzer at zero that buzzs for no longer than like 3 or 5 seconds and
2) a button or switch so that when it gets to zero will reset back to given a total seconds
not anything that changes time or pauses or anything
Right now all it does is loop from 300 seconds to zero than back to 300 to zero again and again and again.
Heres the code so far it already has the setup for the button and buzzer (I think)
I read all the tutorials on timer, tone, stopwatch, etc HELP!!!!!!!
#include <DigitShield.h>
float counter = 0;
int d = 10;
const int buttonPin = 8; // the number of the pushbutton pin
const int speakerOut = 9;
int buttonState = 0; // variable for reading the pushbutton status
#define BUTTON 8
void setup(){
pinMode(buttonPin, INPUT);
pinMode(speakerOut, OUTPUT);
DigitShield.begin();
DigitShield.setPrecision(0);
}
void loop() {
DigitShield.setValue(counter);
counter = counter - .0001;
if(counter <=0) {
counter = 300;
}
}