Hello Respected All Members,
I am new in this forum and in PIC Programming field. I need a little help in my small assignment.
I am using PIC16F676 MCU and MikroC compiler with internal Oscillator and internal MCLR voltage settings. In my circuit two 5k Potentiometer are connected with RA4 and RA3 for analog read input. One led connected on (Pin 13) RA0 of MCU for output. I want to adjust the time from 1 second to 10 seconds delay with respect to potentiometer for LED off/on. Means I wanna use RA4 potentiometer to set LED OFF delay and RA3 potentiometer to set LED ON delay.
This is my code written in Mikro C
This is my Proteus Simulation Snap
http://prntscr.com/9n2lmm
And this is my MikroC configuration Bit Settings:
http://prntscr.com/9n2lo8
I am new in this forum and in PIC Programming field. I need a little help in my small assignment.
I am using PIC16F676 MCU and MikroC compiler with internal Oscillator and internal MCLR voltage settings. In my circuit two 5k Potentiometer are connected with RA4 and RA3 for analog read input. One led connected on (Pin 13) RA0 of MCU for output. I want to adjust the time from 1 second to 10 seconds delay with respect to potentiometer for LED off/on. Means I wanna use RA4 potentiometer to set LED OFF delay and RA3 potentiometer to set LED ON delay.
This is my code written in Mikro C
Code:
sbit LED at RA0_bit;
unsigned int VR1_Value = 0;
unsigned int VR2_Value = 0;
void main(void)
{
CMCON = 0x07; //Turn off Comparators
ANSEL = 0x18; //AN3 and AN4 as Analog Input
ADCON1 = 0x10; /* set FOSC/8 as ADC clock source */
ADCON0 = 0x00; /* select channel 0 and turn off ADC */
TRISA3_bit = 1; //Analog VR2 input
TRISA4_bit = 1; // VR1 input
TRISA0_bit = 0; // Led pin as an output
LED = 0;
VR1_Value = ADC_Read(4); // LED OFF Time
VR2_Value = ADC_Read(3); // LED ON Time
LED = 0;
Delay_ms(VR1_Value);
LED = 1;
Delay_ms(VR2_Value);
}
And this is my MikroC configuration Bit Settings: