O'Reilly logo

Getting Started with the Internet of Things by Cuno Pfister

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

VoltageReader

Reading digital inputs for buttons, switches, and the like is fine, but sometimes you may want to read analog inputs as well. The VoltageReader in Figure 3-4 shows how this can be done.

Architecture of VoltageReader

Figure 3-4. Architecture of VoltageReader

The complete code is given in Example 3-2. It polls a potentiometer every three seconds and prints the raw value and the corresponding voltage value to the debug output.

Note

If you develop on Mac OS X or Linux, the debug output can be sent over a serial line instead of USB. For more information, please see the Mono forum at http://forums.netduino.com/.

Example 3-2. VoltageReader

using System.Threading; using Microsoft.SPOT; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required