Hola en un Arduino uno , atreves del registro pude hacer variar la frecuencia de 10 Hz a 100 Hz por un potenciómetro. Ahora me gustaría poder hacer variar el ciclo útil atreves de otro potenciómetro desde el 10% hasta el 80%
int Pwmpin=9;
int Fcharge=A0;
void setup() {
pinMode(Pwmpin,OUTPUT);
TCCR1A=_BV(COM1A1)|_BV(COM1B1);
TCCR1B=_BV(WGM13)|_BV(CS11);
}
void loop() {
float freq=0;
float count=10000, countt=0, Pinput=0;
while(1){
ICR1=count;
countt=2*8*count;
freq= int(16000000/countt);
OCR1A=int (count/2); // ciclo util al 50 %
count=10000;
Pinput=analogRead(A0);
Pinput=(Pinput/0.0113);
count=count+Pinput;
if(count >=100000)
{
count=10000;
}
delay(1000);
}
}
Les agradezco su ayuda.
