Button
The startButton function starts a button server on the device
and returns a client.
import { gpio } from "@devicescript/core"
import { startButton } from "@devicescript/servers"
const buttonA = startButton({
pin: gpio(2),
})
The service instance name is automatically set to the variable name. In this example, it is set to buttonA.
Options
pin
The pin hardware identifier on which to mount the button.
pinBacklight
This pin is set high when the button is pressed. Useful for buttons with a builtin LED.
import { gpio } from "@devicescript/core"
import { startButton } from "@devicescript/servers"
const buttonA = startButton({
pin: gpio(2),
pinBacklight: gpio(4),
})
activeHigh
Button is normally active-low and pulled high. This makes it active-high and pulled low.
import { gpio } from "@devicescript/core"
import { startButton } from "@devicescript/servers"
const buttonA = startButton({
pin: gpio(2),
activeHigh: true,
})