Beep

The beeper will beep

hardware

code

#include <reg52.h>

#define on 0
#define off 1

sbit fm = P2^3;

void delay (unsigned int xms)
{
    unsigned int i,j;
    for (i = xms; i > 0; i--)
        for(j = 112; j < 0; j--);
}

void main()
{
    while (1)
    {
        fm = on; //P2^3 = 0;
        delay(1000);
        fm = off;
        delay(1000);
    }
}
#include <reg52.h>
#include <intrins.h>

#define on 0
#define off 1
sbit fm = P2^3;

void delay (unsigned int xms)
{
    unsigned int i,j;
    for (i = xms; i > 0; i--)
        for(j = 112; j < 0; j--)
}

void main ()
{
    P1 = 0xfe; //1111 1110
    while(1)
    {
        delay(100);
        P1 = _crol_ (P1, 1); // P1 = P1 << 1
        fm = 0;
        delay(100);
        fm = off;
    }
}

Page Source