Skip to main content

ReflectedLight

caution

This service is rc and may change in the future.

A sensor that detects light and dark surfaces, commonly used for line following robots.

import { ReflectedLight } from "@devicescript/core"

const reflectedLight = new ReflectedLight()

Registers

reading

Reports the reflected brightness. It may be a digital value or, for some sensor, analog value.

  • type: Register<number> (packing format u0.16)

  • read only

import { ReflectedLight } from "@devicescript/core"

const reflectedLight = new ReflectedLight()
// ...
const value = await reflectedLight.reading.read()
  • track incoming values
import { ReflectedLight } from "@devicescript/core"

const reflectedLight = new ReflectedLight()
// ...
reflectedLight.reading.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

variant

Type of physical sensor used

  • type: Register<number> (packing format u8)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { ReflectedLight } from "@devicescript/core"

const reflectedLight = new ReflectedLight()
// ...
const value = await reflectedLight.variant.read()
note

write and read will block until a server is bound to the client.