BÀI 4 : GIAO TIẾP VƠI NÚT NHẤN PIC16F84A XC8

2:44:00 AM
- Đây là ảnh mô phỏng protues.
button led pic16f84a xc8
- Đây là code chương trình.
#include <stdio.h>
#include <stdlib.h>
#define _XTAL_FREQ 8000000 // if 4Mhz is XT
#include <xc.h>
// CONFIG
#pragma config FOSC = HS        // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF       // Watchdog Timer (WDT disabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (Power-up Timer is disabled)
#pragma config CP = OFF         // Code Protection bit (Code protection disabled)

void main(void)
{
    TRISA = 0XFF;
    TRISB = 0X00;
    PORTB = 0X00;
    while(1)
    {
        if(RA0==1)
        {
        __delay_ms(100);
        while(RA0==1)
        {
            RB7=1;
        }
        }
        if(RA1==0)
        __delay_ms(100);
        while(RA1==0)
        {
            RB7=0;
        }
    }
}
- Link download project Click here

Share this

Related Posts

Previous
Next Post »