Let the future tell the truth and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I really worked, is mine. (Nikola Tesla)

15/08/2010

●Flashing LED Controlled by a Button

Here is the program written by using CCS C.


#include <16f628.h>
#fuses NOPROTECT, NOWDT, NOLVP, NOMCLR INTRC_IO //Adding internal oscillator with INTRC_IO and MCLR makes possible to reset but with NOMCLR there is no need to connect anything that pin
#use delay(clock=4M) //To define the delay time correctly

void main(){
while(1){ // For an endless loop
if(!input(pin_a0)) //Checking the input of the first pin of port A
output_high(pin_b0); //If input is low, LED flashes
else output_low(pin_b0); //If input is high, LED doesn't flash
}
}


ShareThis