user-img

Davar Bakhshi

  • 1 Projects
  • 0 Followers
  • Oct 16,2026
+ Follow

ATmega8 Dusk-to-Dawn Switch

An ATmega8-based dusk-to-dawn switch that automates lighting using an LDR sensor, featuring software hysteresis to prevent flickering and adjustable light thresholds.

ATmega8 Dusk-to-Dawn Switch
 
  • thumbnail-img
  • thumbnail-img
  • thumbnail-img
 

Hardware Components

  • ATmeha8

    X 1
  • 5v Relay spdt | Qunantity

    X 1
  • LDR

    X 1

Story

 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 

Davar Bakhshi

 

۰:۲۳ ‎(۸ ساعت پیش)‎
 
 
 
 
 
به من
 
 
 
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.
 
 
Code
  • https://github.com/davarb53-ops/dusk-to-dawn-switch
    View
Schematic and Layout

ATmega8 Dusk-to-Dawn Switch

An ATmega8-based dusk-to-dawn switch that automates lighting using an LDR sensor, featuring software hysteresis to prevent flickering and adjustable light thresholds.

5
 
0
0
0

Share your project on social media to expand its influence! Get more people to support it.

  • Comments( 0 )
  • Like( 0 )
/1000
Upload a photo:
You can only upload 1 files in total. Each file cannot exceed 2MB. Supports JPG, JPEG, GIF, PNG, BMP

You May Also Like

View All
Add to cart
Board Type : GerberFile :
Layer : Dimensions :
PCB Qty :
Different PCB Design
PCB Thickness : PCB Color :
Surface Finish : Castellated Hole :
Copper Weight : 1 oz Production Time :
Total: US $
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.

PCB Assembly

PCBA Qty: BomFile:
NO. OF UNIQUE PARTS: NO. of Components:
Country: Shipping Way:
Assembly Cost: US $
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
3dPrintingFile : Size :
Unit : Volumn :
3D Printing Qty : Material :
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
Acrylic Type : AcrylicFile :
Dimensions: Engrave:
Acrylic Qty :
Acrylic Thickness:
Acrylic Color:
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
CNC Milling File : Size:
Unit: Volumn:
CNC Milling Qty : Material:
Type of Aluminum: Surface Finish:
Tolerance:
Surface Roughness:
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
Item Price Qty Subtotal Delete
Total: US $0.00
Certified Product | Guaranteed Purchase: Full techsupport