Relay control using RELAY-2 Peripheral Board


Controls relays on the RELAY-2 peripheral board from BiPOM Electronics

Toolkit:SDCC 8051 Development System

Location:/bipom/devtools/SDCC/examples/relay2/

Code Example


// RELAY 1

#define JP1_RELAY1				P3_2
#define JP2_RELAY1				P3_3
#define JP3_RELAY1				P3_4
#define JP4_RELAY1				P3_5
#define JP5_RELAY1				P3_6
#define JP6_RELAY1				P3_7
// RELAY 2

#define JP7_RELAY2				P1_0
#define JP8_RELAY2				P1_1
#define JP9_RELAY2				P1_2
#define JP10_RELAY2				P1_3
#define JP11_RELAY2				P1_4
//

#define RELAY1					JP1_RELAY1
#define RELAY2					JP11_RELAY2
//

#define TurnOn(bit)  {bit=1;}

#define TurnOff(bit) {bit=0;}

//

#define TIMEOUT 2000
//  

main()
{
		for (;;)				// infinite loop

		{
			TurnOn(RELAY1);		// turn relay #1 on

			TurnOff(RELAY2);	// turn relay #2 off

			delay(TIMEOUT);		// 1 second pause

			TurnOff(RELAY1);	// turn relay #1 off	

			TurnOn(RELAY2);		// turn relay #2 on

			delay(TIMEOUT);		// 1 second pause

		}   
}