Laser trip switch?

I want to use a laser and a ldr to switch on a relay using arduino
once the laser is tripped the relay turns on and once it trips again its off 
could some one help me with the code and schematics i want to use pin 9 as in1 on the relay 
thanks a ton in advance

sort by: active | newest | oldest
-max-1 year ago

What fun is it to DIY if you cheat by getting other people to make the code for you? ;) Besides, arduino is completly overkill for this application! Just need a little bit of analog ingenuity, and a soft latch!

iceng -max-1 year ago

Which Resistor do you `want to be the LDR ?

-max- iceng1 year ago

This specific circuit is not ideal for that, but is should not be too hard to do that with a little logic and comparators. I think it might even be possible to simply replace the switch in that circuit with a LDR, although it would have to go really high resistance state when not activated.

-max- -max-1 year ago

I went ahead and built that exact circuit up today, and found that while it works OK, it tends to trigger on much easier than it does off. I tried adding VDR in place of the switch, which did not work. That was expected anyway. I was hopeing a MOSFET might work well enough as a switch, for which I could pull control the gate with the VDR and a current source or sink, but the body diode in the MOSFET was too leaky. Even the capacitive effects of the gate were enough to trigger the circuit and cause it to trigger. A relay (or a analog switch) may be the way to go for this circuit.

TheGreatResistor (author)  -max-1 year ago

i went ahead and built this circuit which makes my mosfet really hot it is a very simple design but only for on and off no timers btw i used a irfz44n instead of a transistor since i have current draw upto 2 amps and led in this circuit is the strip i just made some modifications to mine


MOSFET are not perfect substitutes for BJT transistors. BJT's are current controlled devices and will will turn on when enough current flows from the base to the emitter, which occurs when the base-to emitter voltage exceeds 0.6V. The base-to-emitter junction looks like a diode, hence, the symbol with that arrow.

MOSFETs on the other hand are voltage controlled devices. A common standard N channel MOSFET will turn on when the gate exceeds several volts, typically 7 volts. If you cannot get the gate of a standard MOSFET at least that high compared to its 'source', then the MOSFET will not saturate and will not turn fully on. the gate of a MOSFET "looks" like a tiny capacitor between the gate and source. It has extremely HIGH resistance, meaning that current will not flow in or out of the gate unless the voltage on the gate changes rapidly.

iceng -max-1 year ago

Mosfets like the 2N7000 can start turning on at o.8Vgs and is guaranteed to start at 3Vgs then it conducts over half an amp at 4.5Vgs.

They were designed to operate with micro-processors !

-max- iceng1 year ago

In general the gate of a MOSFET needs several volts though. I do not have any 2N7000's to experiment with, but the graph that shows the drain to source current shows that the 2N7000 does not conduct until the gate reaches 2V. (10Vds)

iceng -max-1 year ago

A graph is the idealized manufacturers representation of transistor action.

As an engineer, I design for the limits of the bell curve because in space there is no easy circuit adjustment that non-engineers are fond of doing in labs.

Again I point to Gate Threshold minimum / maximum colored values that are normaly ignored by designers who prefer to use typical values and trust in Saint Eligius over proper engineering design abilities.

-max- iceng1 year ago

That's interesting, it is pretty low! But certainly the effective impedance of the channel is very high at that point.

-max- -max-1 year ago

The most likely reason the MOSFET is getting hot is because you are stuck it the linear region, where the FET acts more like a resistor rather than a short to ground. So like I said before, voltage dropped across the MOSFET times the current through it will give you power dissipated. If the MOSFET was fully turned on or off, then the power dissipated would be close to zero.

You will need to mess with the values of R2 in order to get this to work. MOSFETs have a pretty wide range of voltages for which they will remain in the linear region, So that means that the light hitting the VDR will have to be either very bright, or completly dark. You may need to use a comparator between the VDR and resistor network and the MOSFET gate. Comparitors are qwute cool things, search into them if you are intrested.

TheGreatResistor (author) 1 year ago

hey guys i really appreciate for taking your time to answer my question but i went with this neat design

iceng1 year ago

Here is a Latch easy to understand...

1] Light lowers the LDR resistance, which turns the p-mosfet ON...

2] The NPN Q1 is turned on by the path R2-D1-Q1 base-Emitter to ground.

3] Q1 holds the Q3 gate low ensuring Q3 stays Latched ON.

4] Pressing switch S1, takes away base drive from Q1 NPN and unless the Laser is working the LDR the mosfet gate goes high turning the Latch OFF.

Be sure to click the pic to see all the details...

iceng iceng1 year ago

Square images appear whole :-/

iceng iceng1 year ago



that one comes up with stuff on road trips maybe using the NOT search would help https://www.instructables.com/howto/laser+trip+switch+NOT+road+trip+NOT+backpacking/

TheGreatResistor (author) 1 year ago

Thanks but i need a proper code and it shud be on once tripped and if tripped again it should go off

Here you go: Click