Creating an example program to use Arduino

Now, we are going to upload an example program from the IDE to Arduino. Select the Hello World sample and upload the sketch:

Arduino IDE with roslib examples

The code in the preceding screenshot is very similar to the following code. In the following code, you can see an include line with the ros.h library. This library is the rosserial library, which we have installed before. Also, you can see a library with the message to send with a topic; in this case, it is the std_msgs/String type.

The following code snippet is present in the c8_arduino_string.ino file:

#include <ros.h> #include <std_msgs/String.h> ...

Get ROS Programming: Building Powerful Robots 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.