k3ng_rotator_controller/libraries/digitalWriteFast/Examples/ToggleFast/ToggleFast.ino
Anthony Good 56e6ed8233 2021.10.14.01
FEATURE_STEPPER_MOTOR
          Removed OPTION_STEPPER_MOTOR_MAX_50_KHZ.  Too much overhead from interrupts.
          Implemented faster digital writes using digitalWriteFast library (library now included in Github)
          Added OPTION_STEPPER_DO_NOT_USE_DIGITALWRITEFAST_LIBRARY to disable digitalWriteFast library use
2021-10-13 20:58:48 -04:00

45 lines
1.6 KiB
C++
Executable File

#include <digitalWriteFast.h>
#define pinNum 9
//int pinNum = 9; //do not use variables, macro will revert to the slower digitalWrite()
//const int pinNum = 9; //this is a constant, will use port manipulation (fast)
void setup() {
pinModeFast(pinNum, OUTPUT);
}
void loop() {
//the pin is toggled multiple time before looping is because it took too long that the pin stayed low for 600ns, while clearing or setting the pin only took 125ns. For 16MHz Arduino Uno.
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
}