pinMode(pin, [INPUT | OUTPUT | INPUT_PULLUP | INPUT_DOWN])
digitalWrite(pin, [HIGH | LOW])
digitalRead(pin)
Example:
function setup() {
pinMode(D0, OUTPUT);
pinMode(D34, INPUT);
}
function loop() {
let value = digitalRead(D34);
digitalWrite(D0, value);
}
Similar to Arduino, these commands configure, write and read a digital GPIO pin.
The possible values for pin
are:
Pin | Alias | Direction | Description |
---|---|---|---|
0 | D0 | In/Out | Built-in LED / GPIO0 |
16 | D16 | In/Out | UART1 Rx / GPIO16 |
17 | D17 | In/Out | UART1 Tx / GPIO17 |
18 | D18 | In/Out | SPI SCK / GPIO18 |
19 | D19 | In/Out | SPI MISO / GPIO19 |
23 | D23 | In/Out | SPI MOSI / GPIO23 |
25 | D25 | In/Out | DAC1 / ADC2_CH8 / GPIO25 |
26 | D26 | In/Out | DAC2 / GPIO26 |
27 | D27 | In/Out | I2C SDA / GPIO27 |
32 | D32 | In/Out | I2C SCL / GPIO32 |
33 | D33 | In/Out | ADC1_CH5 / GPIO33 |
34 | D34 | In | External Interrupt |
36 | D36 | In | ADC1_CH0 / GPIO36 |