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:
- AT89C52 is used as the single chip
- Submit simulation process, results and source code
Experimental circuit diagram
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();
}
}