Reference+
Name
digitalWrite()
Class
GPIO
Description
Sets an output pin to be either high or low
You need to set the pin to output by calling pinMode()
before calling this function. Unlike on Arduino, it is not possible to set a input pin's
internal pull-up resistor using this function.
Examples
import processing.io.*; boolean ledOn = false; void setup() { GPIO.pinMode(4, GPIO.OUTPUT); // On the Raspberry Pi, GPIO 4 is pin 7 on the pin header, // located on the fourth row, above one of the ground pins frameRate(0.5); } void draw() { ledOn = !ledOn; if (ledOn) { GPIO.digitalWrite(4, GPIO.LOW); fill(204); } else { GPIO.digitalWrite(4, GPIO.HIGH); fill(255); } stroke(255); ellipse(width/2, height/2, width*0.75, height*0.75); }
Syntax
.digitalWrite(pin, value)
Parameters
pin
(int)
GPIO pinvalue
(int, boolean)
GPIO.HIGH (1) or GPIO.LOW (0)value
(boolean, int)
true or false
Return
void
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.