I am trying to build a BMX start gate using a voice recorder to play the Random Start sequence.
I am having trouble getting the program to run each subroutine separately. It seems that the program is not waiting at the appropriate time therefore it executes two routines concurrently.
As soon as I press the button, the beeps ( tone) starts as well as the voice recorder. The beeps should not start until the End of Message signal has been received back from the voice recorder. Im sure I have a fault in my WHILE statement.
Program as a BMX start gate.
Push Start Button
(Detect button push)
(Ensure only one button push)
Send signal to voice recorder to initiate recorded message.
Wait for End Of Message signal.
When EOM signal received, start random delay.
When random delay has ended,
Play tones.
At end of tones,
Operate relay.
I am using
Arduino Uno
Relay module ( no ID number on it)
Nuvoton ISD 1800 Series
Single Chip, Single message, voice record/playback device.
Data sheets here. (Sorry it doesn't seem to want to make a hyperlink, have to cut and paste)
(If link doesnt work please let me know.)
I have connected the Play L pin on the voice recorder to pin 4 of the Arduino and
LED pin ( EOM ) of recorder to pin A1 of the Arduino
To my understanding, the EOM signal should be a low so using an Analog input of Arduino to detect it.
I have included a bmp pic of the circuit. As attachment or link
Dropbox - File Deleted - Simplify your life BMX Start Gate1.png?dl=0
I have also included a short video showing that both events happen at the same time, when one event should proceed the other.
Dropbox - File Deleted Arduino.mp4?dl=0
Sketch is in the attachment
Below is the result for when it plays the beeps and voice together. It appears to follow the program but somehow it is ignoring the WHILE statement or getting it too early.
Starting new Random Number Sequence
debounce val1_
0debounce val2_
0waiting for button press
waiting for button press
waiting for button press
waiting for button press
just testing here
00button pushed
playl high
led on
returned from debounce routine
move to subroutine get eom
just testing EOM here
eomState is 1023
voltage b4 is 5.00
waiting for low signal EOM
voltage aft is 15
eom sent. eom sent.eom sent.
random start subroutine getting delay time
The Random Number is = 2255
Back from random delay, now go play beeps
start beeps
finish beeps go back
debounce val1_
0debounce val2_
0waiting for button press
waiting for button press
waiting for button press
waiting for button press
waiting for button press
When I put this line in,
"while(analogRead(eomPin) !=0);"
this is the result below.
The voice recorder does its bit but that is all.
waiting for button press
waiting for button press
waiting for button press
just testing here
00button pushed
playl high
led on
returned from debounce routine
move to subroutine get eom
just testing EOM here
eomState is 1023
voltage b4 is 5.00
stops at this point.
The result if the line reads " while(analogRead(eomPin) ==1);"
waiting for button press
waiting for button press
waiting for button press
just testing here
00button pushed
playl high
led on
returned from debounce routine
move to subroutine get eom
just testing EOM here
eomState is 1023
voltage b4 is 5.00
waiting for low signal EOM
voltage aft is 15
eom sent. eom sent.eom sent.
random start subroutine getting delay time
The Random Number is = 1958
Back from random delay, now go play beeps
start beeps
finish beeps go back
debounce val1_
0debounce val2_
0waiting for button press
waiting for button press
waiting for button press
waiting for button press
waiting for button press
Seems like it does roughly the same thing no matter how I phrase the statement, so Im definitely doing something wrong for it to ignore it all the time.
I also get random firings of the voice recorder. Every now and then it will go through the "ok riders ...." recording. But nothing else happens, it just plays the recording, like there has been a trigger on the Playl pin.
Any help would be greatly appreciated,
Thank you for your time.
BMX Sketch.txt (6.16 KB)