I am very rusty with Arduino and am trying to create a simple circuit for a wearable device which I will be using as a training timer to aid with archery target shooting.
Goal:
When the button is (momentarily) pressed, generate a tone from buzzer which sounds at random intervals between 2 second and 5 seconds after time of button push. I am also hoping for a clean serial monitor which prints 1) button push occurred 2) tone was generated 3) random time interval generated (to simply ensure that these are, in fact, random).
For example, press button -> tone sounds from buzzer in 3.2 seconds (randomly generated). Press button again, tone sounds at 4.1 seconds (randomly generated), etc. etc.. *Tones should never be generated outside of 2 seconds and 5 seconds after button press.
I am trying to avoid using a circuit which requires the button to use power from the 5V pin + 10k resistor to ground and instead, simply use the input from the 2-leg button as a signal.
*I am aware that I do not have any code written to account for the buzzer output. I'm just stuck and need some help!
Hardware:
- Arduino Nano Every
- Lilypad button (2 leg button +/-)
- Lilypad buzzer (+/-)
- 9V power supply
Wiring:
- Button input: pin D5
- Buzzer output: pin D6
- Power supply: GND/Vin
Thanks in advance!
Longbow_Trainer_Yusef_Code.ino (502 Bytes)