Raspberry Pi Button Input
Вставка
- Опубліковано 30 січ 2025
- Today we are going to learn how to take the input state of a button, and translate that over to the state of a LED. This will allow us to turn a LED on and off when the button is pressed on our bread board.
Get your Pi:
Raspberry Pi 3 - amzn.to/2jINKSY
Raspberry Pi Starter Kit - amzn.to/2jIG3vJ
Raspberry Pi Parts Kit: amzn.to/2knUQj6
Raspberry Pi Deluxe Breakout Kit - amzn.to/2jFILn8
~-~~-~~~-~~-~
Raspberry Pi 3 Setup - • Raspberry Pi 3 Setup
SUB GOAL ► ||||||||||||||| 54% ||............. 54.3K/100K
⭐ LATEST SUBSCIBER ► John Nino Doligol ⭐
--------------------
➤ Subscribe: vod.strms.net/...
➤Github: github.com/bza...
➤ Patreon: vod.strms.net/...
➤ Discord: / discord
--------------------
GEAR I USE (affiliate links):
➤ Mic - amzn.to/2Yj2L7H
➤ Audio Interface- amzn.to/3kVCBQT
➤ Camera - amzn.to/3urWe6v
➤ Lens - amzn.to/3okaRI1
➤ Mouse - amzn.to/3F0kxx4
➤ Keyboard - amzn.to/2ZBBM7F
➤ Hot Keys - amzn.to/3m7URWA
Outro Song: TheFatRat - Unity
#RaspberryPi #rpi #led
Awesome! As a 41 yr old I am deeply inspired to get into Pi engineering. Thank you for your lessons and enthousiasm.
Your voice is clear 100% and i understand the stuff...thumps up with your Tutorial 100%
...From now you gonna be one of my Raspi Teachers lol
Glad I could help!
You made this so simple. It's not easy to find videos like these. Thanks!
You're welcome!
Your Raspberry Pi videos are the best on UA-cam by far. Really appreciate the clear instructions. Thanks!
You're very welcome!
Thanks for this video. It helped a lot. I was able to hook up two buttons to control the LED and had a sound effect for each of the buttons . Can you do a video on Pull Down?
PS. You can use GPIO.setmode(GPIO.BOARD) for better numbering of the pins 7:04
does it matter where you put the resistor? i noticed some people were putting it between the LED and ground.
no
electronics.stackexchange.com/questions/61674/how-do-i-know-where-to-place-resistors-on-my-circuit
Hi, Do the codes we want run every time we press the button?
do I need a breadboard, can I plug my button with some soldered jumper wires directly into 39/40 in the pi? -- I just want the button to register a click not light up an LED
As a beginner it is very useful and learn something about raspberry pi
Cheers. This helped me work out what was wrong with freenove tutorial 2
Glad it helped out.
Thank you! super helpful. I love these videos, can't wait for more.
How would I code for an output to be dependent on two buttons being pressed simultaneously.
Great Tutorial! How to use a 6 pin self-locking push button for the same application?
What is the maximum voltage we can connect to it ? For example, if I want to run a fan using the same would it be possible ? Cuz the module seems pretty small and could get fried easily.
Does the T-Cobbler not work with the buttons because nothing happens when I push the button and I have the code setup correctly as well as the breadboard, also I looked at a lot of other videos like this and nobody uses it.
This is great. I’m doing led buttons a to e and 1 to 4 and want them to stay on until pressed blink off and back on.
I need to assign the button to the keyboard letter -
We now have the basics of some Input and some Output. What should we build now?
How about skynet? :)
We are going to need a bigger bread board that that!
What about something with a sensor or even better a motor/servo?
Photo cell - interrupt trigger! Switches are just so ... binary!
You should build a rfid lock system
Does this work with multiple buttons?
My Button still doesn't work after the script, should I unbend my legs more, the light stays on but only turns off once I quit the script from running
Turning on an off Raspbian is a bit time consuming, isn't it? Any hint on how to make the prototyping more agile?
What’s the song at the end?
Without using the pull up/pull down circuits, integrated in raspberry pi, can we make it run using +5V pins? Using an Output Gpio pin instead of +5V pins causes damage for Raspberry or it is ok too? Thank you!
Why is the light staying on even after I end the program for when I add in the Finally statement?Everything works correctly except that
Same here on zero w
Very easy to understand, good tutorial, thanks! But I would like to know how would you make the button turn the LED ON and let it stay on and then when the button is pushed again, the LED would go OFF and stay off: this would be very useful to control a diy smart light or AC socket
Not sure if you found an answer by now but what you're looking for is a toggle. I don't have the code for it but you need to save the state of the LED and have it toggle each time the button is pressed. so something like if button == true then ledState = not ledState
nice video!! thnx
it doesnt work for my RPi 4. led stays ON.
Question: isn't Ground positive? Because electricity flows from negative to positive?
In order to make a sort of sonic screwdriver ( the micro switch JUST lights the LED) what is best to use in a small cilindrical area?
Oh hello past me lol
These guides are I great! I am about to buy some electronics parts for my Raspberry Pi so I can learn how these things work. I am buying a breadboard, some LEDs, 470, 2.2, and 10k resistors, tactile buttons, and jumper wires. Does this seem like enough things to play with for a beginner such as myself? I could also get some photo cells (they seem interesting) and maybe a PIR motion sensor. However, I have no idea how to use the photo cells and the motion sensors. Does this seem like a decent enough list though?
+Indervir S. I tend to pick up the the parts as needed instead of stockpiling them. So it all depends on what you are planning to create.
I have successfully created 3 buttons with three lights thanks to your tutorial.
Now, I'm trying to get that script to work with another script that makes my 2inch display work. When I run them simultaneously in separate windows, they work fine... But as soon as I copy/paste code one into another, I get all kinds of errors.
Any suggestions? Thanks for any help you can give me.
when i run the code, the light turns on and stays on, and the button does nothing. I have no idea how to fix this, please help.
Can you please leave a download link for the breadboard connection list you have?
They are all over the Internet
They are all the same
anyway to weave this code into Tkinter to give you a graphical representation of the I/O showing button changes or label changes?
Yes use a while True loop with root.update()
@@CrypticConsole I did something similar. I used win.after() and win.checkstatus() to send the args into a loop.
Amazing, subscribed
Can youu do this without the LED and make it so each press acts like a key?
Yeah u can pretty much do anything in coding
can you do the code in the linux terminal instead of using python?
My button is NO however when I press it the LED turns off
I have a two legged button and I cant get it to work :s I assumed it would have the same circuitry. Correct me if I'm wrong please =D
It should depends on the type of button
Nice job
I don't know why but GPIO.PUD_UP won't work, but PUD_DOWN works on 3.3 and 5v.
Woohooo! Thank you!
You are welcome :)
It worked but when I press the button I rapidly blinks
How can I do this without using breadboard?
Sunil Manandhar you could slider it all together.
Do you not own a bread board or just looking to make something more advanced ?
should I connect give the negative voltage to the raspberry pi ? Does it damage the board because in Arduino I should use an 3.5 positive voltage as input so when I provide negative voltage doesn't it damage the board pls help me as fast as posdible as I need it for my school project
raceback (most recent call last):
File "/home/pi/Desktop/button.ply", line 6, in
sleepTime - .1
NameError: name 'sleepTime' is not defined
>>> please help
sleepTime = 0.1
buttons won't work on my rapsberry pi 4
If we weren't to have that sleep call, what would happen?
+BurgZerg Arcade Please anserw that question
yes I agree someone answer this question, does it even need the sleep timer input?
It would stress the CPU and Pins...
Imagine if you had no sleep! no sleep = very tight loop. Very Responsive, but not thoughtful. there are other things the computer should be doing.
Sleep call is to debounce the button. It registers as multiple button presses if you do not have it.
I never knew python was easyer than JavaScript. Imean it’s literally the word not
6:56
I was learning to how read resistors, and how a question, how do color blind people read them? I'm not color blind, but l'm just thinking about others
Good call! I am.. but only red and green colorblind- haha... Thats what my Fluke is for!
I just use my multimeter.
why are everyone using board to connect all?
Tim English?
fucking last lesson... nice way to begin a video....
Dude you have to fix the focus of your camera. It keeps changing while you move your hand and it makes me sick ...
Dude how are you verified?