My sketch is running two functions simultaneously when they should be consecutive. I don't seem to be getting an End of Message signal back from the voice recorder. But the program should do nothing until it does.
What I am trying to do is
1 Push Button
1a. Send signal to start voice recorder
2.Have voice recorder say its speech
2a. Do nothing until get EOM.
2b. Receive End Of Message signal
3. Wait Random time
4. Play tone
5. Operate a relay.
Components
Arduino Uno
Relay module ( no ID number on it)
Nuvoton ISD 1800 Series
Single Chip, Single message, voice record/playback device. (1820PY)
I have a number of issues may or may not be related.
- Can receive the EOM signal when I just test the voice recorder, but not receiving it when I hook the components together.
2.Two subroutines operate simultaneously when they should be consecutive.
The voice recorder starts its talk but also the tone sounds at the same time. The tone should not start until the recorder has sent an EOM signal back to the arduino, and waited a random time.
The programming faults I feel I have are.
-
Receiving the EOM signal in the proper manner ie analog signal on analog pin?
and conditioning the signal to be used by the arduino. If I expect a low signal from recorder, how is the arduino dealing with this? Incorrect programming statements? -
The "While " function may not be used in the correct manner.
-
Am I mixing analog and digital signals and expecting it to work?
-
Am I incorrectly programming the "test for a low signal"?
-
My conversion from analog to digital is faulty.
The End Of Message signal is a high to low appearing on the LED output of the voice recorder. The Voice Recorder LED flashes on at the EOM. This can be seen in the video.
Below is the section of the sketch I feel is the problem area. However I will attach the complete sketch as well as a picture of the circuit diagram, a link to a short video showing the simultaneous actions and the data sheets for the ISD1820. (sorry don't know how to make hyperlink.)
Below this code I shall put the monitored output as I added a number of print lines to try to find where the sketch was failing. I had no luck but I'm hoping a more experienced person on this forum can find my errors.
Thank you in advance for all help received.
Link to Video
Link to Data Sheet
void GetEomSignal (){ //watch for EOM signal from recorder
Serial.println("just testing EOM here");
// read the input on analog pin 1:
int eomState = analogRead(eomPin);
Serial.print("eomState is ");
Serial.println(eomState);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = eomState * (5.0 / 1023.0);
//delay (10);
Serial.print ("voltage b4 is ");
Serial.println(voltage);
while(analogRead(eomPin) ==0); {
//DO I NEED TO WAIT TO SEE THE LOW SIGNAL? .IS IT TOO QUICK? Make it wait until receive Low signal, Shouldnt it wait here til it gets the LOw signal. Need LOW to return for next routine. But it will break out before the low signal because already it is false. But other command !=0 wont work. What about ==1? but it is analog. That didnt work anyway.
//digitalWrite(ledPin,LOW); // simulate playlpin here for testing purposes.
Serial.println("waiting for low signal EOM"); }
Serial.print ("voltage after is ");
Serial.println(eomPin);
digitalWrite (playlPin, LOW);
digitalWrite (ledPin, LOW);
Serial.println("eom sent. eom sent.eom sent.");
}
// delay (1000);
void RandomStart (){
Monitored Output
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 = 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
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
The result if the line reads " while(analogRead(eomPin) !=0);"
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
Arduino Forum Sketch.txt (6.09 KB)