#include <REGX52.H>
#define SW1 P2_0
#define SW2 P2_1
#define SW3 P2_2
#define BEEP P1_6
#define LED1 P1_5
#define LED2 P1_4
#define LED3 P1_3

void delay(unsigned int count) {
    unsigned int x, y;
    for (x = 0; x < count; x++)
        for (y = 0; y < 1275; y++);
}

void main(void) {
    SW1 = SW2 = SW3 = 1;
    BEEP = LED1 = LED2 = LED3 = 1;
    while (1) {
        if (SW1 == 0) {
            LED1 = 0; LED2 = 1; LED3 = 1;
            BEEP = 0; delay(25); BEEP = 1;
            while (SW1 == 0);
        }
        if (SW2 == 0) {
            LED1 = 1; LED2 = 0; LED3 = 1;
            BEEP = 0; delay(25); BEEP = 1;
            while (SW2 == 0);
        }
        if (SW3 == 0) {
            LED1 = 1; LED2 = 1; LED3 = 0;
            BEEP = 0; delay(25); BEEP = 1;
            while (SW3 == 0);
        }
    }
}
