Blinking LED using ROS on Raspberry Pi 2

This is a basic LED example which can blink the LED connected to the first pin of Wiring Pi, that is the 12th pin on the board. The LED cathode is connected to the GND pin and 12th pin as an anode. The following image shows the circuit of Raspberry Pi with an LED:

Figure 25: Blinking an LED using Raspberry Pi 2

We can create the example ROS package, using the following command:

    $ catkin_create_pkg ros_wiring_example roscpp std_msgs

You will get the existing package from the ros_wiring_examples folder.

Create a src folder and create the following code called blink.cpp inside the src folder:

#include ...

Get Mastering ROS for Robotics Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.