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, 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 the same for Odroid also.
The code for interfacing 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" ...