Hi everyone, I would like some help to solve a problem with a project that I’m working on. Hope someone can point out what I’m doing wrong and help correct the mistake. Basically I’m doing a project using PIC12F675 which blinks one of the two LEDs depending on how much voltage is fed in the ADC pin (Analog to Digital Conversion pin). I have used a LDR ( Light Dependent Resistor ) in series with a resistor as in a voltage divider concept and taking the voltage from the center of the LDR and resistor as the input for the ADC pin. The function of this whole circuit is to tell if the light ambience in the room is below or above a predetermined amount. It should blink Green for above and Red for below the predetermined amount. (I have attached a schematic for a clearer picture)
This is how I have programmed the PIC12F675 using PIC Basic Pro. Thanks in advance for the help
LED1 con 4
LED2 CON 5
CMCON=7
ANSEL=%00001000
TRISIO=%10000000
ADVAL VAR BYTE
K VAR WORD
ROCK VAR WORD
ROCK=%01010101
CHECK:
ADCIN 0, ADVAL
notdone:
IF ADVAL > ROCK THEN
GOTO MMM
ELSE
GOTO MM2
ENDIF
MMM: FOR K = 1 TO 2
HIGH LED1
HIGH LED2
PAUSE 250
LOW LED2
LOW LED1
PAUSE 250
NEXT K
GOTO CHECK
MM2: HIGH LED1
PAUSE 250
LOW LED1
PAUSE 250
GOTO CHECK
END
This is how I have programmed the PIC12F675 using PIC Basic Pro. Thanks in advance for the help
LED1 con 4
LED2 CON 5
CMCON=7
ANSEL=%00001000
TRISIO=%10000000
ADVAL VAR BYTE
K VAR WORD
ROCK VAR WORD
ROCK=%01010101
CHECK:
ADCIN 0, ADVAL
notdone:
IF ADVAL > ROCK THEN
GOTO MMM
ELSE
GOTO MM2
ENDIF
MMM: FOR K = 1 TO 2
HIGH LED1
HIGH LED2
PAUSE 250
LOW LED2
LOW LED1
PAUSE 250
NEXT K
GOTO CHECK
MM2: HIGH LED1
PAUSE 250
LOW LED1
PAUSE 250
GOTO CHECK
END