Show:
Extends webduino.Module

The Photocell class.

Photocell is small, inexpensive, low-power sensor that allow you to detect light.

Constructor

webduino.module.Photocell
(
  • board
  • analogPinNumber
)

Parameters:

  • board webduino.Board

    Board that the photocell is attached to.

  • analogPinNumber Integer

    The pin that the photocell is connected to.

Methods

addListener
(
  • type
  • listener
)

Add a listener for a certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

emit
(
  • type
  • object,...
)

Emit an event of certain type.

Parameters:

  • type String

    Event type.

  • [object,...] Object optional

    Event object(s).

listeners
(
  • type
)

Return the listener list bound to certain type of event.

Parameters:

  • type String

    Evnet type.

measure
(
  • callback
)

Start detection.

Parameters:

  • [callback] Function optional

    Callback after starting detection.

off ()

Stop detection.

on
(
  • callback
)
deprecated

Inherited from webduino.EventEmitter but overwritten in src/module/Photocell.js:80

Deprecated: `on()` is deprecated, use `measure()` instead.

Start detection.

Parameters:

  • [callback] Function optional

    Callback after starting detection.

once
(
  • type
  • listener
)

Add a one-time listener for a certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

removeAllListeners
(
  • type
)

Remove all listeners of certain type.

Parameters:

  • type String

    Event type.

removeListener
(
  • type
  • listener
)

Remove a listener for certain type of event.

Parameters:

  • type String

    Event type.

  • listener Function

    Event listener.

setMaxListeners
(
  • n
)

Set maximum number of listeners that is allow to bind on an emitter.

Parameters:

  • n Number

    Number of listeners.

Attributes

state

String on or off

The state indicating whether the module is measuring.

type

String readonly

Type of the module.

Events

PhotocellEvent.MESSAGE

Fires when the value of brightness has changed.