User Tools

Site Tools


dev8051:code8051

This is an old revision of the document!


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

Codes to test hardware modules available for our NMK322 Microcontroller lab.

Code: IR module and Ultrasonic sensor module

Testing IR module and HC-SR04 ultrasonic sensor module.

Code: BT module and servo

Testing HC06 bluetooth module , TowerPro MG996R servo.

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

Code: Testing Base Kit

Testing Base Kit (202425s1).

Code: RFID module and OLED

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.1768925100.txt.gz · Last modified: by azman