User manual

Example Projects
© 2006 Microchip Technology Inc. DS51557C-page 23
2.3.2 Project 2: Dusk Indicator Using the Voltage Comparator
If you have yard lights or a porch light at home that automatically turns on at dusk then
you are familiar with the application we will create in this project. The comparator on
the PIC16F917 will be used to compare the voltage level from the potentiometer to the
voltage level out from the light sensor. When the intensity of the light to the sensor is
reduced below the trip point set by the potentiometer, the LED will turn on.
Objectives
1. Use the internal analog comparator module.
2. Implement software hysteresis to stabilize the comparator output.
Applicable Technical Documents
PICmicro
®
Comparator Tips ‘n Tricks (DS41215)
Jumper Configuration
C1- (J13) to LIGHT (J4)
C1+ (J13) to POT1 (J4)
RD7 (J10) to D0 (J14)
FIGURE 2-4: PROJECT 2: JUMPER DIAGRAM