EveryCircuit
Contact
Reviews
Home
gah000
modified 2 years ago

LED on off

1
0
474
06:00:59
This logic can be used to time a little LED chain when there is only an on/off switch for the 3 AA batteries. The NPN transistor used is BC550 The 4.5V switch turns the unit on and off. The switch before the 15k simulates logic level signal from ATTiny85 (or other) output pin. R values may need to change to match the actual LED configuration. A sample Arduino sketch: // LEDtimer.ino // gah Dec. 02, 2023 // This is supposed to go into an ATTINY85 to make it an on off timer for LEDs // Remove all console communication first unsigned long t_now = 0L; // initial value unsigned long t_8h = 0L; unsigned long t_16h = 0L; // We could also have a second on_time in the morning if desired. int ledPIN = 13; void setup() { delay (3000); // security delay Serial.begin (9600); pinMode(ledPIN, OUTPUT); t_8h = 1000L * 60 * 60 * 8; // initial 8h numerical representation in msec t_16h = 1000L * 60 * 60 * 16; // initial 18h numerical representation in msec } void loop () { digitalWrite(ledPIN, HIGH); // turn power to the LEDs ON Serial.println ("LEDs are powered ON now\n"); Serial.print ("Elapsed time since start = "); Serial.println (t_now); Serial.print ("\tt_8h = "); Serial.print (t_8h); Serial.print ("\tt_16h = "); Serial.print (t_16h); while (t_now < t_8h) { t_now = millis(); } digitalWrite(ledPIN, LOW); // turn power to the LEDs OFF Serial.println ("LEDs are powered OFF now\n"); Serial.print ("Elapsed time since start = "); Serial.println (t_now); Serial.print ("\tt_8h = "); Serial.print (t_8h); Serial.print ("\tt_16h = "); Serial.print (t_16h); while (t_now < t_16h) { t_now = millis(); } // This concludes 1 full day (24 hrs) // incerementing t_8h and t_16h values now t_8h = t_8h + 1000L * 60 * 60 * 24; t_16h = t_16h + 1000L * 60 * 60 * 24; // then loop untill battery is empty or power switch is pressed // if overflow occurs during that time you have an excellent battery. }
published 2 years ago

EveryCircuit is an easy to use, highly interactive circuit simulator and schematic capture tool. Real-time circuit simulation, interactivity, and dynamic visualization make it a must have application for professionals and academia. EveryCircuit user community has collaboratively created the largest searchable library of circuit designs. EveryCircuit app runs online in popular browsers and on mobile phones and tablets, enabling you to capture design ideas and learn electronics on the go.

Copyright © 2026 by MuseMaze, Inc.     Terms of use     Privacy policy