Simplifying circuit

Hi guys,

I have make a switch that turns on some LEDs when it gets dark and off when it gets light, code works fine for its intended purpose.

What I want to know is, how can I simplify the hardware? I need to make a few of these and I dont want to use a Nano every time.

I have attached some pics of what I have done and here is the code, if anyone is interested.

int led = 3;

#include <RBD_LightSensor.h>
 
RBD::LightSensor light_sensor(A0);
 
void setup() {
  Serial.begin(9600);
  pinMode(led, OUTPUT);
}
 
void loop() {
  int LS = (light_sensor.getPercentValue());
  Serial.println(LS);
  if (LS > 40){
    digitalWrite(led, LOW);
  }
  
  else {
    digitalWrite(led, HIGH); 
  }
}

thanks in advance.

Kane

It looks like the code senses the light level, and turns an LED on or off.

You can also do that with just an LDR (light dependent resistor), an LED, a battery and one or two more cheap components.

Or hack a $1 solar garden light.

Above my pay grade and I have yet to use this - but have you thought about an ATtiny85?

It looks like the instruction set will work and you only need 2 I/O

Or as the person that just posted ahead of me it should also be able to be done with discreet components

gogreenpower2:
Hi guys,

I have make a switch that turns on some LEDs when it gets dark and off when it gets light, code works fine for its intended purpose.

What I want to know is, how can I simplify the hardware? I need to make a few of these and I dont want to use a Nano every time.

Ready made module Ebay......you won't get the parts for the price of the ready made unit.

Make your own.........

talkingelectronics has a variety ranging from 555 to transistor and all between

bluejets:
Ready made module Ebay......you won't get the parts for the price of the ready made unit.

4 Wires Light Detection Photosensitive Sensor Module Photodiode for | eBay

I think this might be the simplest solution. thanks for all the replies.

edit: can these be used as a standalone switch, most of what I can find they are still running off a board of some type.

It seems the cost of an ATtiny85 - $6 is only about $1 cheaper than some Pro Mini's and Attiny85 USB Development Board. extra $1 might be worth it for the regulator.

ATTiny13A is my favourite device for such tasks, much cheaper than the t85 and working down to 1.8V. It does not have a bootloader and needs to be programmed using the ISP but when you learn how to use Arduino as ISP (or get one of the cheap programmers from eBay) there is little difference.