- Requirements: Use a PIC16F887 microcontroller to control 8 single leds on and off using the timer interrupt T1 with a delay period of 262ms.
- Circuit diagram on Proteus simulation software
Figure 1. Controlling 8 LEDs to turn on and off using interrupts |
- Main program:
File: main.c
___________________
#INCLUDE <16F887.H>
#FUSES NOWDT,PUT,HS,NOPROTECT,NOLVP
#USE DELAY(CLOCK=20M)
UNSIGNED INT8 X;
#int_timer1
void interrupt_timer1()
{
X=~X;
OUTPUT_D(X);
}
VOID MAIN()
{
SET_TRIS_D(0x00); X=0X00; OUTPUT_D(X);
SETUP_TIMER_1(T1_INTERNAL | T1_DIV_BY_8);
SET_TIMER1(0);
ENABLE_INTERRUPTS(GLOBAL); ENABLE_INTERRUPTS(INT_TIMER1);
WHILE(TRUE) {}
}
___________________
Link download: https://drive.google.com/file/d/1e_8QOGfguNwGeuFN-T0MR9-vJyvMLAmz/view
Comments
Post a Comment