One-chip computer experiment 1: simply realize the light-emitting diode on and off

Description

Use keil to write a program to achieve the following functions:
Connect a light-emitting diode D1 to the P1.0 port, make D1 keep on and off, and the time interval between on and off is 0.2s.
Requirements: Verification by Proteus simulation:

  1. AT89C52 is used as the single chip
  2. Submit simulation process, results and source code

Experimental circuit diagram

Insert picture description here

experiment analysis

This experiment is too simple and there is nothing to analyze.

Source code

#include<reg52.h>

sbit light = P1^0;

// delay 0.2s
void delay(void) {
    
    
	unsigned int i, j, k;
	for(i = 20; i > 0; i--) {
    
    
		for(j = 20; j >0; j--) {
    
    
			for(k = 248; k > 0; k--);
		}
	}
}

void main() {
    
    
	while(1) {
    
    
		light = 0;
		delay();
		light = 1;
		delay();
	}
}

Guess you like

Origin blog.csdn.net/Cyril_KI/article/details/110578485