Light Sensing LED - PICAXE Version

by Bot1398 in Circuits > Microcontrollers

34704 Views, 100 Favorites, 0 Comments

Light Sensing LED - PICAXE Version

SAM_1693.JPG
A while ago I posted light sensing LED which used the arduino board now it is the same project but using a PICAXE microcontroller.This is the simplest circuit you might have ever seen it only uses a PICAXE microcontroller,a resistor and a LED.A LED not only lights up when power is applied but also produces a tiny voltage when exposed to light.Based on this principle we are going to make our "light sensing LED".A single LED is used to take a reading and light up when it is dark.This is a fun to do project which requires minimal parts.

This instructable will explain how to create your own light sensing LED,making some changes,programming the microcontroller,makingit on a breadboard and soldering the circuit.

A short video of it in action:



How Can the LED Sense Light?

led_bulbs.jpg
An LED can be used for light detection as well as emission.LED is a simple diode which has been adopted to emit light.Therefore if it is inserted into the circuit the same way as the photodiode it will serve the same function of sensing light

The LEDs will be sensitive to the light which has the wavelength equal to it or lesser than it.

When light falls on the LED a small voltage is produced this voltage produced can be fed to a microcontroller which can read it and follow the further instructions.

Parts & Tools

SAM_1342.JPG
SAM_1122.JPG
SAM_1606.JPG
SAM_1139.JPG
SAM_1344.JPG
SAM_1346.JPG
SAM_1350.JPG
SAM_1349.JPG
Parts :
~ PICAXE 08M2 Microcontroller - Sparkfun.com
~ 330 Ohm Resistor - Sparkfun.com
~ Green or Red LED(I used a green LED) - Sparkfun.com
~ 10k Ohm Resistor - Sparkfun.com
~ 22k Ohm Resistor - Sparkfun.com
~ Audio Jack - Sparkfun.com

Tools :
~ Soldering Iron - Sparkfun .com
~ Solder Wire - Sparkfun.com
~ PICAXE Programmer - Sparkfun.com
~ ProtoBoard - Sparkfun.com
~ BreadBoard - Sparkfun.com
~ PICAXE Programming Editor - Picaxe.com
~ Audio Cable 3.5mm - Sparkfun.com 
~ A to miniB USB Cable - Sparkfun.com

Note - Use only green or red LED and not any other color as the LED's of these two colors are the most sensitive to light.

The total cost would be around 5.55 $ assuming that you have all the tools.

Programming

SAM_1638.JPG
SAM_1643.JPG
SAM_1649.JPG
First you will need to program your PICAXE microcontroller for this you need a programmer I bought one from sparkfun for $14 it is the cheapest USB programmer for PICAXE that I found and you will need to download the PICAXE programming editor.Configure you programming editor to 08M2 mode and select the suitable COM prot.For programming your PICAXE you need to make the download circuit it consists of three wires.One wire sends data from the computer to the serial input of the PICAXE, one wire transmits data from the serial output of the PICAXE to the computer, and the third wire provides a common ground.I have added a schematic for the download circuit.You also need to externally supply 4.5v power supply to the PICAXE while programming (My programmer needs a external supply yours may not need one).I  made the circuit on a breadboard you can make it on a protoboard.I removed the power rails of my breadboard as they were not allowing the cable to go into the audio jack.

Here's the sensitive to dark code
main:readadc 2,b0
        if b0 < 10 then dark
        goto main
    
dark:high 2
     pause 1000
     goto main
        

Here's the sensitive to light code
main:readadc 2,b0
        if b0 > 10 then light
        goto main
    
light:high 2
       pause 1000
       goto main


If the programming finishes properly a pop up window will appear saying success and will display the size of the sketch.If something goes wrong please feel free to ask.

Built the Circuit

SAM_1656.JPG
SAM_1659.JPG
SAM_1661.JPG
SAM_1670.JPG
Untitled.jpg
This might be the simplest circuit you might have ever seen it consists of a PICAXE microcontroller,a LED and a resistor.A single LED is used to take a reading and light up when it is dark.You can test the circuit on a breadboard then you can solder it on a protoboard.The circuit is pretty straight forward connect the +ve terminal of the LED (with a longer lead) to pin2 of the PICAXE microcontroller and connect the -ve terminal of the LED (with a shorter lead) to gnd. Dont forget to add a resistor between the +ve terminal of the LED and pin2 of the microcontroller.Connect the +ve and -ve terminals of the microcontroller to +5v and -5v respectively.I used a wall adaptor to power it you can use 3xAA batteries.I used no resistor for the LED as it has a inbuilt resistor.Look at the last image for the schematic!.

Testing & Changing Sensitivity

SAM_1702.JPG
SAM_1701.JPG
There are two codes that I have provided one is the sensitive to dark code and the other is sensitive to light code.If you are using sensitive to dark code the LED should light up when you are in dark and should switch off when you are in a well lit room.If you use the sesitive to light code then the LED should light up when you are in a well lit room and should switch off when you are in dark.To change this sensitivity what I did was I simply replaced ' < ' with ' > ' and it worked.

Soldering

SAM_1620.JPG
SAM_1623.JPG
SAM_1628.JPG
Now that you have built the circuit on a breadboard and tested it lets make the circuit permanent and solder it.If you have no experience of soldering consult this guide.You should always use the lead free solder as leaded could be harmful.Maintain safety while ,soldering use gloves and safety glasses use proper stand to keep you soldering iron as it is very hot and can harm you.You can use hard core wire to make the connections.You need a very small piece protoboard as this circuit is very small.Use 8 pin DIP socket to keep your PICAXE microcontroller safe.This might be the worst soldering you have ever seen but don't mind as I am not at all good at soldering.

All Done!

All-Done.jpg

Hope this project inspires further experimentation. The PICAXE microcontrollers are extremly versatile and have a easy to learn programming language. This is just one of many simple projects which can be constructed using the PICAXE microcontrlles. Keep pondering!.Dont forget to follow mores comming up. .For any queries leave a comment below or PM me