Question

i am using a PICkit2 Low Pin Count Demo board with a 16f690 chip. i have been able to write simple code to turn the LEDs on and off, but upon trying to utilize the push button to change the state of the LEDs, have been unable to do so. My code is below, along with a link to the schematic for the device.

#include <htc.h>

__CONFIG(MCLRE_OFF &  BOREN_OFF & PWRTE_OFF & IESO_OFF & CP_OFF & FCMEN_ON);

void main()
{
    //initialization
    TRISAbits.RA3 = 1;      //make button (RA3) input
    TRISCbits.RC0 = 0;      //make LED (RC0) output

    for(;;)                 // loop forever
    {
        //set RC0 if RA3 is low (button pressed), else clear RC0
        if(PORTAbits.RA3)
        {
            RC0 = 1;
        }
        else
        {
            RC0 = 0;
        }
    }
}

Demo Board User’s Guide

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top