I thought I should have some hardware projects on my Github so I decided to start with a fairly simple one. This is a night light that lights up when it's dark enough.
- 330 ohm resistor
- 100k ohm resistor
- BC547 (NPN transistor)
- photoresistor
- LED
- power source
Above is the final schematic for this circuit. There are two parts to it, first is the right side which uses an NPN transistor as a switch. The left side is a voltage divider.
These calculations were done to figure out the required resistance for the LED.
Typically, the forward voltage of an LED is between 1.8 and 3.3 volts
-- Wikipedia
The specific LED I was using has a forward voltage drop of around 2V and needs about 10mA for it to function optimally. Using Ohm's law, we can calculate the required resistance.
I don't have a 400 ohm resistor. 330 is close enough (alternatively 470 would work too but I don't have that either).
When looking at the datasheet for the transistor I used, it says the minimum voltage to turn the base on is 580mV. This means as long as a value greater than 580mV is passing through the base, there will be a current flowing from the collector to the emitter.
The formula for voltage dividers can be found with a quick search.
Above is an image from Wikipedia. Wikipedia also gives us the formula for a voltage divider as
In the schematics I drew up,
I don't have a 93.4k resistor so I used an 100k resistor.