Ali_Ahmer
Newbie level 3
Hello Respected All Members,
I am New in this Forum and PIC Programming. I need a little help.
I am using PIC16F676 MCU with Internal Oscillator clock and internal MCLR Voltage in MikroC Compiler. I want to read two analog inputs of 5K potentiometer connected at RA4 and RA3 to calculate the LED on/off Delay. I have connected a LED on RA0 (Pin 13) of PIC16f676 MCU. I want to limit its time from 1 second to 10 seconds with respect to 5k Potentiometer.
I have pasted my code below, But it gives me some error. I don't know where i was doing wrong:
This is my Proteus Simulation Design:
And Below is my MikroC compiler Configuration Bit Settings:
I am New in this Forum and PIC Programming. I need a little help.
I am using PIC16F676 MCU with Internal Oscillator clock and internal MCLR Voltage in MikroC Compiler. I want to read two analog inputs of 5K potentiometer connected at RA4 and RA3 to calculate the LED on/off Delay. I have connected a LED on RA0 (Pin 13) of PIC16f676 MCU. I want to limit its time from 1 second to 10 seconds with respect to 5k Potentiometer.
I have pasted my code below, But it gives me some error. I don't know where i was doing wrong:
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);
}
This is my Proteus Simulation Design:
And Below is my MikroC compiler Configuration Bit Settings: