# Picaxe Project - LDR trigger and relays



## Dead Things (Apr 4, 2009)

Here is a Picaxe project I have been working on, using an Light Dependent Resistor to trigger 12VDC relays.






Thanks to Steve O and hpropman for walking me thru this . I keep saying this and I mean it, I really appreciate the helping hand that people extend.
The code for switching the relays is binary.


----------



## halstaff (Nov 18, 2009)

Looking good!
Are you using the 18M for this project? Fritz has got me convinced I need to move up from the 08 and get more capabilities. Being able to drive the relays directly off the board is nice.


----------



## Dead Things (Apr 4, 2009)

halstaff said:


> Looking good!
> Are you using the 18M for this project? Fritz has got me convinced I need to move up from the 08 and get more capabilities. Being able to drive the relays directly off the board is nice.


Thanks, have been following your work, too! Yep, using the 18M2, I bought the starter kit http://www.rev-ed.co.uk/images/full/chi030.jpg as well as a seperate 18M2 and darlington driver, as per Steve O's Roll Your Own.. 
I will probably use the chi030 as a show controller and put the other one into a prop.


----------



## halstaff (Nov 18, 2009)

Would you mind posting the code you used?
I'll be adding some relays and it would help get the process started.
Thanks.


----------



## Dead Things (Apr 4, 2009)

halstaff said:


> Would you mind posting the code you used?
> I'll be adding some relays and it would help get the process started.
> Thanks.


Here it is, any critiques are welcomed.

CODE
----------------------------------------------------------
symbol adc_val = b8
let dirsb = %11111111
let pinsb = %00000000

main:
readadc c.1, adc_val
if adc_val > 130 then noshow
if adc_val < 130 then gosub show
noshow:
pinsb = %00000000
goto main

show:
let pinsB = %00000001
pause 1000
let pinsB = %00000011
pause 1000
let pinsB = %00000111
pause 1000
let pinsB = %00001111
pause 1000
let pinsB = %00001010
pause 1000
let pinsB = %00000101
pause 1000
let pinsB = %00000000
pause 1000
let pinsB = %00001111
pause 1000
let pinsB = %00001100
pause 1000
let pinsB = %00000011
pause 1000
let pinsB = %00001000
pause 1000
let pinsB = %00001100
pause 1000
let pinsB = %00001110
pause 1000
let pinsB = %00001111
pause 1000
let pinsB = %00000000
pause 1000
goto main
-----------------------------------------------------------


----------



## hpropman (Jul 27, 2008)

Hey great job! Are you running the relays through the darlington driver chip because I do not see any diodes on the relays. The chip has built in diode protection but if you do not use the chip then you would need a transistor and a diode for each relay. The chip just makes it easier and neater.


----------



## Dead Things (Apr 4, 2009)

hpropman said:


> Hey great job! Are you running the relays through the darlington driver chip because I do not see any diodes on the relays. The chip has built in diode protection but if you do not use the chip then you would need a transistor and a diode for each relay. The chip just makes it easier and neater.


Sorry, Joe, just saw your reply today. yes i am going to be using the Picaxe 18M2 starter board which, as you know, has the darlington built in. This is the other part of the equation to my Haunt Controller.


----------



## fritz42_male (May 5, 2009)

Dead Things - video taken down?

Just fyi, Steve and I are playing with Picaxe based sound to servo and should have something up soon.

For all those Picaxe users out there, I can recommend the Pebble breadboarding tool. It's very hand for playing with layouts before you build them. Get it here:

http://www.picaxeforum.co.uk/showthread.php?t=12629

I'll also be updating my VLC project soon with various 'daughter' boards e.g. the op amp for the sound to servo, a transistor/diode/relay combo etc. These will all use the standard servo extension cable to connect up.

Steve and I are using the H5608 Protoboard which is available in the US from Radio Shack as the 276-150

http://www.radioshack.com/product/index.jsp?productId=2102845&filterName=Category


----------

