Break beam laser

I've been searching the Internet for weeks without success for the possibility of using a Keyes ky-008 laser module and detector to activate a servo motor once the beam is broken. Is it possible? I've have code for turning on and off an LED light once the beam is broken but I don't know how to modify it to activate a servo ........ If it's possible.

I have been helped with the sketch by POWER_BROKER.

He has helped me activate a servo once the beam is broken. All is good now everyone. Thank you for everyone's advice and especially Power_Brokers code/sketch.

kidokwan:
Is it possible?

I've have code.

  1. Sure.

  2. We don't see it.

A wiring diagram and and a picture of the setup might also be handy.
And a rough idea of the distance you want to bridge.
Leo..

Hi Wawa. That's good news to know you have the code. Would you be willing to share it with me? It would save me pulling my hair out. :slight_smile:

I don't have any code.
I just said it was possible (for you to do).
This part of the forum is for people that know what they want, have the code, but it doesn't work as they expect.
So far I only know that you have a ky-008 laser.
Leo..

Go to your code. Where it says write to the LED, replace it with a myservo.write.

Also do some other things like stuff and that other thing.

Great advice. Thank you. I'll give it a try and if it works out I will post the code for anyone else.