Arduino-ROS, example - Accelerometer ADXL 335

In this example, we are interfacing Accelerometer ADXL 335 to Arduino Mega through ADC pins and plotting the values using the ROS tool called rqt_plot.

The following image shows the circuit of the connection between ADLX 335 and Arduino::

Figure 12 : Interfacing Arduino - ADXL 335

The ADLX 335 is an analog accelerometer. We can simply connect to the ADC port and read the digital value. Following is the embedded code to interface ADLX 335 via Arduino ADC:

#if (ARDUINO >= 100) #include <Arduino.h> #else #include <WProgram.h> #endif #include <ros.h> #include <rosserial_arduino/Adc.h> const ...

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.