1.0.0 • Published 4 years ago
@gsantossilva/rasp.io v1.0.0
Rasp.io
Modern Raspberry gpio control using node.js
Table of contents
Getting started
Installation
npm install @gsantossilva/rasp.io
or
yarn add @gsantossilva/rasp.io
Usage
Example
const LED = 13;
await Gpio.open(LED, Gpio.OUTPUT, Gpio.LOW);
await Gpio.write(LED, Gpio.HIGH);
Constants
LOW
- Type:
Number
- Value:
0
HIGH
- Type:
Number
- Value:
1
OUTPUT
- Type:
String
- Value:
out
INPUT
- Type:
String
- Value:
in
PATH_SYS
- Type:
String
- Value:
/sys/class/gpio/
Methods
open()
Open pin using export and define mode.
const LED = 13;
await Gpio.open(LED, Gpio.OUTPUT, Gpio.LOW);
setMode()
Change mode gpio for out or in.
const LED = 13;
await Gpio.setMode(LED, Gpio.INPUT);
await Gpio.setMode(LED, Gpio.OUTPUT);
export()
Export gpio.
const LED = 13;
await Gpio.export(LED);
exported()
Verify if exported gpio.
const LED = 13;
await Gpio.exported(LED);
read()
Read value in gpio.
const LED = 13;
await Gpio.read(LED);
write()
Write value in gpio.
const LED = 13;
await Gpio.write(LED, Gpio.LOW);
await Gpio.write(LED, Gpio.HIGH);
pulse()
Change value in gpio.
const LED = 13;
await Gpio.pulse(LED, 2000);
License
1.0.0
4 years ago