Arduino-ROS, example - blink LED and push button

In this example, we can interface the LED and push button to Arduino and control using ROS. When the push button is pressed, the Arduino node sends a True value to a topic called pushed, and at the same time, it switches on the LED which is on the Arduino board.

The following shows the circuit for doing this example:

Figure 9: Interfacing the push button to Arduino
/* * Button Example for Rosserial */ #include <ros.h> #include <std_msgs/Bool.h> //Nodehandle ros::NodeHandle nh; //Boolean message for Push button std_msgs::Bool pushed_msg; //Defining Publisher in a topic called pushed ros::Publisher ...

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.