this is the photo interruptor. also fun! as usual i have included the code for the module in the video so it should have you up and running quickly. and as always, if it helps...
Like and Subscribe!
Affiliate links for arduino sensors! Large Arduino Kit (Recommended) includes various sensors, a couple breadboards, loose components, pcb board, jumper wires, soldering iron AND more: https://www.banggood.com/custlink/mmKhdf9Si8
Want to send me something? Technivorous 902 n Hughes Blunt Sd 57522
AI Generated·May contain errors
All right, folks. Welcome to Arduino for Beginners. This is Arduino 101.
And in this one, we're going to be taking a look at this little guy. Now, this is quite
an interesting little device. This is the HW487, and it is also known as a... Let's get this right
here. This is a photo interrupter module is what it's called. So this has this little plastic guy
on here, and there are two ridges there. You can see those ridges. And if you slide something in
between there, it blocks light getting from one side to the other, and it will return a signal.
So this is another simple wiring setup. I have my positive and my negative wired to the five
volt and the ground, respectively. Then I have my signal. My signal, in this case,
is plugged into number three, and I have a very simple code running. Now, this code here
is three integers. You have LED, which is 13, button pin, which is three, and
valve, which is left empty. Then we will go into our setup and set two pin modes,
pin mode LED as output, which means pin 13 is an out, and pin mode button pin input, which means
that number three, which we're plugged into, is an input. So then we're going to loop,
and our loop is super short. It is value equals digital read on button pin. Then if value equals
high, which means that it's sending a signal, then we are going to write the LED to be high,
which means on. If it is not high, which means it's not sending a signal,
it is going to write the LED to be low or off. So what we are going to go ahead and do
is demonstrate this. I've already uploaded my sketch. What it does is pretty straightforward.
You're going to have to watch the yellow light on the UNO here. As I slide in between there,
the light turns on. When I remove it, the light goes off, and on, and off, and on,
and off. And it doesn't have to be that object. Anything that blocks it more completely will
give you a better signal, but pretty much anything that can block it can go in there.
Let's try a sticker. I have a sticker here, and these are opaque. So as I drop this in between
those little guys, the light stays on steady because it's not receiving anything on the other
side. So then I remove it, and pretty cool. This is a good way to tell if something is or has been
opened. There are numerous applications for this item as well, not just the one that I just
mentioned. And like I said, if you're interested in any of these sensors, you don't have any of
the ones that I'm showing you, feel free to use the affiliate link down below and grab yourself
a whole set. They're pretty cheap, and they are fun to play around with, and pretty versatile as
well. So that's going to be it for this quick video, although I think we will wrap up with
another little pop. So let me show you this in conjunction with another sensor, and it'll be our
first two sensor setup. Now I have a simple buzzer here. Now this buzzer is hooked in on
the positive side here, which means it's getting power, and the negative, the return side,
I'm going to take and plug in over here to number 13. But before I do that, I want to make sure that
I have something blocking my sensor here. My light has turned on, and you know that that's working
properly. It's blocked, so I'm going to go ahead and plug this into 13. Okay, so right now my lid
is closed, my latch is functioning fine, and somebody tries to open something that I've made
that I didn't want them to open, and really annoying alarm goes off. So as soon as that is
removed, oh that is annoying. So let's see, and I haven't tried this yet, but let's see if we can
try this in reverse, shall we? Nope, it doesn't work that way. So you have to have the positive
plugged into positive, and then like I said, and of course again we are using the breadboard
in this case because we are trying to power two objects at once, and there is only the one
five volt pin. So pretty nifty little alarm if you want to set off an alarm in your safe home
if a window is opened or something like that. Very, very neat little trick, and very, very handy
for both of these sensors. Well, that's it guys. That's going to wrap up this video. If you've
noticed a shirt, the merch is available. Go ahead and check out the Teespring merch link down below.
It won't be available on a channel store until I reach 10,000 subscribers, and so far I am just
about to hit 5,000. So it'll be a little while, a couple more months before you see this on the
actual channel, but they are available now. I have a couple other designs. Feel free to pop over there
and check them out, and know that any purchase through the Teespring site definitely helps to
promote our site here and increase the channel's ability to make videos in the future. So we
appreciate all your support. Don't forget to check out the Teespring link. Check out our Patreon link.
Leave a like on this video and hit that subscribe button because we have a lot more coming at you
in the coming days.