TIMER0 controls a single LED to flash

Publisher:温文儒雅Latest update time:2021-12-22 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

insert image description here
insert image description here

The program C language source code is as follows:


/*

INT1 interrupt 5-bit count

*/

#include

typedef unsigned char uint8;

typedef unsigned int uint16;


sbit LED = P0^0;


uint16 T_Count = 0;


void main()

{

TMOD = 0x01;

TH0 = 0xFC;

TL0 = 0x67;

IE = 0x82;

TR0 = 1;

while(1);

}


void LED_Flash() interrupt 1

{

TMOD = 0x01;

TH0 = 0xFC;

if(++T_Count == 100)

{

LED = ~LED; //!LED

T_Count = 0;

}

}

Reference address:TIMER0 controls a single LED to flash

Previous article:INT1 interrupt five-bit counter PROTEUS and 51 microcontroller tutorial
Next article:4 Use the shift function to light up the running lights

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号