From the programming examples it looks like the output pins can switch on/off at 1/1000 of a second. Is this true?
I need to get 20 KHZ on/off switching. Is there a way to do that?
From the programming examples it looks like the output pins can switch on/off at 1/1000 of a second. Is this true?
I need to get 20 KHZ on/off switching. Is there a way to do that?
The default PWM output routines have a frequency of about 1KHz. Bypassing those with bare calls to DigitalWrite() should allow you to go much faster, and lower-level C code or timer manipulation should be able to take you a bit beyond that. 20kHz probably isn’t a problem. Tightly crafted assembly language on this class of AVR has been about to output a VIDEO signal on a port pin.
From the programming examples it looks like the output pins can switch on/off at 1/1000 of a second. Is this true?
I need to get 20 KHZ on/off switching. Is there a way to do that?
If you want to do it with pure Arduino, the following code gives you 10.1kHz… not very clean, though.
int ledPin = 13; // LED connected to digital pin 13
void setup() // run once, when the sketch starts
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop() // run over and over again
{
digitalWrite(ledPin, HIGH); // sets the LED on
delayMicroseconds(46); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delayMicroseconds(46); // waits for a second
}