BASIC4MCU | 질문게시판 | 8051 led 1초 점등
페이지 정보
작성자 디코랩 작성일2018-09-12 19:53 조회8,660회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=3059
본문
인터럽트 0번이 들어오면 포트 2_0의 led를 1초 켜졌다가 꺼지는 코드를 작성하고 싶습니다.
#include <reg51.h>
unsigned char led;
void delay(unsigned char i)
{
while(i--);
}void EXT0_int(void) interrupt 0
{
EA=0;
led = 0x00;
delay(7000);
led = 0xff;
EA=1;
return;
}void main(void)
{
TCON=0x01;
EX0=1;
EA=1;
PX0=1;
led=0xfe;
P1=led;
while(1);
}
현재 코드인데 딜레이 7000정도면 1초정도라 생각하고 작성하였으나 잘 동작이 되지 않아 질문 드립니다.
댓글 0
조회수 8,660등록된 댓글이 없습니다.