PreviousNext
buttonPressed
Help > Macros > Control > buttonPressed

Macro

 

Read the level at the pin dedicated to being checked

Purpose

 

Simple pin level checking (e.g. whether the pushbutton connected to this pin is pressed)

Syntax

 

bit buttonPressed

Parameters

 

 –

Return value

 

     true If log.0 is detected on the pin

     false      If log.1 is detected on the pin

Output values

 

 

Preconditions

 

The dedicated pin must be configured as an input. It is arranged in OS by default. OS itself never switches this pin to output.

Remarks

 

     The dedicated pin is C5 (for TR modules for SIM mounting, e.g. TR-72G) or Q12 (for SMT mounting, e.g.TR-76G).

     It is connected to MCU pin RB4. Interrupt on change and wake-up from sleep can be utilized on this pin.

     IQRF development tools (e.g. CK-USB-04A and DK-EVAL-04A) with a TR module for SIM mounting, e.g. TR-72G (but not with a TR module for SMT mounting, e.g. TR-76G) use this pin to connect the User pushbutton (SW1), active low.

Side effects

 

 –

See also

 

 –

Example 1

 

if (buttonPressed)        //   If button is pressed

{

   pulseLEDR();           //      LED indication

      ...

}

Example 2

 

TRISB.4 = 1;               // Configure the pin as input. Required only if                                 // previously changed by the user.

                           // See IQRF User’s guide, chapter MCU pins.

if (buttonPressed)        //   If button is pressed

      ...