I have a simple code and I would like to know how I could adjust the frequency using a potentiometer
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delayMicro(1); // waits for a second
}
Ok let me get this straight, by delay do you mean when the pot is turned to adjust the frequency it will be delayed before its adjusted by 100 microseconds?
ok for example having both delays at 100 microseconds will give 1khz and reducing both delays with a pot to 90 microseconds would reduce the frequency to 990khz but because of the analogRead feature it would take 100 microseconds to reduce to 990khz. thats my understanding of what you said.
if thats the case then I have no problem with that.
the frequency output of this code is 1 kilohertz I would like to modify this code so that I can use a Potentiometer to adjust the frequency from 0hertz to 1 kilohertz.
hopefully those words are good enough to understand.