Hello, I was scoping out the digital write function to see how fast it goes. I was using the PWM pin digital pin 6 and here's my code.
int ledPin = 6; // 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
digitalWrite(ledPin, LOW); // sets the LED off
}
Here's a video of my scoping. Arduino pin speed test - testing digital pin 6 - YouTube
I was using "single shot" because my o'scope couldn't get a lock on my signal. It appears that the HIGH and LOW signal lasts for about 5 uS on average but sometimes it takes 17 uS! Anyone know why it takes so long sometimes? This "lengthening" seems to be pretty regular.
While looking for a way to speed this up, I found Arduino Reference - Arduino Reference and it appears I can manipulate the port directly. Anyone know how fast I could get this pin to change if I used assembly or something faster?
I'm using the Arduino Diecimila ran at 16 mhz.