TCP/IP - Dual Button Bricklet – Tinkerforge

- Getting Started
  - Primer
  - Tutorials
  - FAQ
- Hardware
  - Bricks
  - Bricklets
  - Master Extensions
  - Power Supplies
  - Accessories
  - Timeline
- Software
  - Brick Daemon (brickd)
  - Brick Viewer (brickv)
  - API Bindings
  - Firmwares and Plugins
  - Device Identifier
  - Source Code and Bug Tracking
  - Programming Interface
- Starter Kits
  - Weather Station
  - Hardware Hacking
  - Server Room Monitoring
  - Blinkenlights
  - Internet of Things
  - Camera Slider
- Embedded Boards
  - Raspberry Pi
- Specifications
  - Technical Data
  - TCP/IP Protocol
    - Protocol
    - API
      - Brick Daemon Functions
      - Broadcast Functions
      - General Callbacks
      - Bricks and Bricklets
        - Bricks
        - Bricklets
          - Ambient Light Bricklet
          - Analog In Bricklet
          - Analog Out Bricklet
          - Barometer Bricklet
          - Color Bricklet
          - Current12 Bricklet
          - Current25 Bricklet
          - Distance IR Bricklet
          - Distance US Bricklet
          - Dual Button Bricklet
            - API
              - Basic Functions
              - Advanced Functions
              - Callbacks
          - Dual Relay Bricklet
          - GPS Bricklet
          - Hall Effect Bricklet
          - Humidity Bricklet
          - Industrial Digital In 4 Bricklet
          - Industrial Digital Out 4 Bricklet
          - Industrial Dual 0-20mA Bricklet
          - Industrial Quad Relay Bricklet
          - IO-16 Bricklet
          - IO-4 Bricklet
          - Joystick Bricklet
          - LCD 16x2 Bricklet
          - LCD 20x4 Bricklet
          - LED Strip Bricklet
          - Line Bricklet
          - Linear Poti Bricklet
          - Moisture Bricklet
          - Motion Detector Bricklet
          - Multi Touch Bricklet
          - NFC/RFID Bricklet
          - Piezo Buzzer Bricklet
          - Piezo Speaker Bricklet
          - PTC Bricklet
          - Remote Switch Bricklet
          - Rotary Encoder Bricklet
          - Rotary Poti Bricklet
          - Segment Display 4x7 Bricklet
          - Solid State Relay Bricklet
          - Sound Intensity Bricklet
          - Temperature Bricklet
          - Temperature IR Bricklet
          - Tilt Bricklet
          - Voltage Bricklet
          - Voltage/Current Bricklet
  - Modbus Protocol
  - Wireshark Dissector

# TCP/IP - Dual Button Bricklet

This is the description of the TCP/IP protocol for the Dual Button Bricklet. General information and technical specifications for the Dual Button Bricklet are summarized in its hardware description.

## API

A general description of the TCP/IP protocol structure can be found here.

### Basic Functions

`BrickletDualButton.``set_led_state`

  Function ID: | 1

  Request:

  - led_l -- uint8
  - led_r -- uint8

  Response: | no response

  Sets the state of the LEDs. Possible states are:

  - 0 = AutoToggleOn: Enables auto toggle with initially enabled LED.
  - 1 = AutoToggleOff: Activates auto toggle with initially disabled LED.
  - 2 = On: Enables LED (auto toggle is disabled).
  - 3 = Off: Disables LED (auto toggle is disabled).

  In auto toggle mode the LED is toggled automatically at each press of a button.

  If you just want to set one of the LEDs and don't know the current state of the other LED, you can get the state with `get_led_state` or you can use `set_selected_led_state`.

  The default value is (1, 1).

`BrickletDualButton.``get_led_state`

  Function ID: | 2
  Request: | empty payload

  Response:

  - led_l -- uint8
  - led_r -- uint8

  Returns the current state of the LEDs, as set by `set_led_state`.

`BrickletDualButton.``get_button_state`

  Function ID: | 3
  Request: | empty payload

  Response:

  - button_l -- uint8
  - button_r -- uint8

  Returns the current state for both buttons. Possible states are:

  - 0 = pressed
  - 1 = released

### Advanced Functions

`BrickletDualButton.``set_selected_led_state`

  Function ID: | 5

  Request:

  - led -- uint8
  - state -- uint8

  Response: | no response

  Sets the state of the selected LED (0 or 1).

  The other LED remains untouched.

`BrickletDualButton.``get_identity`

  Function ID: | 255
  Request: | empty payload

  Response:

  - uid -- char[8]
  - connected_uid -- char[8]
  - position -- char
  - hardware_version -- uint8[3]
  - firmware_version -- uint8[3]
  - device_identifier -- uint16

  Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

  The position can be 'a', 'b', 'c' or 'd'.

  The device identifier numbers can be found here.

### Callbacks

`BrickletDualButton.``CALLBACK_STATE_CHANGED`

  Function ID: | 4

  Response:

  - button_l -- uint8
  - button_r -- uint8
  - led_l -- uint8
  - led_r -- uint8

  This callback is called whenever a button is pressed.

  Possible states for buttons are:

  - 0 = pressed
  - 1 = released

  Possible states for LEDs are:

  - 0 = AutoToggleOn: Auto toggle enabled and LED on.
  - 1 = AutoToggleOff: Auto toggle enabled and LED off.
  - 2 = On: LED on (auto toggle is disabled).
  - 3 = Off: LED off (auto toggle is disabled).

The content of this page is licensed under Creative Commons Attribution 3.0 Unported License.