Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano-Controlled LED Lighting with RTC Scheduling

View and Edit Project In Cirkit DesignerImage of Arduino Nano-Controlled LED Lighting with RTC Scheduling

Circuit Documentation

Summary

This circuit is designed around an Arduino Nano microcontroller and includes a real-time clock (RTC-DS1302), a set of LED filaments, NPN transistors, and resistors. The Arduino Nano is programmed to control the state of an output pin based on the time provided by the RTC. The output pin drives an NPN transistor that switches a series of LEDs on or off depending on the time of day. The circuit is powered by a 5V DC source.

Component List

Arduino Nano

LED Filament 3V

Resistor (10 Ohms)

Resistor (2000 Ohms)

NPN Transistor (CBE)

RTC-DS1302

DC Source 5V

Wiring Details

Arduino Nano

LED Filament 3V

Resistor (10 Ohms)

Resistor (2000 Ohms)

NPN Transistor (CBE)

RTC-DS1302

DC Source 5V

Documented Code

#include <virtualbotixRTC.h>
virtualbotixRTC myRTC(3, 4, 5)

void setup() {
  Serial.begin(57600);
  pinMode(2, OUTPUT);
  // sec, min, hour, day of the week, day of the month, moth, year
  myRTC.setDS1302Time(00, 00, 21, 2, 22, 10, 2024);
}

void loop() {
  myRTC.updateTime();
  // Turn on the LEDs between 8 AM and 11 PM
  if(myRTC.hours >= 8 && myRTC.hours <= 23){
    digitalWrite(2, HIGH);            
  }else{
    digitalWrite(2, LOW);   
  }
  delay(60000); // Wait for 60 seconds before updating the time again
}

The code is written for the Arduino Nano and utilizes the virtualbotixRTC library to interface with the RTC-DS1302 module. The setup() function initializes the serial communication and sets the initial time on the RTC. The loop() function checks the current time and controls the output pin connected to the NPN transistor, which in turn controls the LED filaments based on the time of day.