The next example is handling input from a button. When we press the button, the code will publish to the led_blink topic and blink the LED. When the switch is off, the LED will also be OFF. The LED is connected to the 12th pin and GND, and the button is connected to the 11th pin and GND. The following image shows the circuit of this example. The circuit is also the same for Odroid:
The code for interfacing the LED and button is given next. The code can be saved with the name button.cpp inside the src folder:
#include "ros/ros.h" #include "std_msgs/Bool.h" ...