- Discrete LEDs
- Dot/Bar LEDs
- Matrix LEDs
- 7-Seg LEDs
- LCDs
- Switches
- KBDs
- Sensors
- Motors
- Analog
-
Comm
- Serial -- Software
- Serial -- Hardware
- RS-232 via the MAX3232
- I2C -- EEPROM
- I2C -- DS1307 Real Time Clock
- 1-Wire -- DS18B20, Powered, Single-Drop
- 1-Wire -- DS18B20, Powered, Multi-Drop
- 1-Wire -- DS18B20, Parasitic, Multi-Drop
- TI Link Protocol -- Calculator Demo
- Infrared Communication
- MIDI -- Output Demo
- MIDI -- Input Demo
- MIDI to Analog Synth
- Miscellaneous
Reading Potentiometers
In this section we now turn our attention to sensors. We'll start off with potentiometers. I suppose it seems funny to consider a pot as a sensor, but it really is. The wiper senses a voltage which will then be passed along to the PIC. Of course, that's analog in nature, but most PICs include analog-to-digital (ADC) circuitry which does a great job of converting the voltage into a binary number.
The PIC Micro Pascal compiler contains a library unit devoted to this function. Despite some of the terminology demanded by the various commands and their parameters, it's very easy to use.
Here's the circuit we'll use for testing:
You'll note that there are two pots in this demo. The commands in the PMP library unit can be used in either 8-bit or 10-bit modes, yielding numbers from 0 to 255 or 1023, respectively. The LCD shows both so you can see what's going on.
Click to get the source code.
Click to get the schematic PDF.
Next Project: Light Sensor
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment