Function quick reference
Each sensor has a set of functions for controlling it and query it for its state. Some sensors also generate an events when the sensors change. A sensor must be activated before it generates events or relevant values.
- SENSORS_ACTIVATE(sensor) - activate the sensor
- SENSORS_DEACTIVATE(sensor) - deactivate the sensor
- sensor.value(0) - query the sensor for its last value
- sensors_event - event sent when a sensor has changed (the data argument will referer to the actual sensor)
Example for querying the button:
- SENSORS_ACTIVATE(button_sensor) - activate the button sensor
- button_sensor::value(0) - the button has been pressed or not
- battery_sensor - query the battery voltage level
- button_sensor - query the on-board button
- pir_sensor - query the passive IR sensor (motion detector)
- radio_sensor - query the radio signal strength
- sound_sensor - query the microphone
- temperature_sensor - query the temperature sensor
- vib_sensor - query the vibration sensor
- leds_on() - turn LEDs on
- leds_off() - turn LEDs off
- leds_invert() - invert LEDs
- leds_blink() - blink all LEDs
Contiki provides a set of timer libraries. Event timers generates an event when the timer expires and callback timers call a function when the timer expires. The simple timers on the other hand have to be actively queried to check when they have expired.