#include void Led_Disp(unsigned char addr,enable) { static unsigned char temp = 0x00,temp_old = 0xff; if(enable) temp = temp | (0x01 << addr); else temp = temp & (~(0x01 << addr)); if(temp != temp_old) { P2 = P2 & 0x1f | 0x80; P0 = ~temp; P2 &= 0x1f; temp_old = temp; } } void Relay(bit enable) { static unsigned char temp = 0xff; static unsigned char temp_old = 0x00; if(enable) temp |= 0x10; else temp &= ~0x10; if(temp != temp_old) { P2 = P2 & 0x1f | 0xA0; P0 = ~temp; P2 &= 0x1f; temp_old = temp; } }