Home › Forums › Microcontrollers › PIC Microcontroller › Using PWM and ADC at the same time › Reply To: Using PWM and ADC at the same time
September 19, 2015 at 7:08 pm
#11770
Keymaster
Dear Mustunsultan,
There is no meaning in combining some codes without any logic.
Try like this.
unsigned int ADC;
void main()
{
short duty1 = 16;
CMCON = 0x07;
ADCON1 = 0x80;
TRISA = 0xFF; //input analog signal
//PWM Function
PWM1_Init(5000);
PWM1_Start();
//ADC Function
do
{
ADC = ADC_Read(1);
PWM1_set_duty(ADC/4);
delay_ms(400);
}while(1);
}
