Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.
Overview
The ATmega8 Dusk-to-Dawn Switch is a fully automated lighting control system designed to turn lights ON at night and OFF during the day. This project is perfect for streetlights, garden lights, or home security systems, helping to save energy and automate your environment without manual intervention.
How It Works
The system uses a Light Dependent Resistor (LDR) connected to an analog voltage divider. The ATmega8 microcontroller reads the analog voltage using its internal ADC (Analog-to-Digital Converter).
· In daylight, the LDR resistance is low, resulting in a low ADC value.
· In darkness, the LDR resistance increases, raising the ADC value.
When the ADC value crosses a predefined threshold (e.g., a value of 300), the microcontroller activates a 5V relay via a transistor (BC547) to turn on the light.
Key Features & Engineering Highlights
· Software Hysteresis: To prevent the light from flickering when ambient light is exactly at the threshold, we implemented software hysteresis. The light turns ON when the ADC drops below 300, but only turns OFF when the ADC rises above 500.
· Delay Mechanism: A software delay (counting consecutive readings) prevents the system from reacting to transient light changes, such as car headlights passing by.
· Adjustable Thresholds: The light sensitivity thresholds can be easily modified in the C code.
Hardware Components
· ATmega8 Microcontroller
· LDR (Light Dependent Resistor)
· 5V Relay (SPDT)
· BC547 Transistor (for relay driving)
· 1N4007 Diode (flyback protection)
· Resistors: 10kΩ, 1kΩ
· 5V Power Supply
Software & Compilation
The project is written in Embedded C using AVR-GCC. It uses the internal 8MHz oscillator of the ATmega8. The code includes ADC initialization, polling logic, and GPIO control for the relay. You can compile the code using Atmel Studio, AVR-GCC, or the Arduino IDE (as an AVR board).
Getting Started & Resources
For full schematics, source code, and a step-by-step tutorial, please visit our GitHub repository:
A detailed simulation video demonstrating the circuit in Proteus is also available in the repository.