WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

switch.h

This module allows you to wrap an IOPin to represent a switch or push button.
The button should be connected between an IOPin and Ground.
Assuming that the switch is connected to B1 then:
SWITCH mySwitch = MAKE_SWITCH(B1); // create the switch
// In appInitHardware...
SWITCH_init(&mySwitch); // Initialise the switch
// In your main loop
The switch can then be read using the pressed/released functions.

 

Function

 


void SWITCH_init(SWITCH *sw)

Initialise a switch.
This is normally called from appInitHardware to make sure the given pin is an input pin and that the internal pullup resistor is enabled.

boolean SWITCH_pressed(SWITCH* sw)

Test if a given switch has been pressed.

boolean SWITCH_released(SWITCH* sw)

Test if a switch is 'released' ie 'not pressed'.

Valid XHTML 1.0 Transitional