gpio
GPIO stands for General Purpose Input/Output. It's a standard interface used to connect microcontrollers to other electronic devices. With the following methods the GPIO pins on the Raspberry PI can be configured as input or output, read from and written to.
Methods
setPin(pin, mode)
pin
number - The GPIO pin.mode
string - The pin's mode. Supported values are:write
andread
.
Sets the GPIO in read or write mode.
Returns Promise<number>
- Resolves with a number. If the value equals to -1 it means the pin mode could not be set.
write(pin, value)
pin
number - The GPIO pin.value
number - The value to write.
Write 0
or 1
to the GPIO pin.
Returns Promise<number>
- Resolves with a number. If the value equals to -1 it means the pin value could not be set.
read(pin)
pin
number - The GPIO pin.
Read the value from the GPIO pin.
Retuns Promise<number>
- Resolves with the GPIO pin value (either 0
or 1
).