- 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
Light Sensor
In this exercise we'll see how to detect light with a cadmium sulphide photo resistor. These devices are available from many sources and very inexpensive. As the name suggests, they are resistors whose resistance changes when struck by light. You'll have to look carefully to find it in the photo, on the left side. It's a spindly little affair on long leads. By the way, the pot you see here is for setting the intensity of the LCD.
Our plan of attack is simple. We'll wire the sensor in series with a resistor from +5V to ground. This creates a voltage divider, and the voltage developed at the tie point is detected by the ADC within the PIC. Thus, the operation (and code) is virtually identical to what we saw in the potentiometer demo of the previous exercise.
Do I need to remind you that you can click on the schematics here to view and expand them in your browser window? Or that you can click the links, below, to fetch a high quality PDF for your notebook (along with the source code)?
As usual, take some time to look over the program, especially the PMP library unit which handles the analog-to-digital conversion. By this time, you should be coming to the conclusion that PMP is extremely powerful and can readily handle just about any situation.
Click to get the source code.
Click to get the schematic PDF.
Next Project: Homemade Pressure Sensor
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment