The program realizes the function. When the upper light is on and the low level is on, the upper light is on. The same is true for the others. However, when the two lights are on and the low level is on, the other two low levels will prevent the upper lights from being on at the same time. The code is as follows:
#include
sbit P1_0 = P1^0;
sbit P1_1 = P1^1;
sbit P2_0 = P2^0;
sbit P2_1 = P2^1;
sbit P2_2 = P2^2;
sbit P0_0 = P0^0;
void delay(unsigned char i) {
unsigned int j = 0,k = 0;
for(k = 0; k < i; k++)
for(j = 0; j < 255; j++);
}
void main(void){
bit left,right,security;
while(1) {
left = P2_0;
right = P2_1;
security = P2_2;
P0_0 = 0;
if (left != 1 && right == 1) {
P1_0 = left;
delay(250);
}
if (right != 1 && left == 1) {
P1_1 = right;
delay(250);
}
if(security != 1 || (left != 1 && right != 1)) {
P1 = 0;
delay(250);
P1_0 = 1;
P1_1 = 1;
delay(250);
}
P1_0 = 1;
P1_1 = 1;
delay(500);
}
Previous article:Single chip cycle water lamp 2
Next article:Single chip crossroad traffic light
Recommended ReadingLatest update time:2024-11-16 13:41
C source program of frequency meter based on AT89C51 single chip microcomputer and main functions of frequency meter
This article is a C source program for a frequency meter based on the AT89C51 microcontroller. The main functions of this frequency meter are as follows: 1. Test functionality It indicates all the test functions of the digital frequency meter, generally including frequency measurement, period , cumu
[Microcontroller]
Clock Interrupt in MCU Programming
This article takes the AT89C51 system with a 6MHz clock as an example to illustrate the application of clock interrupts:
Timer initial value and interrupt cycle The clock interrupt does not need to be too frequent, generally 20mS (50Hz) is sufficient. If a time base signal of one hundredth of a second is requir
[Industrial Control]
Study of Songhan MCU assembly program
It is almost impossible to find learning materials for assembler programming on the Internet. I also learned slowly from my master. Only then did I understand it.
Let me write a summary... I have a psychological explanation for myself. I have wanted to write a summary for a long time... but I have never done it... and
[Microcontroller]
PIC microcontroller basic learning program design
PIC microcontroller (Peripheral Interface Controller) is an integrated circuit (IC) used to develop and control peripheral devices. It is a CPU with decentralized (multi-tasking) functions. This content describes the learning of programming in PIC microcontrollers.
1. Basic format of PIC microcontroller program
[Microcontroller]
Microcontroller three-byte division subroutine
ORG 0000H
AJMP MAIN
ORG 0030H
MAIN:
MOV 77H,#0FH
MOV 78H,#42H
MOV 79H,#40H
MOV 7AH,#00H
MOV 7BH,#03H
MOV 7CH,#0E8H
LCALL DIV_MB
SJMP MAIN
;======= ==========================================
; DIVISION FOR THREE-BYTE DATA
; DIVIDEND FROM 77H&78H&79H
; DIVISOR FROM 7AH&7BH&7CH
; QUOTIENT TO 77H
[Microcontroller]
51 single chip microcomputer-temperature sensor and serial port
1. Question requirements Sometimes we need to know the historical data of the temperature measured by the temperature sensor over a period of time. The previous temperature sensor routine only displayed the data in real time on the LCD screen, and its historical data could not be viewed, so we used all the knowledge
[Microcontroller]
Basic steps of PIC microcontroller programming
Basic steps of PIC microcontroller programming
First, to master the programming method of the single-chip microcomputer, you must first be familiar with the representation of the instructions of the PIC single-chip microcomputer, the symbols of the instructions and the addressing method of the instructions.
Second
[Microcontroller]
Wang Bin of CoreShine Technology: How China Mobile's first RISC-V MCU drives the Internet of Everything
In July 2021, China Mobile's wholly-owned subsidiary, China Mobile IoT, Xinsheng Technology Co., Ltd., officially operated independently. At that time, Liu Chunyang, member of the Party Committee and deputy general manager of China Mobile IoT, said that Xinsheng Technology completed its registration at the end of 2020
[Microcontroller]
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- Pipeline water leakage monitor based on sound waves] Material unpacking-ESP32-S3-DEVKITC+STM32L496 Discovery kit
- [ESK32-360 Review] Potentiometer to adjust LCD text color
- Selling ZYNQ 7020 and other idle development boards
- During the Mid-Autumn Festival, engineers will not work overtime!
- Different types of pin headers
- How to select peripheral components of DC-DC boost regulator
- Example interpretation of 51 single chip microcomputer complete learning and application
- FM33LG0xx FL Library Examples & Keil Pack
- How do zstack routers and terminal nodes share a common set of programs?
- The efficiency has little to do with IC.