devicescript
devicescript copied to clipboard
something like this?
Here's start of a very simple sample with input (sensor) and output (traffic light).
console.log("starting...")
const temp = new ds.Temperature()
const light = new ds.TrafficLight()
temp.temperature.subscribe(async t => {
console.log(t)
await light.green.write(false)
await light.yellow.write(false)
await light.red.write(false)
if (t > 30) {
await light.red.write(true)
} else if (t > 20) {
await light.yellow.write(true)
} else {
await light.green.write(true)
}
})

not sure what the ask is.
added sample https://github.com/microsoft/devicescript/commit/2544de05e56455a0f7abd3252adb1a994a6d1920