digitalToggle()
Toggle between HIGH and LOW a digital pin.
If the pin has been configured as an OUTPUT with pinMode, its voltage will be set 3.3V for HIGH, GROUND for LOW.
Check Z-Uno pinout
digitalToggle(pin)
pin
the pin number
none
Automatically changes pin mode to OUTPUT as pinMode(pin, OUTPUT) was called.
void setup() {
pinMode(8, OUTPUT); // sets the digital pin as output
}
void loop() {
digitalWrite(8, HIGH); // sets the LED on
delayMicros(4000); // waits for four seconds
digitalToggle(8); // sets the LED off
delay(4000); // waits for four seconds
}
Z-Uno pin control is pretty slow, typical digitalRead() call will take itself about 1 ms.
Fast operations are allowed in special special "fast mode". To use this fast mode one need to specify pin number via s_pin variable type. Z-Uno compiler will detect it and use fast mode for such digitalRead() calls. In this case the call will take about 1–2 μs for indirect call (via function) and 0.5 μs for direct (see example below).
By default pins 9-16 are fast. You can change this using ZUNO_REMAP_SPINS()
s_pin my_pin = 9;
void setup() {
pinMode(my_pin, OUTPUT);
}
void blinkWithPin(s_pin pin) {
pinMode(pin, OUTPUT);
digitalWrite(pin, 0);
delayMicroseconds(100);
digitalToggle(pin);
delayMicroseconds(100);
digitalToggle(pin);
}
void loop() {
byte another_pin;
digitalToggle(my_pin, 0); // direct call is possible
another_pin = 10;
blinkWithPin(another_pin); // or call via function
}