this one covers a standard button module on-board, the same principl;e and arduino code applies for a button withouth the pcb and pins, using the buttins pins themselves. if youre enjoying these tutorials please...
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. Let's check out another input.
This time it is a simple push button module. So this one is not too complicated. You're welcome
to run the signal pin back into another pin and then turn the LED on your board on and off,
but I've chosen to put an external one. So I've got a regular LED here. This is a 10 millimeter LED
and there's a 220 ohm resistor on it between that and pin number 8. The other side is going back to
ground and that's just kind of a separate setup that's not included with the button, but you'll
see why that's on there in a second. The signal here is going into number 5 and the negative and
positive are hooked to the 5 volt and ground as well. So the button works. You can see it turns
on the light. So I'm going to make this window a touch small. I suppose you don't need to see the
comments. So basically there are a few lines of code here and we are grabbing LED pin 8. That's
where the LED power is coming from. That's the negative side of the LED and remember we're
running that through that 220 ohm resistor there and then we are grabbing pin 5 and that is the
actual sensor for whether or not the button is pressed down. So then you have the value here.
This int value equals zero. That's a variable we're going to use down here to read whether
it's pressed or not, but first we have to set them up. So we're going to set up the LED pin as an
output because we're going to put out power when we're on high and then we have the in pin as input
and this is the pin that's connected to the sensor on the button module. So we are going to go ahead
and jump down to the loop after that and set value equal to a read of the button whether it's pressed
or not. So if it's pressed it's going to say that the value is low actually and not high. So if the
value is high we're going to turn the LED pin off which is the natural state of the button. So if
it's not pressed we want the LED off. Then if it is not, which is what this else means, it means if it's
not high then we're going to digital write LED pin high. So we're going to turn it on and this is how
that works once you've uploaded it. Basically a quick press of the button the light turns on. It
stays on while you hold it down because the loop is still checking and then when you release it
after about a half a second it just stops. So there's no delay in here. There doesn't need to
be. It's working just fine how it is and everything is working properly. Now I could hook up a couple
more LEDs I suppose. Although I might have to change the resistor to get enough power but let's try
quickly if we can light them both up with the press of the button here.
Just by inserting one more and attaching it to the same ground and there you go. They do both
light up. The green's not so bright. Needs a little more power in the red but they're still
both lighting up. So pretty simple push button for the Arduino and let's move on to the next sensor.
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.