Skip to content

Instantly share code, notes, and snippets.

@supersonictw
Last active March 7, 2020 13:45
Show Gist options
  • Save supersonictw/10c2012e853b3fbf5c64e739cf596065 to your computer and use it in GitHub Desktop.
Save supersonictw/10c2012e853b3fbf5c64e739cf596065 to your computer and use it in GitHub Desktop.
Keli C TEST Code for Atmel AT89S51
#include <reg51.h>
#define LED P1
// (c) 2020 SuperSonic (https://github.com/supersonictw)
sbit buzzer = P0 ^ 1;
void delay500us(int);
void pulse_bz(int, int, int);
int main()
{
int c;
LED = 0x01;
buzzer = 0;
while (1)
{
for (c = 0; c < 8; c++)
LED << 0;
for (c = 0; c < 8; c++)
LED >> 0;
delay500us(6000);
pulse_bz(100, 10, 10);
delay500us(100);
pulse_bz(100, 10, 10);
delay500us(100);
pulse_bz(100, 10, 10);
delay500us(100);
}
}
void delay500us(int x)
{
int i, j;
for (i = 0; i < x; i++)
for (j = 0; j < 60; j++)
;
}
void pulse_bz(int count, int TH, int TL)
{
int i;
for (i = 0; i < count; i++)
{
buzzer = 1;
delay500us(TL);
buzzer = 0;
delay500us(TH);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment