51 MCU buzzer operation

It is very simple to make the buzzer sound. Add a low level to the buzzer so that the current flows through and the buzzer will sound.
The code is very simple and should be easy to understand!

#include <reg52.h>

sbit beep=P2^3;
void main()
{
    int a;
    while(1)
    {
        a=66666;
        beep=0;
        while(a--);
        a=66666;
        beep=1;
        while(a--);
    }
}
0

Leave a Reply

Your email address will not be published.