Monitoring light using Arduino and ROS

We can start coding a basic Arduino-ROS node that can sense the amount of light using a light-dependent resistor (LDR). You can use any Arduino for this demo; here, we are going to use the Arduino Mega 2560. Given in the following figure is the circuit of an LDR with the Arduino. The characteristic of an LDR is that it is basically a resistor in which the resistance across it changes when light falls on it. The maximum resistance is when there is no light and minimum when light falls on it.

Figure 9: Arduino-LDR interfacing circuit

We have to connect one pin to 5V from the Arduino board and the next terminal ...

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.