Cov txheej txheem:

Ntxiv Adafruit's Ring LED Momentary Hloov rau Raspberry Pi: 3 Cov Kauj Ruam (nrog Duab)
Ntxiv Adafruit's Ring LED Momentary Hloov rau Raspberry Pi: 3 Cov Kauj Ruam (nrog Duab)

Video: Ntxiv Adafruit's Ring LED Momentary Hloov rau Raspberry Pi: 3 Cov Kauj Ruam (nrog Duab)

Video: Ntxiv Adafruit's Ring LED Momentary Hloov rau Raspberry Pi: 3 Cov Kauj Ruam (nrog Duab)
Video: CentIoT PBS-11A/B Momentary/Locking 2 Pin, Push Button Switch 12MM Panel Hole, 12VDC/5A 250VAC/3A 2024, Kaum ib hlis
Anonim
Ntxiv Adafruit's Ring LED Momentary Hloov rau Raspberry Pi
Ntxiv Adafruit's Ring LED Momentary Hloov rau Raspberry Pi

Raws li ib feem ntawm kuv txoj kab txiav kab, kuv xav tau lub ntsuas hluav taws xob thiab rov pib dua ntawm Raspberry Pi-based media center khiav Kodi ntawm OSMC.

Kuv tau sim ntau qhov hloov pauv hloov pauv ib ntus. Adafruit's Rugged Metal Push Button with Blue LED yog txias heev.

Nov yog thawj ntawm ntau qhov kev qhia, uas yog lub hauv paus ntawm Kodi/OSMC lub kaus mom rau Raspberry Pi.

Hauv txhua qhov kev qhia, Kuv yuav tau txais ib feem ntawm lub kaus mom ua haujlwm thiab kuv xav tias txhua daim ntawm lub kaus mom muaj txiaj ntsig los ntawm nws tus kheej.

Kauj Ruam 1: Sau Qhov Chaw

Qhov tshwj xeeb rau qhov kev qhia no:

  • Rugged Hlau Laub Khawm nrog Xiav LED Adafruit $ 4.95
  • Kev sib cais luv luv Adafruit $ 4.95

Cov khoom siv tau thiab cov cuab yeej siv tau (tus nqi hauv USD):

  • Breadboard Fry's $ 7.99
  • Breadboard xov hlau Fry $ 7.99
  • Txiv neej rau Poj Niam Jumper Wires Fry $ 3.99
  • MacBook Pro (lub PC tuaj yeem siv tau)
  • Raspberry Pi 3 Element14 $ 35
  • 5.2V 2.1A USB Power Adapter los ntawm Amazon $ 5.99
  • Micro USB rau USB cable 3ft los ntawm Amazon $ 4.69
  • Case los ntawm Amazon $ 6.99
  • SanDisk Ultra 16 GB microSDHC Class 10 nrog Adapter (SDSQUAN-016G-G4A) los ntawm Amazon $ 8.99
  • Solder, Solder Station, Tip Cleaner
  • TV nrog HDMI chaw nres nkoj, USB keyboard, USB nas, HDMI Cable

Sau ntawv:

  • Cov ntawv nyob hauv cov spades, xws li, ♣ replace-this ♣, yuav tsum hloov nrog tus nqi tiag. Tau kawg, tshem cov spades.
  • Raspberry Pi yuav tsum tau teeb tsa thiab khiav Kodi/OSMC
  • Adafruit muaj qee qhov "qhia tau zoo", tab sis kuv tsis yooj yim nrhiav. Hauv google, sim:

    • ♣ tshawb nrhiav-lus ♣ inurl:
    • rugged coj nplhaib inurl:
  • Fritzing yog ib qho cuab yeej zoo rau kev ua mov ci

Kauj Ruam 2: Ntiv LED

Ntiv Nplhaib LED
Ntiv Nplhaib LED

Hauv kuv daim ntawv thov, lub nplhaib LED yog lub zog ntsuas. Yog tias raspberry pi tau siv thiab ua haujlwm ces Lub Nplhaib LED yuav tsum tau taws (lossis xiav). Yog tias tsis muaj lub zog lossis raspberry pi raug kaw, ces lub nplhaib LED yuav tsum raug tua.

Ntiv nplhaib LED Kev Sib Txuas

Daim ntawv qhia zaub mov tso cai rau kuv sim nrog lub Circuit Court kom txog thaum nws ua haujlwm. Txiv neej-rau-poj niam jumper xov hlau thiab txuas cov xov hlau uas tuaj nrog cov laug cam ua cov txheej txheem no yooj yim dua. Txiv neej-rau-poj niam jumper xov hlau txuas lub khob cij rau raspberry pi.

Ob txoj kev sib txuas sab nraud ntawm Lub Nplhaib Laub khawm tswj lub Nplhaib LED. Lub davhlau ya nyob twg hauv av txuas nrog Raspberry Pi hauv av nrog 330 Ohm resistor. Hauv av yog (-). Thiab GPIO 24 yuav txuas nrog lub davhlau ya nyob twg zoo (+).

