Hi, I'm trying to program the above, without using a 555. I want to do it in software with Arduino if possible.
Closest I have so far is:
//This is an extract
//"bip" is the tone to generate, outPin is the piezo connection
//"playBip" is triggered by a set of external conditions being met in the main loop.
void playBip(const int outPin)
{
unsigned long currentBipmillis = millis();
if (currentBipmillis - previousBipmillis >= bipmillisInterval)
{
previousBipmillis = currentBipmillis;
if (bipState == 0) {
bipState = 1;
bipmillisInterval = 20;
tone(outPin, 1320);
} else {
bipState = 0;
bipmillisInterval = 500;
noTone(outPin);
}
}
}
This generates the desired tone for the desired duration, but will not accept another input inside the 500ms down time, and will re-trigger itself after 500ms. I want it so that is will generate a 20ms tone once and once only on each trigger, as long as the trigger does not repeat within 20ms, and will remain down indefinitely until the next external trigger.
Thoughts, ideas, etc? Yup, I've looked and pretty much everything I've seen so far resorts to 555's and 7400 series.