Design Sharing | 51 Microcontroller TIMER0 Control for Running Lights

Design Sharing | 51 Microcontroller TIMER0 Control for Running Lights

Microcontroller design sharing and customization

Diary of an Electronic Engineer’s Growth

Design Sharing | 51 Microcontroller TIMER0 Control for Running LightsDesign Sharing | 51 Microcontroller TIMER0 Control for Running Lights

Specific Function Implementation:

Using the 51 microcontroller TIMER0 to control an 8-bit running light.

Design Sharing | 51 Microcontroller TIMER0 Control for Running Lights

Design Introduction

Design Sharing | 51 Microcontroller TIMER0 Control for Running Lights

Introduction to the 51 Microcontroller

The 51 microcontroller is a low-power, high-performance CMOS 8-bit microcontroller with 8K of programmable Flash memory, providing a highly flexible and efficient solution for numerous embedded control applications.

The 51 series microcontrollers have the following standard features:

8K bytes of Flash, 512 bytes of RAM,

32 I/O lines, watchdog timer,

Built-in 4KB EEPROM,

MAX810 reset circuit,

Three 16-bit timers/counters,

A 6-vector, 2-level interrupt structure,

Full-duplex serial port.

Additionally, the 51 series can stop the CPU in idle mode, allowing RAM, timers/counters, serial ports, and interrupts to continue functioning. In power-down protection mode, the RAM content is preserved, the oscillator is frozen, and the microcontroller stops working until the next interrupt or hardware reset.The chip used in this design is compatible with all 51 series microcontrollers (including AT series and STC series).

Design Sharing | 51 Microcontroller TIMER0 Control for Running Lights

Design Approach

Literature research method: Collect and organize relevant research materials, read literature to prepare for the study;

Survey research method: Identify existing problems and solutions through surveys, analysis, and specific experiments;

Comparative analysis method: Compare the specific principles of different designs and the performance differences of similar sensors, analyzing the current research status and development prospects of the system;

Software and hardware design method: Implement hardware through software and hardware design, and finally test whether all functions meet the requirements.

Reference template for microcontroller design papers:

Graduation Project Worry-Free | Microcontroller Graduation Project Paper Template

Design Content

Simulation Diagram (Proteus 8.7)

This design uses Proteus 8.7 software for simulation design, as shown in the figure.

Note: Free sharing, please draw the simulation according to the figure below!!

Design Sharing | 51 Microcontroller TIMER0 Control for Running Lights

Proteus 8.7 software materials and simulation solutions:

Proteus 8.7 installation and cracking tutorial (includes installation package)

Common problems and solutions for Proteus simulation

Simple tutorial for Proteus 8.7

Program (Keil 5)

This design uses KEIL 5 software for program design.

Note: All code is shared for free, please create your own project!!!!

This design is written in C language, and the complete code is as follows:

Design Sharing | 51 Microcontroller TIMER0 Control for Running Lights

The running result is shown in the figure:

#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint  unsigned int
void delay(uint z){
	uint x,y;
	for(x=z;x>0;x--)
		for(y=110;y>0;y--);
}
void ledliu(){
	uint aa;
	delay(500);
	aa=P1;
	aa=_crol_(aa,1);
	P1=aa;
}
void main(){
	P1=0xfe;
	TMOD=01;
	TH0=-50000/256;
	TL0=-50000%256;
	EA=1;
	ET0=1;
	TR0=1;
	while(1);
}/**************Interrupt Service Function*******************/
void T0_time() interrupt 1{
	uint i;
	TH0=-50000/256;
	TL0=-50000%256;
	i++;
	if(i==10){
		ledliu();
		i=0;
	}
}

Keil C51 software materials and usage tutorials:

Keil C51 installation and cracking tutorial (includes installation package)

KEIL 5 usage tips

Simple tutorial for Keil 5

Contact Us

Design Sharing | 51 Microcontroller TIMER0 Control for Running Lights

More design content:

Microcontroller physical design

Microcontroller simulation design projects

Microcontroller tutorials

Free design materials (C language)

Free design materials (Assembly)

Common problem solutions

Welcome to follow the WeChat public account “Diary of an Electronic Engineer’s Growth“!!

To contact us, please reply with the keyword “Customer Service” in the public account!!

Leave a Comment