Utility software rau sej

Lub Nplhaib LED software xav tau pob rpi.gpio. Cov lus txib hauv qab no rub tawm, tsim thiab teeb tsa rpi.gpio

$ sudo ua

# apt-tau hloov tshiab # apt-tau nruab sej-pip python-dev gcc # pip nruab rpi.gpio # tawm

Tawm rov qab los rau $ sai

Ntiv LED Software

Qhib lub Nplhaib LED

$ sudo nano /usr/local/bin/power_ring_led.py

thiab kho kom raug:

#!/usr/bin/env nab hab sej

ntshuam RPi. GPIO li GPIO ntshuam subprocess ntshuam argparse parser = argparse. ArgumentParser () pab pawg = parser.add_mutually_exclusive_group () group.add_argument ("-l", "--light", ua = "store_true") group.add_argument (" -o "," --off ", action =" store_true ") # Disable ceeb toom GPIO.setwarnings (Cuav) # tig rau gpio pin 24 GPIO.setmode (GPIO. BCM) GPIO.setup (24, GPIO. OUT) args = parser.parse_args () yog args.light: GPIO.output (24, Tseeb) elif args.off: GPIO.output (24, Tsis tseeb)

Ntaus CTRL-o, CTRL-x ENTER kom txuag tau cov ntaub ntawv thiab tawm nano editor

Hloov qhov kev tso cai ntawm cov ntawv

$ sudo chmod 755 /usr/local/bin/power_ring_led.py

Tsim ib tsab ntawv pib:

$ sudo nano /etc/init.d/power_ring_led.sh

thiab kho kom raug:

#!/bin/sh

### Pib INIT INFO # Muab: scriptname # Yuav Tsum-Pib: $ remote_fs $ syslog # Yuav tsum-Nres: $ remote_fs $ syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Pib daemon ntawm lub sijhawm khau raj # Nqe lus piav qhia: Pab kev pabcuam los ntawm daemon. ### Xaus INIT INFO # Pib thiab nres power_ring_led.py # Cov npe: /etc/init.d/power_ring_led.sh # Kev tso cai: chmod 755 /etc/init.d/power_ring_led.sh # Pib lossis nres power_ring_led.py rooj " $ 1 "pib) /usr/local/bin/power_ring_led.py -teeb &;; nres) /usr/local/bin/power_ring_led.py -tawm &;; *) ncha "Siv: /etc/init.d/power_ring_led.sh {pib | nres}" tawm 1;; esac tawm

Ntaus CTRL-o, CTRL-x ENTER kom txuag tau cov ntaub ntawv thiab tawm nano editor

Hloov qhov kev tso cai ntawm cov ntawv

$ sudo chmod 755 /etc/init.d/power_ring_led.sh

Sau npe tsab ntawv kom khiav ntawm khau raj

$ sudo insserv power_ring_led.sh

Pib tsab ntawv

$ sudo /etc/init.d/power_ring_led.sh pib

Lub Nplhaib LED yuav tsum teeb!

Kauj ruam 3: Pib dua Hloov

Pib dua Hloov
Pib dua Hloov
Pib dua Hloov
Pib dua Hloov

Pib dua Hloov

Feem ntau, kuv Raspberry Pis khiav txhua lub sijhawm. Raspberry Pi 3 siv lub zog me me heev.

Qhov zoo tshaj, Kuv xav tau lub zog hloov pauv kom ruaj ntseg kaw tus pi, los ntawm kev hu sudo kaw -h 0 ua ntej txiav lub zog. Txawm li cas los xij, kev siv lub hloov hluav taws xob yog qhov nyuaj dua thiab yuav tsis tshua muaj siv.

Nov yog qhov hloov pauv pib, qhov pib, nws rov pib dua Raspberry Pi.

Solder ob tus pin rau Raspberry Pi 3

Ntawm Raspberry Pi 3, nrhiav qhov khiav qhov - saib daim duab, lub npov daj. Cov qhov khiav yog nyob ze ntawm gpio header.

Tshem tawm txhua lub xov tooj (lub zog, HDMI, ethernet, thiab lwm yam) thiab Micro SD daim npav los ntawm Raspberry Pi.

Los ntawm hauv qab ntawm pawg thawj coj saib, txuas ob lub luv luv sib cais txiv neej tus pin los ntawm Kev khiav qhov.

Txuas txhua yam rov qab ua ke thiab xyuas kom nws tseem ua haujlwm.

Txuas N01 (ib txwm qhib) ntawm lub sijhawm hloov pauv mus rau ib qho ntawm Run pins, thiab C1 mus rau lwm tus Pin txuas. NC1 (ib txwm kaw) tsis siv.

Nias lub pob, thiab lub kaw lus yuav tsum rov pib dua!

Pom zoo: