I've chosen the 16F676 for size and cost and it also has an ADC which I also need. I need to use all the I/Os and I need to use PORTA.3 (MCLR) as a digital input to be used with a button. The "big" program isn't working so I've broken it down into smaller parts to make sure everything is working correctly. Below is the code to use the button to toggle an LED on and off. The start up works and the button turns the LED on, but only one time. Once the LED is toggled on for the first time, it gets stuck. What am I doing wrong?
Code:#config __CONFIG _CP_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF #endconfig TRISA = 001000 LED var PORTA.1 PUSHBUTTON var PORTA.3 '***********************start up just to make sure LED is working************************** led = 1 pause 100 led = 0 pause 100 led = 1 pause 100 led = 0 '*************************************************************************************** main: if PUSHBUTTON = 0 then toggle led pause 25 endif goto main end




Bookmarks