(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Adding a button

Description: This tutorial shows how to add a push button

Tutorial Level: BEGINNER

Introduction

This tutorial shows how to use a digital input on the ArbotiX. In particular, we will add a button to our ArbotiX and have the value of the button streamed as a ROS topic.

Wiring

TODO

Configuration

Our button is attached as digital 0, so we want to add the following line to our YAML file:

digital_sensors: {
    my_button: {pin: 0, value: 1, rate: 10}
}

This will will create a single digital input connection which streams the value of pin 0 at approximately 10hz to a topic called "my_button". The value is the default value to set the port at if it were an output, when using digital inputs, a value has a slightly different meaning. A value of 1 enables the pull-up resistor on a digital port, 0 disables it.

By enabling the pull-up resistor, the digital input will be at a default value of 5V. When we press the switch, it connects the input to ground, or 0V.

Examining the Output

We can examine the output topic using:

rostopic echo /arbotix/my_button

When the button is not pressed, the value of the message is 255, when pressed, it drops to 0.

Wiki: arbotix_python/Tutorials/Adding a Button (last edited 2011-03-22 15:49:08 by MichaelFerguson)