Hello, today I will do an interesting project which is LDR Based Automatic Light with PIC16F690. This is a simple project using LDR and PIC16F90. This PIC16F690 is a very popular microcontroller. PIC16f690 micro controller has 3 port. These are PORT A, PORTB, and PORTC. Each port has some specific purpose.
The purpose of this project is to make an automatic light with the help of LDR and microcontroller. If there is sunlight or light from other sources then systems light will be turned off and if there is no sunlight or other source of light then systems light will be turned on. For sensor will will use LDR.
LDR is basically a photoresistor or light dependent resistor. This is a light controlled variable resistor. The resistance of a LDR decreases with increasing incident light intensity and the resistance of a LDR increases with increasing incident of light intensity.
To do this we need following software:
The purpose of this project is to make an automatic light with the help of LDR and microcontroller. If there is sunlight or light from other sources then systems light will be turned off and if there is no sunlight or other source of light then systems light will be turned on. For sensor will will use LDR.
LDR is basically a photoresistor or light dependent resistor. This is a light controlled variable resistor. The resistance of a LDR decreases with increasing incident light intensity and the resistance of a LDR increases with increasing incident of light intensity.
Figure 1: Light Dependent Resistor
To do this we need following software:
1. MikroC pro for PIC (student verison)
2. Proteus 8 professional
3. PicKit 2
CODE
MikroC pro for PIC will be used for writing and compiling the code. Here we will use C language.
Proteus 8 professional will be used for the simulation and finally Pickit 2 will be used for burning the hex file in the PIC16F690 IC.
To do this project we need following components;
1. PIC16F690
2. LED
3. 16 MHz Crystal Oscillator
4. Breadboard
5. Wires
6. 5V DC Power source
7. 5V Relay Module
8. LDR
7. 5V Relay Module
8. LDR
void main()
{
unsigned int input = 0;
TRISC = 0; // output register
PORTC = 0; // output port
ADCON1 =0x0E; // Analog to digital converter turning on
while(1)
{
input = ADC_read(0); // Reading the ADC value from PORT A0
if(input<=500) // 500 is corresponding value of LDR
{
PORTC = 0b01111111; // Turning on LED on PORTC
delay_ms(1000); // Turning on LED for 1 seconds
}
else
{
PORTC = 0b00000000; // Turning off LED
}
}
}
SCHEMATIC
Figure 2: Schematic
Figure 3: Schematic
No comments:
Post a Comment