Hardware Reference
In-Depth Information
Discussion
The LV-MaxSonar-EZ1 outputs distance measured in several ways: RS232 serial, a PWM
signal, and an analog voltage. The easiest one to use is the analog-in, because the Bone has
several analog-in ports.
TIP
If you take the analog voltage*1.8/0.0064, you'll get the distance in inches.
The setInterval(readRange, ms); statement in Example 2-6 causes the
readRange() function to be called every 250 ms. The readRange() function reads
the analog port and calls printStatus() once the value is ready. printStatus()
then prints the value read.
NOTE
The built-in ADC on the Bone is a 12-bit, 200 k samples-per-second successive approximation
converter with eight channels. Seven of the channels are available on the Bone's analog-in
pins.
Search WWH ::




Custom Search