Trouble with ADC Interrupts and PWM output.
hi first post please gentle . have been playing adc , pwm outputs. attached schematic of setup. have voltage divider light dependent resistor r1 , center node attached pin pc1 , center post of potentiometer connected pin pc0. varying resistance of ldr led being driven pwm pin pd6. my goal have voltage of voltage divider match voltage coming out of pot. if turn pot duty cycle of pwm driving led increased making led brighter , bringing voltage voltage divider go match output pot. here code using. code: [select] volatile int pot; volatile int ldr; uint8_t channel; int adcvalue[2]; int error; int pwmvalue = 0; void setup() { cli(); admux |= (1<<refs0); //set adc ref. avcc adcsra |= (1<<adps0) | (1<<adps1) | (1<<adps2);...