Single chip microcomputer simulation car turn signal

Publisher:梦中的额吉Latest update time:2016-04-19 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
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 = P1_1 = security;
P1 = 0;
delay(250);
P1_0 = 1;
P1_1 = 1;
delay(250);
}
 
P1_0 = 1;
P1_1 = 1;
delay(500);
 
 }
}

Keywords:MCU Reference address:Single chip microcomputer simulation car turn signal

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]
C source program of frequency meter based on AT89C51 single chip microcomputer and main functions of frequency meter
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]
Study of Songhan MCU assembly program
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]
51 single chip microcomputer-temperature sensor and serial port
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]
Wang Bin of CoreShine Technology: How China Mobile's first RISC-V MCU drives the Internet of Everything
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号