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

КОМЕНТАРІ • 86

  • @JS-jq8pu
    @JS-jq8pu 2 роки тому

    Awesome! As a 41 yr old I am deeply inspired to get into Pi engineering. Thank you for your lessons and enthousiasm.

  • @msimisimlangeni681
    @msimisimlangeni681 3 роки тому +1

    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

  • @zachdavis8703
    @zachdavis8703 3 роки тому +6

    You made this so simple. It's not easy to find videos like these. Thanks!

  • @vittal255
    @vittal255 3 роки тому +4

    Your Raspberry Pi videos are the best on UA-cam by far. Really appreciate the clear instructions. Thanks!

  • @TraceguyRune
    @TraceguyRune 7 років тому +7

    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

  • @bobtony6036
    @bobtony6036 6 років тому +4

    does it matter where you put the resistor? i noticed some people were putting it between the LED and ground.

    • @lucasanderson8521
      @lucasanderson8521 5 років тому

      no
      electronics.stackexchange.com/questions/61674/how-do-i-know-where-to-place-resistors-on-my-circuit

  • @diyvideos8836
    @diyvideos8836 2 роки тому

    Hi, Do the codes we want run every time we press the button?

  • @DommoDommo
    @DommoDommo Рік тому

    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

  • @sivagamishanmugam9101
    @sivagamishanmugam9101 6 років тому

    As a beginner it is very useful and learn something about raspberry pi

  • @bender9929
    @bender9929 3 роки тому +1

    Cheers. This helped me work out what was wrong with freenove tutorial 2

  • @JM-tp5wr
    @JM-tp5wr 7 років тому +2

    Thank you! super helpful. I love these videos, can't wait for more.

  • @mbshaw1
    @mbshaw1 3 роки тому

    How would I code for an output to be dependent on two buttons being pressed simultaneously.

  • @atharvapatil6427
    @atharvapatil6427 7 років тому +1

    Great Tutorial! How to use a 6 pin self-locking push button for the same application?

  • @somenamethisis
    @somenamethisis 4 роки тому

    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.

  • @undeadwolf07
    @undeadwolf07 6 років тому +1

    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.

  • @ls28steamroller
    @ls28steamroller 3 роки тому

    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 -

  • @BurgZergArcade
    @BurgZergArcade  8 років тому +4

    We now have the basics of some Input and some Output. What should we build now?

    • @artemkonoplin2143
      @artemkonoplin2143 8 років тому +2

      How about skynet? :)

    • @BurgZergArcade
      @BurgZergArcade  8 років тому +7

      We are going to need a bigger bread board that that!

    • @fortuneflux
      @fortuneflux 7 років тому

      What about something with a sensor or even better a motor/servo?

    • @JohnWest4
      @JohnWest4 7 років тому

      Photo cell - interrupt trigger! Switches are just so ... binary!

    • @40rcec0re6
      @40rcec0re6 5 років тому

      You should build a rfid lock system

  • @exonax4188
    @exonax4188 4 роки тому

    Does this work with multiple buttons?

  • @Asjah_Marie
    @Asjah_Marie 3 роки тому

    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

  • @guillermoperez8250
    @guillermoperez8250 5 років тому

    Turning on an off Raspbian is a bit time consuming, isn't it? Any hint on how to make the prototyping more agile?

  • @jaysonsiebold
    @jaysonsiebold 7 років тому

    What’s the song at the end?

  • @catalinion8849
    @catalinion8849 6 років тому

    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!

  • @cranjismcbasketball8113
    @cranjismcbasketball8113 4 роки тому +4

    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

    • @Alan_1
      @Alan_1 2 роки тому

      Same here on zero w

  • @Vincintosh
    @Vincintosh 7 років тому

    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

    • @Bebop79
      @Bebop79 5 років тому

      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

  • @fotarbas
    @fotarbas 5 років тому +1

    nice video!! thnx
    it doesnt work for my RPi 4. led stays ON.

  • @firstnamelastname9398
    @firstnamelastname9398 5 років тому

    Question: isn't Ground positive? Because electricity flows from negative to positive?

  • @KapybaraKSP
    @KapybaraKSP 7 років тому

    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?

  • @indervirsingh3123
    @indervirsingh3123 8 років тому

    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?

    • @BurgZergArcade
      @BurgZergArcade  8 років тому +1

      +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.

  • @TheOldBlackCrow
    @TheOldBlackCrow 4 роки тому

    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.

  • @MrAdamo
    @MrAdamo 7 років тому +2

    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.

  • @rikmentink2392
    @rikmentink2392 6 років тому +1

    Can you please leave a download link for the breadboard connection list you have?

    • @40rcec0re6
      @40rcec0re6 5 років тому

      They are all over the Internet

    • @40rcec0re6
      @40rcec0re6 5 років тому

      They are all the same

  • @yapandasoftware
    @yapandasoftware 6 років тому

    anyway to weave this code into Tkinter to give you a graphical representation of the I/O showing button changes or label changes?

    • @CrypticConsole
      @CrypticConsole 6 років тому

      Yes use a while True loop with root.update()

    • @yapandasoftware
      @yapandasoftware 6 років тому

      @@CrypticConsole I did something similar. I used win.after() and win.checkstatus() to send the args into a loop.

  • @ad9291
    @ad9291 4 роки тому

    Amazing, subscribed

  • @superporkchops3604
    @superporkchops3604 5 років тому

    Can youu do this without the LED and make it so each press acts like a key?

    • @40rcec0re6
      @40rcec0re6 5 років тому

      Yeah u can pretty much do anything in coding

  • @alamgirahmed8329
    @alamgirahmed8329 5 років тому

    can you do the code in the linux terminal instead of using python?

  • @CodingWithBen
    @CodingWithBen 4 роки тому

    My button is NO however when I press it the LED turns off

  • @ahmed-elakkad
    @ahmed-elakkad 5 років тому

    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

    • @40rcec0re6
      @40rcec0re6 5 років тому

      It should depends on the type of button

  • @Deschuttes
    @Deschuttes 7 років тому

    Nice job

  • @zaldyjr
    @zaldyjr 6 років тому +2

    I don't know why but GPIO.PUD_UP won't work, but PUD_DOWN works on 3.3 and 5v.

  • @artemkonoplin2143
    @artemkonoplin2143 8 років тому

    Woohooo! Thank you!

  • @theorangejuice05
    @theorangejuice05 5 років тому

    It worked but when I press the button I rapidly blinks

  • @sunilmanandhar1181
    @sunilmanandhar1181 7 років тому

    How can I do this without using breadboard?

    • @BurgZergArcade
      @BurgZergArcade  7 років тому

      Sunil Manandhar you could slider it all together.

    • @TraceguyRune
      @TraceguyRune 7 років тому

      Do you not own a bread board or just looking to make something more advanced ?

  • @xxxd6068
    @xxxd6068 6 років тому

    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

  • @randomizedletters4466
    @randomizedletters4466 5 років тому

    raceback (most recent call last):
    File "/home/pi/Desktop/button.ply", line 6, in
    sleepTime - .1
    NameError: name 'sleepTime' is not defined
    >>> please help

  • @theuncoder8130
    @theuncoder8130 4 місяці тому

    buttons won't work on my rapsberry pi 4

  • @StrangeComments
    @StrangeComments 7 років тому +2

    If we weren't to have that sleep call, what would happen?

    • @raintzrandmaa9829
      @raintzrandmaa9829 7 років тому

      +BurgZerg Arcade Please anserw that question

    • @ZipTronic
      @ZipTronic 7 років тому

      yes I agree someone answer this question, does it even need the sleep timer input?

    • @TraceguyRune
      @TraceguyRune 7 років тому

      It would stress the CPU and Pins...

    • @JohnWest4
      @JohnWest4 7 років тому

      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.

    • @stinky6245
      @stinky6245 6 років тому

      Sleep call is to debounce the button. It registers as multiple button presses if you do not have it.

  • @sanmighty3308
    @sanmighty3308 4 роки тому +1

    I never knew python was easyer than JavaScript. Imean it’s literally the word not

  • @mayeshadeen
    @mayeshadeen 3 роки тому

    6:56

  • @TraceguyRune
    @TraceguyRune 7 років тому +2

    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

    • @JohnWest4
      @JohnWest4 7 років тому +1

      Good call! I am.. but only red and green colorblind- haha... Thats what my Fluke is for!

    • @BigHonkinGoose
      @BigHonkinGoose 4 роки тому

      I just use my multimeter.

  • @tim4168
    @tim4168 7 років тому

    why are everyone using board to connect all?

  • @larsnobel4279
    @larsnobel4279 5 років тому

    fucking last lesson... nice way to begin a video....

  • @FedericoGranata
    @FedericoGranata 7 років тому +1

    Dude you have to fix the focus of your camera. It keeps changing while you move your hand and it makes me sick ...