digitalWrite()
Write a HIGH, or a LOW, value to 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.
If the pin is configured as an INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal pullup on the input pin. It is recommended to set the pinMode() to INPUT_PULLUP to enable the internal pull-up resistor.
Check Z-Uno pinout
digitalWrite(pin, value)
pin
the pin number
value
HIGH or LOW
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
digitalWrite(8, LOW); // 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);
digitalWrite(pin, 1);
delayMicroseconds(100);
digitalWrite(pin, 0);
}
void loop() {
byte another_pin;
digitalWrite(my_pin, 0); // direct call is possible
another_pin = 10;
blinkWithPin(another_pin); // or call via function
}