npm install --save https://github.com/raspberry-pi-home/pi-home-gpio.git
import { isAccessible } from 'pi-home-gpio'
console.log(isAccessible)
import { Led } from 'pi-home-gpio'
const led = new Led(17)
led.on()
setTimeout(() => led.off(), 1000)
import { PushButton, Led } from 'pi-home-gpio'
const led = new Led(17)
const button = new PushButton(4)
button.onAction(led.value)
import { ToggleButton, Led } from 'pi-home-gpio'
const led = new Led(17)
const button = new ToggleButton(4)
button.onAction(led.toggle)
Creates a new Led component which will act as a digital output
Turns on the Led
Turns off the Led
Toggle the status of the Led
Set the given value to the Led, if value is not provided it will return the current status
If provided, value must be either 1 or 0
Creates a new Button component which will act as a digital input
When the button is pressed onAction function is called
Creates a new Button component which will act as a digital input
When the button is pressed onAction function is called with a 1, and when the button is released onAction function is called with a 0
Returns the current status (1 or 0)
- 2
- 3
- 4
- 5
- 7
- 6
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27