hi~i want counter at piezo buzzer...
when i push the button buzzer will beep 2times and very quickly ,so i need to use interrupt to read the buzzer.if using void loop cannot read it .
the problem is im using 1 pin only ,interrupt,then i need tho counter the beep sound .
if (digitalRead(button)==LOW)
1 beep sound,and starting counter.starting counter from 0
digitalWrite,5,HIGH
2 beep sound,and starting counter from 0
examples:if (beep =1) { //1 beep sound
3 beep sound,and starting counter from 0
examples:if (beep =1) { //1 beep sound
a=1;
}
if (beep =2) { //2 beep sound
a=2;
}if (beep =3) { //3 beep sound
a=3;
}
need to help...thx
I think you need to explain a bit better what you are trying to do.
Perhaps a drawing of the intended circuit.
As it stands it appears you are not clear on how the interrupt works.
Right, a state machine is required to detect a variable number of beeps.
haoyee12:
hi~i want counter at piezo buzzer...
when i push the button buzzer will beep 2times and very quickly ,so i need to use interrupt to read the buzzer.if using void loop cannot read it .
the problem is im using 1 pin only ,interrupt,then i need tho counter the beep sound .
if (digitalRead(button)==LOW)
1 beep sound,and starting counter.starting counter from 0
digitalWrite,5,HIGH
2 beep sound,and starting counter from 0
examples:if (beep =1) { //1 beep sound
3 beep sound,and starting counter from 0
examples:if (beep =1) { //1 beep sound
a=1;
}
if (beep =2) { //2 beep sound
a=2;
}if (beep =3) { //3 beep sound
a=3;
}
need to help...thx
Language problem???
Try a language closer to your native language:
中文 - Chinese
Deutsch - German
Español - Spanish
Français - French
অসমীয়া, বাংলা, बड़ो (India)
Italiano - Italian
Nederlands - Dutch
Português - Portuguese
Русский - Russian
Svenska - Swedish, Suomi - Finnish, Norsk - Norwegian
advice on interrupts: experiment with
attachInterupt(2, isr, RISING);
attachInterrupt (INT4, isr, RISING);
attachInterrupt (digitalPinToInterrupt(2), isr, RISING);
to see if they behave as you expect. I get the results I need from
attachInterrupt (digitalPinToInterrupt(2), isr, RISING);
but not from the other 2. Pin 2 is INT04 on a Mega
Do you want to play with interrupts, or do you want to detect the number of buzzer beeps?
That's 2 very different things!