Connect Push Button with Raspberry pi 4
Вставка
- Опубліковано 8 вер 2024
- Connect Push Button with Raspberry pi 4
Scroll down for code.....
Push buttons and switches are very important part of any electronic device. You use it daily to turn on Lights to mobile phone. It is everywhere. There are various type of push button two leg and four leg. But we will use four leg push button for this tutorial. In short this tutorial is about, when you press button it will turn ON LED, when you release button it will turn OFF LED.
If you want to support my video please buy any product through my amazon affiliate link. I will receive a commission, at no extra cost to you.
LIST OF COMPONENT (affiliate links)
amzn.to/2noWmWm (Raspberry pi 4 model B)
amzn.to/2nm0d6x (Raspberry pi 4 power supply)
amzn.to/2APAvuf (Dual fan heat sink aluminium armor Raspberry Pi 4 case) Optional
amzn.to/2vn4IyP (Push Button)
amzn.to/2mIHAJF (microSD card)
amzn.to/2vSpUON (LED)
amzn.to/2wxPmWz (Breadboard)
amzn.to/2vJ3lvo (Jumper wire)
amzn.to/2vmSK8l (Resistor)
► Jarico - Landscape : / la. .
► Jarico - Landscape [NCS BEST OF]: • Video
from gpiozero import LED, Button
from signal import pause
led = LED(25)
button = Button(2)
button.when_pressed = led.on
button.when_released = led.off
pause()
Very nicely done
can you connect a button like you did without that board? Like connecting it directly?
Yes but it will be very hard