51 single chip microcomputer experiment - simulating three machine fault detection and indication systems

Publisher:EternalBlissLatest update time:2022-09-06 Source: csdn Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Experimental topic:

A three-machine fault detection and indication system is simulated in Proteus, as shown in Figure 2. When there is no fault, LED0 is on; when there is a fault, LED0 is off. When fault 1 (P2.0 is 0), LED1 is on; when fault 2 (P2.1 is 0), LED1 is on; when fault 3 (P2.2 is 0), LED3 is on.


2.KEIL code

#include

sbit LED=P1^0;

sbit LED1=P1^1;

sbit LED2=P1^2;

sbit LED3=P1^3;

sbit P20=P2^0;

sbit P21=P2^1;

sbit P22=P2^2;

void INT0_Init() //Write interrupt initialization function

{

EA=1; //Turn on the interrupt master switch

EX0=1; // Enable external interrupt 1

IT0=1; //Set to falling edge trigger

}

void main()

{

INT0_Heat();

while (1)

{

if(P20==1&&P21==1&&P22==1) {LED=0;LED1=1;LED2=1;LED3=1;}

else LED=1;

}

}

void INT0_Rupt() interrupt 0 //Write external interrupt 0 service function

{

LED1=P20;

LED2=P21;

LED3=P22;

}


3. Protues simulation diagram

When no button is pressed, the LED is on:

When button 2 is pressed, LED goes out and LED2 turns on.

Reference address:51 single chip microcomputer experiment - simulating three machine fault detection and indication systems

Previous article:51 MCU experiment - Use timer 0 to realize the running light, requiring each LED to display for 1s in turn
Next article:51 MCU Experiment - Using External Key Interrupt to Implement Quaternary Counter

Latest Microcontroller Articles
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号