当前位置:网站首页>C51 single chip microcomputer, an entry-level tutorial for lighting up small lights
C51 single chip microcomputer, an entry-level tutorial for lighting up small lights
2022-06-24 05:51:00 【Distant stars】
- 51 First experience of single chip microcomputer
- Keil uvision5 C51 edition :
link :https://pan.baidu.com/s/1LI7ucKVBFwpx2VMOoHFmMg
Extraction code :d8u6
There is an activation step in the installation step , I didn't turn off the firewall , No success , But it does not affect the use .
- Proteus 8.6 SP2 Professional:
link :https://pan.baidu.com/s/1RbKt1XuDLZITgbVDcsmwWQ
Extraction code :ynt7
Two 、keli Use
1、 Create a project
open Keil Software , Click on the top of the toolbar project, choice new μVision Project...
2、 New file , Remember to save , For writing code
You can use the shortcut key Ctrl+S Preservation
Note the file suffix here .c Used for compiling C The program
3、 To configure 、 Add the document
Here we are , Completed the environment configuration , It can be programmed !
3、 ... and 、proteus Use
1、 Create project
open proteus Software , Click on the top left File, Click again New Project, This page appears
You may not choose 80C51, Come according to your own needs
Complete project creation !
2、 Build a virtual circuit
Four 、 Programming , Run the program
1、 Code writing
#include <reg52.h>
sbit led = P1^0; // Here is the port p1^0, Give a name
void main(){
while(1){ //while The death of the loop , Will always carry out while Contents of Li
led = 0; // Give port p1^0 Assign a low level , So that the small lamp forms a circuit ,1 For high level ,0 For low level
}
}This completes the writing of the code !
2、 The program runs
Click the run button in the lower left corner to complete the operation
If the code runs successfully , Failed to run , You can refer to here : Solution portal
3、 Running results
The figure is visible , When I click the run button , The little light is on , But I hit the end button , The small light goes out
( harm , Blue light , It's not easy to observe )
5、 ... and 、 A little more advanced : Running water lamp
1、 Virtual circuit
2、 Code
#include <reg51.h>
#define uint unsigned int
#define uchar unsigned char
uchar table[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};// Each one corresponds to a small lamp
uchar p;
int x;
void main()
{
x=50000; // Prepare a variable in advance , Used for delay action , Otherwise, the small lamp changes too fast
while(1)
{
for(p=0;p<8;p++) // loop , Turn the small lights on
{
P1=table[p];
while(x--);
}
}
}3、 Running results
6、 ... and 、 Article reference :
51 Introduction to single chip microcomputer (1)
51 Single chip microcomputer LED Lighten up 、 Flashing and running water lamp are realized
author : Stars in the distance CSDN:https://blog.csdn.net/qq_44921056
Tencent cloud :https://cloud.tencent.com/developer/column/91164
This article is only for communication learning , Without the permission of the author , Prohibited reproduced , Let alone for other purposes , Offenders will investigate .
边栏推荐
- To create a high-quality geek for human beings, cloud + community starts the competition "discovery plan"
- How to solve the problem that easynvr calls the video download interface of the specified time period to display "being synthesized" and does not generate video?
- What is the subdomain name and how to register the domain name
- PNAs: development of white matter pathways in human brain during the second and third trimester of pregnancy
- It is necessary to do the industry of waiting insurance evaluation. Let's see if you are on the list
- How to get the website domain name? Does it cost money to apply for a website domain name?
- Why storage?
- Technical dry goods | understand go memory allocation
- Disaster recovery series (III) -- cloud network disaster recovery construction
- Tomorrow, we will help farmers make their debut together!
猜你喜欢
随机推荐
[industry outlook] future development forecast of UHD video application
What is domain name resolution? How much does domain name registration cost
Kubernetes Chapter 1: Foundation
Fixed assets management software enables enterprises to realize intelligent management of fixed assets
PV and PVC analysis and use in kubernetes
How about the VIP domain name? Does the VIP domain name need to be filed after registration?
How does the company domain name come from? What kind of domain name is a good domain name
What are the advantages of building a private cloud platform?
What does it mean that the domain name is being walled? How to solve the problem of domain name by wall?
What does it mean that the terminal displays escape character is'^]'after the telnet peer port?
Tencent cloud harbor private warehouse deployment practice
What is domain name registration? Do you still need to purchase ECS after domain name registration?
[performance test] 3 How to calculate the number of concurrent users
What are the stages from tradition to Tencent cloud
How about the XYZ domain name? What are the advantages over other domain names?
Talk about my working experience in Tencent and byte
Groovy script engine practice in complex and changeable scenarios
What is the subdomain name and how to register the domain name
MySQL optimization
Massif tool of Valgrind