Go Down

Topic: Faster Than A Blink (Read 1 time) previous topic - next topic


Hello, I'm very new to this technology so please forgive me for what might be an inappropriate question. I'm trying to take a step up from using a 555 timer. I require some rather fast switching speeds. Perhaps a high on time of 50 us. I've tried changing the parameters in the Blinking Diode Sketch but it seems as though I can only do about 1ms high. Is it possible to get a higher frequency with the Arduino Atmega 328? Any help or direction would be appreciated.
DadHav/John H


You can use a function called delayMicroseconds().

If switching the pins with digitalWrite() takes too long for what you need, look at direct port manipulation in the playground.



There is a comprehensive discussion of "Maximum pin toggle speed" over at http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230286016


Thank you Gentlemen. I'll look into both of the suggestions. I'm just discovering how many places there are for help. So much th learn and so little time.


Hello, Just as an added note: I was also directed to a tutorial on timer 1. The following code worked well with my Deumilanova. I was able to get an on time of about 1 us and off of about 10 us. I think I'll be able to find what I need to operate with from this. I didn't want to post this on the other forum link because they all probably know about it already and I didn't want to interrupt with my amateur remarks.

*  Timer1 library example
*  June 2008 | jesse dot tane at gmail dot com

#include "TimerOne.h"

void setup()
 pinMode(10, OUTPUT);
 Timer1.initialize(10);         // initialize timer1, and set a 1000000= 1 second period
 Timer1.pwm(9, 100);                // setup pwm on pin 9, 512=50% duty cycle
 Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt

void callback()
 digitalWrite(10, digitalRead(10) ^ 1);

void loop()
 // your program here...

Merry Christmas Everyone!

Go Up