#include #include /*-------------------------------------------------------- ALARM APPLICATION (IO TESTING) Testing of slot sensor. Alarm sounds when sensor is blocked. 8051 runs on 24 MHz Author: Leong KJ Date: 04-Aug-08 Version: 1.00 STATUS: working Target: AT89C5131 CIRCUIT B ---------------------------------------------------------*/ //-------- LCD Control Definition ------ #define RS P20 #define RW P21 #define E P22 #define LED P36 #define SpkPort P35 #define SlotSensor P37 void delay(unsigned int k) /*------------------------------------------ Basic Software Loop Delay --------------------------------------------*/ { while(k--!=0); } void strobe() { E = 1; delay(150); E = 0; delay(150); } //----- LCD initialisation ----- void LCD_init() { unsigned char x; for (x=0;x<3;x++) { P0=0x30; RS=0; RW=0; strobe(); delay(1500); } P0=0x38; strobe(); P0=0x0c; strobe(); P0=0x01; strobe(); P0=0x02; strobe(); } //----- LCD Character Print routine -------- void lcdPrint(unsigned char x){ P0 = x; RS = 1; strobe(); } //----- LCD Command ---------- void lcdCommand(unsigned char x){ P0 = x; RS = 0; strobe(); } //------ LCD Line Print --------- void lcdLinePrint(printData) unsigned char *printData; { unsigned char x; for(x=0;x