Home > other >  51 microcontroller passive buzzer
51 microcontroller passive buzzer

Time:09-22

Let 51 0.5 s passive buzzer rang, not ring 0.5 s, alternating ring three times after closing leds development board of the (general)
Great god answers, how do you control the buzzer rang time ah, I lost the buzzer rang time control combined with how the volume size,
I don't knock code can realize ring and ring three close alternately LED lights, small but sounds good, how to adjust sound ah # include "reg51. H
"Sbit beep=P0 ^ 0;

Void delay (unsigned int I)
{
Unsigned char k;
While (I -)
For (k=0; K<120; K++);
}
Void main ()
{
Unsigned char j, g=0;
Beep=0;
While (1)
{
If (g<3)
{
G + +;
for(j=0; j<10; J++)
{
Beep=~ beep;
Delay (50);
}
for(j=0; j<10; J++)
{
Beep=0;
delay(500);
}

}
P1=0 x00;

}
}
















CodePudding user response:

Try to adjust the frequency of the buzzer for (j=0; j<10; J++)
{
Beep=~ beep;
Delay (50); Adjust the delay size change frequency
}

CodePudding user response:

reference 1/f, the wise know already should good karma response:
try to adjust the frequency of the buzzer for (j=0; j<10; J++)
{
Beep=~ beep;
Delay (50); Adjust the delay size change frequency
}

Delay (50) to delay (5), ring 0.5 s time should be changed

CodePudding user response:

What method can control the time on the buzzer sound

CodePudding user response:

You write statement itself is a nested loop, adjust a loop, and then adjust another cycle and proved,

CodePudding user response:

references a wise man should know already take good karma, 4/f, response:
statement you wrote itself is a nested loop, adjust a loop, and then adjust another cycle and proved,

0.5 S will be changed

CodePudding user response:

Tended to the long, the long tended, inner loop, reduce external loop to increase the amount remains unchanged is that this is the very simple arithmetic principle, 10 * 50 * 100=500=500, 5, 500 correspond with you the next stop, is not? According to the calculation of your code,

CodePudding user response:

refer to 6th floor wise men know already should good karma response:
tended to the long, tended to decline, the long cycle in reducing the external loop increases, the total is unchanged, this is the very simple arithmetic principle, 10 * 50 * 100=500=500, 5, 500 correspond with you the next stop, is not? Calculated on your code,

Ok, wait a minute try, thank you

CodePudding user response:

refer to 6th floor wise men know already should good karma response:
tended to the long, tended to decline, the long cycle in reducing the external loop increases, the total is unchanged, this is the very simple arithmetic principle, 10 * 50 * 100=500=500, 5, 500 correspond with you the next stop, is not? Calculated on your code,

Great god: are there any other ways to achieve 0.5 s 51 passive buzzer rang, no ring 0.5 s, alternating ring three times after close the leds

CodePudding user response:

Of course, use a timer, can set the frequency and time at the same time,

CodePudding user response:

the wise know already, 9/f, reference shall be good karma response:
of course, use a timer, can set the frequency and time at the same time,

Ah, how to design for a great god save the children

CodePudding user response:

the wise know already, 9/f, reference shall be good karma response:
of course, use a timer, can set the frequency and time at the same time,

A detailed code, I don't really understand it

CodePudding user response:

To my blog to find examples

CodePudding user response:

No PWM, code delay control premise is not to have frequent interruptions, otherwise the voice is not sweet

CodePudding user response:

Time delay function adjustment

CodePudding user response:

Theoretically buzzer directly through the switch quantity control, can't adjust volume, only adjust the frequency, you say "volume" is only the frequency is too high or too low, the human ear can't hear, so only need to modify the time delay function, change of frequency can be achieved
  • Related