User Tools

Site Tools


dev8051:code8051

8051 Codes

Example codes (in C) for the classical Intel-8051 (mcu51) microcontroller core. Using my1code51 library. Tested using sdcc open source compiler and stc12 device.

Codes for NMK322

Testing IR module and HC-SR04 ultrasonic sensor module.

Testing HC06 bluetooth module , TowerPro MG996R servo & Text LCD.

Testing Base Kit (202425s1).

Testing RFID (FRC522) and OLED (ssd1306).

Code: relay

Testing basic relay.

relay.c
/*----------------------------------------------------------------------------*/
#include "timer.h"
#include "uart.h"
/*----------------------------------------------------------------------------*/
MY1SBIT(DRIVE,PIN20);
MY1SBIT(INPUT,PIN10);
/*----------------------------------------------------------------------------*/
void main(void) {
	unsigned char wait;
	timer_init();
	uart_init();
	uart_puts("\nTESTING RELAY\n");
	DRIVE = 1; /* active low */
	INPUT = 1;
	while(1) {
		if (INPUT==0) {
			uart_puts("-- Switch ON... ");
			DRIVE = 0;
			wait = 3*TIMER_LOOP_1S;
			do { timer_wait(TIMER_VAL50MS); } while (--wait);
			uart_puts("OFF.\n");
			DRIVE = 1;
			while (!INPUT);
		}
	}
}
/*----------------------------------------------------------------------------*/

Code: gtuc51

Test code for the old GTUC51B001 development board.

dev8051/code8051.txt · Last modified: by azman