PWM+ Adc

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

PWM+ ADC

void main() {

setup_adc_ports(AN0); setup_adc(ADC_CLOCK_DIV_2); int8 tOFF, tON; while(1){ set_adc_channel(0); tOFF = read_adc(); tON = 255 - tOFF; delay_us(tOFF); output_low(PIN_C0); delay_us(tON); output_high(PIN_C0); } }

You might also like