Cov txheej txheem:

Qhov Taw Qhia Tsheb kauj vab Minimalist, Kov-Enabled !: 10 Kauj Ruam (nrog Duab)
Qhov Taw Qhia Tsheb kauj vab Minimalist, Kov-Enabled !: 10 Kauj Ruam (nrog Duab)

Video: Qhov Taw Qhia Tsheb kauj vab Minimalist, Kov-Enabled !: 10 Kauj Ruam (nrog Duab)

Video: Qhov Taw Qhia Tsheb kauj vab Minimalist, Kov-Enabled !: 10 Kauj Ruam (nrog Duab)
Video: Часы G-Shock до 250 долларов-15 лучших часов Casio G до 250 доллар... 2024, Hlis ntuj nqeg
Anonim
Image
Image

Nyob zoo! Nov yog kuv thawj Phau Ntawv Qhia. Kuv ib txwm xav ua tej yam los ntawm kos tsuas yog pom nws ua haujlwm li cas thiab leej twg tsis nyiam DIY (Ua koj tus kheej) cov khoom thaum koj tuaj yeem hloov kho qee yam raws li koj xav tau txoj cai? Zoo li nthuav raws li DIY yuav suab, nws yuav siv zog me ntsis los ua kom nws tshwm sim. Saib los ntawm Lub Vev Xaib Qhia yog txoj hauv kev zoo los pib koj li DIY kev cia siab thiab yog li cas kuv pib tsim qee yam ntawm kuv cov phiaj xwm ua ntej, tab sis kuv yeej tsis xav tias kuv yuav ua ib qho.

Ib yam li lub sijhawm tau los txog kuv txoj kev, Kuv tau ua Tus Qhia Tsheb kauj vab nrog kev tsim qauv me me thiab kov tau. Kuv paub muaj ntau Cov Lus Qhia lossis cov peev txheej online rau lub ntsuas tsheb kauj vab tab sis feem ntau ntawm lawv tau siv qee qhov chaw ntxiv lossis tsis ntse txaus los hloov kho lawv hauv ib txoj hauv kev tshwj xeeb. Yog tias koj tab tom nrhiav qhov ntsuas uas ntse txaus los ua kom tiav koj cov kev xav tau thiab muab sijhawm rau koj hloov kho lawv raws li qhov koj xav tau, tom qab ntawv Cov Lus Qhia no yog rau koj!

Vim Li Cas Qhov Taw Qhia Tsheb kauj vab?

Kuv nyiam caij tsheb kauj vab ncig lub nroog! Kuv coj kuv lub voj voog thiab tsuas yog caij tsheb thaum sawv ntxov lossis yav tsaus ntuj. Qee zaum, thaum tsaus ntuj, nws nyuaj caij, vim cov tsheb tom qab koj yuav tsis tuaj yeem pom koj thiab qhov ntawd yog qhov cim txaus ntshai. Tias yog vim li cas kuv thiaj xav tsim Qhov Ntsuas Kuv tus kheej nrog txhua cov ntaub ntawv uas kuv muaj nrog kuv nyob hauv tsev thiab kuj zoo nkaus li zoo ntawm lub tsheb kauj vab thaum koj caij tsheb hauv nroog tig cov ntsuas ntsuas ON!

Ua ib qhov haujlwm yam tsis tau ntsib teeb meem, tsis tshwm sim! Tab sis kuv yuav qhia koj txhua qhov kev ua yuam kev uas kuv tau ua, thaum tsim qhov no, raws li "Cov Lus Qhia Zoo" kom koj tsis txhob sim ua lawv. Cov vis dis aus YouTube muaj Cov Lus Qhia ntawm yuav ua li cas peb tes num tau tsim, cov duab me me los qhia seb yam khoom ua haujlwm li cas, thiab qhov ntsuas pom zoo li cas ntawm txoj kev! Cov ntaub ntawv ntau ntxiv tau muab rau hauv Cov Lus Qhia no. Raws li koj ua txuas mus Kuv yuav cim tag ntu ntawm kuv cov vis dis aus hauv youtube li "Ncua Sijhawm:" ntawm txhua kauj ruam rau koj saib seb cov khoom ua haujlwm li cas. Koj tuaj yeem tau txais cov ntaub ntawv ntau ntxiv los ntawm txhaj rau cov kab ntawv txuas uas tau muab.

Nta ntawm txoj haujlwm no:

  • Txoj Cai Taw Qhia
  • Sab laug Qhia Taw Qhia
  • Qhov Pom Pom Pom Hmo Ntuj
  • Kov-Qhib

Kauj Ruam 1: Cov Khoom Siv Kom Pib

Xeem Cheeb Tsam
Xeem Cheeb Tsam
  • Resistors (330 ohms thiab 120 ohms): 330 ohms thiab 120 ohm
  • Raspberry Pi 3: RPi 3
  • Breadboard: Breadboard
  • Jumper Wires (Txiv neej-Txiv neej, Txiv neej-Poj Niam, Poj Niam-Poj Niam): Jumper Wires
  • Multi-Strand Wire: Multi-Strand Wire
  • Capacitive Touch Sensor (TTP223) - (2): Txuas
  • RGB LEDs (Hom Cathode Hom) - (13): RGB LED Common Cathode
  • LEDs ib txwm - (2): LED
  • Cov Khoom Siv Soldering: Cov Khoom Siv Soldering
  • Perf Boards: Perf Board
  • Powerbank: Powerbank
  • 1 micro Farad Electrolytic Capacitor: Electrolytic Capacitor
  • LDR (Lub Teeb Pom Kev Tiv Thaiv): LDR
  • Cable Ties: Cable Ties
  • Cable Concealer: Cable Concealer
  • Acrylic Xim thiab Txhuam (Yeem Xaiv): Xim thiab Txhuam
  • Ob lub thawv rau khoom los ua ke. (1 Loj thiab 1 nruab nrab qhov loj me)

Ib txwm khaws ntau ntxiv raws li tau hais los saum no. Kuv tau txuas cov khoom siv ntawm Amazon thiab qee qhov khoom siv yuav khoom zoo tshaj plaws rau cov khoom siv txhuam!

Sijhawm: Sau Cov Khoom

Kauj Ruam 2: Xeem Cheeb Tsam

Xeem Cheeb Tsam
Xeem Cheeb Tsam
Xeem Cheeb Tsam
Xeem Cheeb Tsam
Xeem Cheeb Tsam
Xeem Cheeb Tsam

Cia peb muab koj cov khoom sib tw sim! Qhov no yog qhov muaj txiaj ntsig tiag tiag txhawm rau cais cov khoom uas puas los yog ua rau coj txawv txawv rau qee qhov laj thawj thiab qib no tseem cia koj tau txais thawj qhov kev paub Ua Haujlwm nrog cov khoom thiab ua me ntsis kev kawm ua ntej mus rau kev tsim kho tag nrho txoj haujlwm.

Kuaj rau hom RGB LED

Muaj ob hom RGB LEDs peb pom hauv khw. Hom cathode ntau thiab hom anode ntau.

Nov yog cov lus qhia tau yooj yim (txawm hais tias loj dua) vim tias kuv txuas cov LEDs zoo li pom los ntawm cov vis dis aus no thiab LED tsis tau teeb raws li qhov xav tau txawm tias tom qab hla kev txheeb xyuas qhov Circuit ob peb zaug. Tom qab ntawd kuv pom tau tias muaj ob hom LED no thiab dhau los ntawm cov ntaub ntawv Kuv thaum kawg tau txais kev daws teeb meem! Qhov teeb meem nrog kuv cov kab hluav taws xob yog cov cathode tus pin txuas nrog 3.3V raws li tau hais tseg thiab kuv tau khaws los ntawm GPIO tus pin mus rau HIGH yog li ob qho tib si cathode tus pin thiab lwm 3 tus pin tau nyob ntawm qhov muaj peev xwm zoo ib yam.

Tshuaj: Kuv txuas tus pin cathode ib txwm rau hauv av thiab LED teeb! Qhov laj thawj kuv tsis hloov kuv tus lej kom khaws GPIO pins LOW vim tias peb yuav siv LEDs ntau dua tom qab thiab RPi muab rau peb tsuas yog ob tus pin ntawm 3.3 V uas peb xav tau nws rau lwm lub hom phiaj ib yam nkaus!

Yuav kuaj li cas?

Khaws lub multimeter nyob rau hauv hom txuas mus. Khawm qhov ntev tshaj plaws nrog cov lus liab liab ntawm lub multimeter thiab nrog cov lus qhia dub, coj mus rhaub ib qho ntawm lwm qhov kev coj ua. Yog hais tias lub teeb ci LED los ntawm kev ua cov kauj ruam saum toj no, nws yog Hom Anode RGB LED. Yog nws tsis yog, thim rov qab cov lus qhia multimeter tam sim no. Coj mus rhaub cov hlau lead ntev tshaj plaws nrog cov lus qhia dub thiab cov lus qhia liab nrog rau lwm txoj hauv kev.

Cov lus qhia yooj yim: Kuv tau siv Hom Cathode Common hauv txoj haujlwm no. Sim ua cov hom no nkaus xwb tab sis txawm tias lwm hom muaj nyob tsis txhob txhawj. Cov kev sib txuas hauv Circuit tseem nyob zoo ib yam, qhov sib txawv tsuas yog yuav tsum tau ua hauv cov cai uas kuv yuav muab los ua ib qho lus pom tom ntej ntawm kab lus tseeb qhov twg koj yuav tsum hloov pauv. Ua pa.

Sijhawm: Xeem RGB

Siv: Yuav ntsuas RGB li cas

RGB LED teeb tuaj

Txhawm rau ua qhov no, txheeb xyuas daim duab sib txuas uas tau muab hauv cov duab saum toj no thiab txuas raws li tus pin los ntawm lub khob cij (kom nws muaj kev nyab xeeb pib nrog).

Liab: Pin 11 (330-ohm resistor)

GREEN: Pin 13 (120-ohm resistor)

XEEB: Pin 15 (120-ohm resistor)

Tus nqi tiv thaiv sib txawv sib txawv vim qhov sib txawv rau pem hauv ntej qhov hluav taws xob ntawm cov coj.

Thaum koj tau txuas nrog lawv kom raug, sau tus lej RPi hauv nws tus nab npawb nab nab IDE.

ntshuam RPi. GPIO ua GPIO

#Tus lej tus lej sib raug rau tus lej tseeb ntawm RPi GPIO Red_pin = 11 Green_pin = 13 Blue_pin = 15 #Connect Common cathode pin rau Pin 6 def turnOn (tus pin): GPIO.setmode (GPIO. BOARD) GPIO.setup (tus pin, GPIO. OUT) GPIO.output (tus pin, GPIO. HIGH) #GPIO.output (tus pin, GPIO. LOW) rau hom anode hom def turnOff (tus pin): GPIO.setmode (GPIO. BOARD) GPIO.setup (tus pin, GPIO. Tawm) GPIO.output (tus pin, GPIO. LOW) #GPIO.output (tus pin, GPIO. HIGH) def redOn (): turnOn (Red_pin) def redOff (): turnOff (Red_pin) def greenOn (): turnOn (Green_pin) def ntsuabOff (): turnOff (Green_pin) def blueOn (): turnOn (Blue_pin) def blueOff (): turnOff (Blue_pin) sim: thaum muaj tseeb: cmd = input ("Ntaus koj cov lus txib:") yog cmd == "liab rau ": #type cov lus txib hais raws nraim hauv" "redOn () elif cmd ==" red off ": redOff () elif cmd ==" green on ": greenOn () elif cmd ==" green off ": greenOff () elif cmd == "blue on": blueOn () elif cmd == "blue off": blueOff () else: print ("Not a valid command") except KeyboardInterrupt: GPIO.cleanup ()

Kuv xa mus rau Tus Kws Qhia Ntawv no, txheeb xyuas qhov no kom ntxaws ntxaws thiab cov cai!

Siv tib txoj cai saum toj no koj tuaj yeem tshawb xyuas ntau lub LEDs ua ke los ntawm kev txuas lawv ua ke ntawm lub khob cij thiab tshem tawm ib qho taw tes los ntawm ib qho ntawm cov pins txuas ua ke. Siv qhov ntsuas qhov sib txawv sib txawv rau txhua tus pin txhawm rau txheeb xyuas qhov ci ntawm koj cov LEDs

Cov lus qhia yooj yim: Nco ntsoov tias koj txuas tib tus pin-type parallel. Ntawd yog, tus pin liab ntawm ib qho LED txuas rau tus pin liab ntawm lwm LED nkaus xwb.

Sijhawm: Ua rau lawv ci!

Kev ntsuas TouchPad

Kev sib txuas ntawm Circuit yog raws li qhia ntawm no (Ncua Sijhawm). Txuas lawv raws li qhia thiab sim koj cov touchpads siv cov cai hauv qab no.

Txoj Cai:

ntshuam RPi. GPIO ua GPIO

los ntawm lub sijhawm ntshuam pw GPIO.setmode (IO. BOARD) touchpad1 = 11 #pin 11 touchpad2 = 13 #pin 13 GPIO.setup (touchpad1, GPIO. IN) GPIO.setup (touchpad2, GPIO. IN) #Peb tuaj yeem koom ua ke ob qho tib si cov lus saum toj no ua ke ua # GPIO.setup ([touchpad1, touchpad2], GPIO. IN) sim: thaum Tseeb: yog (GPIO.input (touchpad1) == Muaj tseeb): luam tawm ("Touchpad 1 kov") pw (2) elif (GPIO.input (touchpad2) == Muaj tseeb): luam tawm ("Touchpad 2 kov") pw (2) lwm yam: luam tawm ("Tsis Touched") tsuas yog KeyboardInterrupt: GPIO.cleanup () #CTRL-C kom tawm mus

Kuaj ib qho LED

Xa mus rau qhov kev qhia txaus rau kev sim koj li LED!

Thaum koj tau sim tag nrho cov khoom siv saum toj no koj tau npaj los tsim qhov loj dua ntawm nws.

Kauj Ruam 3: Soldering Qhov Taw Qhia Vaj Huam Sib Luag

Soldering Qhov Taw Qhia Vaj Huam Sib Luag
Soldering Qhov Taw Qhia Vaj Huam Sib Luag
Soldering Qhov Taw Qhia Vaj Huam Sib Luag
Soldering Qhov Taw Qhia Vaj Huam Sib Luag
Soldering Qhov Taw Qhia Vaj Huam Sib Luag
Soldering Qhov Taw Qhia Vaj Huam Sib Luag

Yog tias koj yog tus tshiab los txheeb xyuas qhov kev qhia no kom paub qee qhov pib ntawm nws ntawm no (Yuav Siv Li Cas) Yog tias koj yog tus kws tshaj lij ntawm kev siv tshuaj tua kab, qhia rau peb pib!

Qhov Taw Qhia Vaj Huam Sib Luag

Koj tuaj yeem pom Cov Lus Qhia ntawm yuav ua li cas muab lawv tso rau ntawm daim txiag ntoo hauv cov duab saum toj no.

Peb siv 13 RGB LEDs rau lub vaj huam sib luag. Cais lawv mus rau peb ntu: sab laug, sab xis, thiab nruab nrab rau qhov sib dhos kom haum.

Tseem ceeb: Sib nrug ntawm cov LEDs

Kuv tau tshuav 3 kab ntawm LEDs. Raws li qhia hauv daim duab thib ob Qhov no yog qhov tseem ceeb rau LED vaj huam sib luag kom pom thiab hnov zoo. Peb tsis xav kom LEDs nyob deb dhau los ua kom muaj chaw seem lossis nyob ze dhau kom tsis tuaj yeem paub qhov txawv ntawm lub teeb pom kev deb.

Cov lus qhia yooj yim: Pib los ntawm kev siv tag nrho cov Cathode Pins ua ntej

Cov Lus Qhia Ua Tau Zoo: Siv Multi-Strand Wires rau txuas cov LEDs ua ke vim lawv tsis khov thiab yooj yim khoov. Koj tuaj yeem siv tus pin txiav tawm ntxiv los ntawm LEDs los txuas qhov kev ncua luv

Txoj Cai Tshooj: (5 LEDs)

  • Txuas tag nrho Red Pins ua ke
  • Txuas tag nrho Green Pins ua ke
  • Txuas tag nrho Cov Cathode Pins ua ke

Sab laug: (5 LEDs)

  • Txuas tag nrho Red Pins ua ke
  • Txuas tag nrho Green Pins ua ke
  • Txuas tag nrho Cov Cathode Pins ua ke

Chaw Chaw: (3 LEDs)

Cov lus qhia yooj yim: Nqe no yuav tsum tau ceev faj txaus. Tsis txhob txhuam txhua tus koob ua ke li peb tau ua hauv ob seem saum toj no!

  • Txuas tag nrho Red Pins ua ke
  • Txuas tsuas yog sab saum toj thiab hauv qab LED's, Green Pin.
  • Txuas tag nrho Cov Cathode Pins ua ke

Hlau

Peb xav tau cov xov hlau ntev los txuas lub vaj huam sib luag mus rau GPIO pawg thawj coj.

Cov lus qhia yooj yim:

  • Siv cov xov hlau ib leeg! Lawv muaj zog txaus kom tiv taus cov kev nyuab siab uas siv rau nws!
  • Khaws cov xov hlau me ntsis ntev dua qhov ntev xav tau ntawm lub vaj huam sib luag thiab RPi (qhov no yooj yim heev thaum tswj cov xov hlau tom qab! (Sijhawm: Ntsuas)
  • Insulate tom qab soldering! Tseem ceeb heev

Siv lub xov hlau jumper thiab ib txoj hlua hlau los txuas. Lub jumper hlau qhov kawg yuav tsum yog tus poj niam txuas. Muag lawv raws li qhia ntawm no (Ncua Sijhawm)

Xim xim cov xov hlau raws li Liab, Ntsuab, thiab Dub. uas sib raug rau Red pin, Green pin, thiab Common cathode pin feem.

Peb xav tau 3 Cov xov hlau dub, 3 Cov Hluav Taws Xob liab, thiab 3 Cov Hluav Taws Xob Ntsuab.

Thaum cov xov hlau tau npaj txhij. Muab cov xov hlau tso rau qhov taw qhia LEDs.

Cov tswv yim pab tau:

  • Xyuas kom tseeb tias cov LEDs tau muag raws li qhov sib txuas tau muab.
  • Nco ntsoov tias koj tau muab cov tshuaj tiv thaiv qhov raug qhov tseeb tso rau hauv qhov chaw. Yog tias qhov txiaj ntsig tau hloov pauv, nws yuav cuam tshuam qhov ci ntawm LEDs
  • Ib txoj hauv kev kom paub tseeb tias txhua yam koj li LEDs ua haujlwm yog siv lub ntsuas ntsuas ntsuas hauv qib 2. Qhov no yooj yim heev vim koj yuav paub yog tias muaj ib qho luv Circuit Court LEDs yuav tsis pom kev.
  • Tsis txhob hle qhov xaus ntawm cov xov hlau ntev dua qhov xav tau. Qhov no yuav nyuaj kom lawv nyob hauv qhov chaw thiab tseem muaj kev pheej hmoo siab ntawm kev luv luv.
  • Siv ntau txoj hlua hlau txuas rau ntawm LEDs.
  • Siv cov hlua ib leeg rau txuas cov ntu rau RPi.

Kauj Ruam 4: Muab Qhov Ntsuas Qhov Ntsuas rau Qhov Kuaj

Muab Qhov Ntsuas Qhov Ntsuas los Ntsuas
Muab Qhov Ntsuas Qhov Ntsuas los Ntsuas
Muab Qhov Ntsuas Qhov Ntsuas Ntsuas rau Qhov Kuaj
Muab Qhov Ntsuas Qhov Ntsuas Ntsuas rau Qhov Kuaj
Muab Qhov Ntsuas Qhov Ntsuas los Ntsuas
Muab Qhov Ntsuas Qhov Ntsuas los Ntsuas

Ua tsaug! Yog tias koj tau siv lub vaj huam sib luag kom raug. Cia peb ua mus ntxiv nrog coding Qhov Taw Qhia tam sim no!

Raws li tau hais ua ntej peb yuav qhia txoj kev lem sab xis, sab laug, thiab qhib/kaw qhov pom hmo ntuj.

Xa mus rau qhov kev sib txuas ntawm Circuit hauv Kauj Ruam 3.

Txuas cov xov hlau ntawm lub vaj huam sib luag raws li tau hais hauv qab no:

  • Liab Txoj Cai - Tus Pin 7
  • Ntsuab Txoj Cai - Pin 11
  • Hom Cathode Txoj Cai - Pin 6 (GND)
  • Liab sab laug - Tus Pin 13
  • Ntsuab sab laug - Tus Pin 15
  • Hom Cathode Sab laug - Tus Pin 9 (GND)
  • Center Liab - Tus Pin 16
  • Chaw Ntsuab (saum thiab hauv qab) - Tus Pin 18
  • Center Common Cathode - Tus Pin 14 (GND)

Txoj Cai Xeem:

ntshuam RPi. GPIO ua GPIO

los ntawm lub sijhawm ntshuam pw #Connect raws li tus lej hauv qab tus lej Red_right = 7 Green_right = 11 Red_left = 13 Green_left = 15 Red_center = 16 Green_top_bottom = 18 GPIO.setmode (GPIO. BOARD) def right_turn (): print ("Tig Txoj Cai") ntsais muag (Green_right, Green_top_bottom, 0) def left_turn (): print ("Turn Left)" blink (Green_left, Green_top_bottom, 0) def blink (pin1, pin2, pin3): if (pin3 == 0): GPIO.setup ([pin1, pin2], GPIO. OUT) rau x hauv kab (10): GPIO.output ([pin1, pin2], GPIO. HIGH) pw (0.5) GPIO.output ([pin1, pin2], GPIO. LOW) pw (0.5) lwm qhov: GPIO.setup ([pin1, pin2, pin3], GPIO. OUT) rau x hauv ntau (10): GPIO.output ([pin1, pin2, pin3], GPIO. HIGH) pw (0.5) GPIO.output ([pin1, pin2, pin3], GPIO. LOW) pw (0.5) def night_sight (): print ("Hmo Hmo Pom Kev") ntsais (Red_left, Red_right, Red_center) sim: thaum Tseeb: cmd = input (" Kuaj LED rau: ") yog cmd ==" tig sab xis ": sab xis_turn () elif cmd ==" sab laug ": sab laug_turn () elif cmd ==" pom hmo ntuj ": hmo ntuj pom () lwm yam: luam tawm (" Hais kom tsis raug ") except Kev yboardInterrupt: GPIO.cleanup ()

Yog tias koj lub vaj huam sib luag tshem tawm txhua qhov kev xeem theem raws li hauv txoj cai, Ua tau zoo! Npaj rau qib tom ntej

Yog tias lub vaj huam sib luag tsis pom kev, nco ntsoov tias koj tau ua raws txhua cov kauj ruam raug thiab saib los ntawm cov lus qhia yooj yim ua ntej. Yog tias qhov teeb meem tseem muaj ntxiv koj tuaj yeem tawm tswv yim hauv qab no, Kuv yuav npaj los pab.

Lub Sijhawm: Kuaj Ib (Txheeb xyuas cov vis dis aus rau tsab ntawv ua haujlwm)

Kauj Ruam 5: Kev Sib Txuas Qhov Ntsuas Qhov Ntsuas Nrog Lub Touchpad

Kev koom ua ke Qhov Ntsuas Qhov Ntsuas Nrog Touchpad
Kev koom ua ke Qhov Ntsuas Qhov Ntsuas Nrog Touchpad
Kev koom ua ke Qhov Ntsuas Qhov Ntsuas Nrog Touchpad
Kev koom ua ke Qhov Ntsuas Qhov Ntsuas Nrog Touchpad
Kev koom ua ke Qhov Ntsuas Qhov Ntsuas Nrog Touchpad
Kev koom ua ke Qhov Ntsuas Qhov Ntsuas Nrog Touchpad

Txuas nws rau RPi

Ua cov kev sib txuas raws li qhia hauv daim duab saum toj no.

Txoj Cai Vaj Huam Sib Luag

Touchpad:

  • GND pin - Pin 34
  • VCC pin - Pin 1
  • SIG pin - Pin 29

LED:

Anode (+) tus pin - Tus pin 33

Sab laug Vaj Huam Sib Luag

Touchpad:

  • GND pin - Pin 30
  • VCC pin - Pin 17
  • SIG pin - Pin 31

LED:

Anode (+) tus pin - Tus pin 35

Hom GND: Tus Pin 39 (Rau ob qho tib si cathode ntawm LEDs) - Cov Khoom Siv Hauv Ntiaj Teb (Sijhawm)

Txoj Cai Xeem:

ntshuam RPi. GPIO ua GPIO

los ntawm lub sijhawm ntshuam pw Red_right = 7 Green_right = 11 Red_left = 13 Green_left = 15 Red_center = 16 Green_top_bottom = 18 right_touch = 29 left_touch = 31 right_led = 33 left_led = 35 triggered = 0 GPIO.setmode (GPIO. BOARD) GPIO.setup ([right_led, left_led], GPIO. OUT) GPIO.setup (right_touch, GPIO. IN, pull_up_down = GPIO. PUD_UP) GPIO.setup (left_touch, GPIO. IN, pull_up_down = GPIO. PUD_UP) def right_turn (channel): GPIO.output (right_led, GPIO. HIGH) thoob ntiaj teb ua rau tshwm sim = 1 luam tawm ("Tig Txoj Cai") ntsais muag (Green_right, Green_top_bottom) def sab laug_turn (channel): GPIO.output (left_led, GPIO. HIGH) thoob ntiaj teb tau txhais ua rau = 1 luam ("Tig Sab laug ") ntsais (Green_left, Green_top_bottom) GPIO.add_event_detect (right_touch, GPIO. FALLING, callback = right_turn, bouncetime = 500) GPIO.add_event_detect (left_touch, GPIO. FALLING, callback = left_turn, bouncetime = 500) pin2): GPIO.setup ([pin1, pin2], GPIO. OUT) rau x hauv ntau (10): GPIO.output ([pin1, pin2], GPIO. HIGH) pw (0.5) GPIO.outpu t ([pin1, pin2], GPIO. LOW) pw tsaug zog (0.5) GPIO.output ([right_led, left_led], GPIO. LOW) thoob ntiaj teb ua rau tshwm sim = 0 def night_sight (): thaum (Muaj tseeb): GPIO.setup ([Red_center, Red_left, Red_right], GPIO. OUT) thoob ntiaj teb ua rau yog (ua rau == 0): luam tawm ("Hmo Hmo Pom Kev") GPIO.output ([Red_center, Red_left, Red_right], GPIO. HIGH) pw (0.27) GPIO.output ([Red_center, Red_left, Red_right], GPIO. LOW) tsaug zog (0.27) lwm yam: luam tawm ("Hmo Hmo Pom Kev") GPIO.output ([Red_center, Red_left, Red_right], GPIO. LOW) sim: hmo ntuj () tshwj tsis yog KeyboardInterrupt: GPIO.cleanup ()

Kov lub touchpad kom pom koj lub teeb ci

Lub Sijhawm (tsis suav nrog LED): Xeem Ob

Lub Sijhawm Teev Taw (nrog Qhov Taw Qhia LED): Xeem 3

Kev piav qhia txoj cai: Peb xav kom hmo ntuj pom kev ua haujlwm tsis tu ncua thiab thaum peb kov lub touchpad nws yuav tsum nres thiab ua haujlwm ntawm lub touchpad. Txhawm rau ua qhov no ib txhij peb siv qee yam hu ua "cuam tshuam" hauv nab hab sej. Qhov no tso cai rau peb los khiav peb cov cai ib txwm uas yog hmo ntuj pom ntawm no thiab tseem ua rau muaj kev tshwm sim thaum pom qhov kov. Peb siv qhov ntsuas sib txawv raws li tus chij kom nres qhov pom hmo ntuj.

Yog xav paub ntxiv txog Kev cuam tshuam, txheeb xyuas qhov txuas no.

Solder Vaj Huam Sib Luag

Tam sim no cia peb xaub cov touchpad panels uas yuav mus rau tus tuav ntawm lub tsheb kauj vab. Xa mus rau kev sib txuas raws li tau hais hauv daim duab saum toj no.

Tam sim no koj tau sim koj li LED thiab lub touchpad, koj zoo mus. Yog tias koj tsis tau sim dua thov xa mus rau Kauj Ruam no thiab Cov Kauj Ruam dhau los.

Muab lub touchpad ze rau ntawm tus tuav tes raws li qhia hauv video. Ntawd yog, rau sab xis touchpad lub touchpad nyob ntawm sab xis thiab sab laug mus rau nws sab laug. Ib yam li ntawd, rau sab laug touchpad, coj yog ntawm sab xis thiab touchpad ntawm sab laug uas ua rau nws yooj yim dua rau tus ntiv tes xoo.

PS: Kuv tsis tau siv lub touchpad rau ntawm lub rooj tsav tsheb vim kuv yuav rov siv dua. Yog li kuv tsuas yog muab nws tso rau ntawm lub vaj huam sib luag nrog daim kab xev ob tog.

Txuas lub vaj huam sib luag rau RPi siv cov xov hlau ntev dua

Kauj Ruam 6: Ua Nws Ntse

Ua Nws Ntse!
Ua Nws Ntse!
Ua Nws Ntse!
Ua Nws Ntse!
Ua Nws Ntse!
Ua Nws Ntse!

Yog! Tam sim no peb muaj tag nrho peb qhov tseem ceeb ntawm Qhov Taw Qhia thiab ua haujlwm. Cia peb ua nws ib kauj ruam ntxiv kom nws ntse.

Ntawm no ntse piav qhia txuag nyiaj ntawm lub roj teeb ib yam. Raws li koj yuav tau pom thaum pom hmo ntuj ib txwm qhib thiab qee zaum qhov no yuav tsis xav tau nyob rau hnub ci tshav ntuj. Txhawm rau kov yeej qhov teeb meem no cia sib koom ua ke LDR (Lub Teeb Pom Kev Tiv Thaiv) kom muab peb cov ntaub ntawv ntawm kev siv lub teeb uas peb tuaj yeem sau thiab ua cov txheej txheem qhia peb raws li.

Xeem LDR

Kuv xa mus rau lub vev xaib no txhawm rau ntsuas LDR txhawm rau tshuaj xyuas lub teeb pom kev thiab qhov txiaj ntsig nws rov qab los li cas.

Xa mus rau lub vev xaib uas muaj npe saum toj no rau hauv Circuit Court thiab tus lej qauv rau kev ua haujlwm ntawm LDR.

Kev koom ua ke LDR rau peb cov cai

Solder LDR rau sab xis ntawm lub touchpad raws li qhia hauv daim duab txuas saum toj no.

Tom qab muab cov koob tso rau hauv qhov chaw raug nws lub sijhawm rau qhov kawg ntawm qhov coding. Txoj cai kawg!

  • Txuas lub ntsiab lus ntawm Cathode (-) ntawm lub capacitor thiab LDR rau Pin 36 ntawm RPi
  • Cov anode ntawm lub tshuab hluav taws xob txuas nrog rau Lub hauv paus ntsiab lus uas tau hais hauv qib 5

Txoj Cai Kawg:

ntshuam RPi. GPIO ua GPIO

los ntawm lub sijhawm ntshuam pw Red_right = 7 Green_right = 11 Red_left = 13 Green_left = 15 Red_center = 16 Green_top_bottom = 18 right_touch = 29 left_touch = 31 right_led = 33 left_led = 35 ldr = 36 triggered = 0 GPIO.setmode (GPIO. BOARD) GPIO. teeb ([right_led, left_led], GPIO. OUT) GPIO.setup (right_touch, GPIO. IN, pull_up_down = GPIO. PUD_UP) GPIO.setup (left_touch, GPIO. IN, pull_up_down = GPIO. PUD_UP) def right_turn (channel): GPIO.output (right_led, GPIO. HIGH) thoob ntiaj teb triggered triggered = 1 luam ("Tig Txoj Cai") ntsais (Green_right, Green_top_bottom) def left_turn (channel): GPIO.output (left_led, GPIO. HIGH) thoob ntiaj teb triggered triggered = 1 print ("Tig Rov Qab") ntsais (Green_left, Green_top_bottom) GPIO.add_event_detect (right_touch, GPIO. FALLING, callback = right_turn, bouncetime = 500) GPIO.add_event_detect (left_touch, GPIO. FALLING, hu rov qab = sab laug_turn), (ldr): suav = 0 #Output ntawm tus pin rau GPIO.setup (ldr, GPIO. OUT) GPIO.output (ldr, GPIO. LOW) pw (0.1) #Chang e tus pin rov qab los nkag GPIO.setup (ldr, GPIO. IN) #Count kom txog thaum tus pin nce siab thaum (GPIO.input (ldr) == GPIO. LOW): suav += 1 rov suav suav def blink (pin1, pin2): GPIO.setup ([pin1, pin2], GPIO. OUT) rau x hauv thaj tsam (10): GPIO.output ([pin1, pin2], GPIO. HIGH) pw (0.5) GPIO.output ([pin1, pin2], GPIO. LOW) pw tsaug zog (0.5) GPIO.output ([right_led, left_led], GPIO. LOW) thoob ntiaj teb tau ua rau pom = 0 def hmo ntuj pom (): thaum (Muaj tseeb): GPIO.setup ([Red_center, Red_left, Red_right], GPIO. OUT) thoob ntiaj teb ua rau yog (lub teeb_sensing (ldr)> 7800): yog (ua rau == 0): luam tawm ("Hmo Pom Kev") GPIO.output ([Red_center, Red_left, Red_right], GPIO. HIGH) pw (0.27) GPIO.output ([Red_center, Red_left, Red_right], GPIO. LOW) tsaug zog (0.27) lwm yam: luam tawm ("Hmo Hmo Pom Kev") GPIO.output ([Red_center, Red_left, Red_right], GPIO. LOW) sim: night_sight () tshwj tsis yog KeyboardInterrupt: GPIO.cleanup ()

Voila! Thiab qhov ntsuas tau npaj txhij rau yob.

Cov Lus Qhia Ua Ntej: Ua ntej sib sau ua ke RPi thiab lwm yam khoom siv rau hauv lub voj voog kom ntseeg tau tias koj sim qhov program no kom raug! Khiav nws ob peb zaug kom debug ib qho yuam kev.

Kauj Ruam 7: Kev pleev xim thiab sib dhos

Painting thiab los ua ke
Painting thiab los ua ke
Painting thiab los ua ke
Painting thiab los ua ke
Painting thiab los ua ke
Painting thiab los ua ke

Cov Ntaub Ntawv Yuav Tsum Tau:

  • Hlau Txiav/ Txiav Cov Cuab Yeej
  • Ib lub thawv ntim khoom loj kom haum rau Raspberry Pi
  • Ib lub thawv me me kom haum rau qhov ntsuas vaj huam sib luag
  • Xim
  • Xim Txhuam

Pib los ntawm kev pleev xim Qhov Ntsuas Qhov Ntsuas thiab cov touchpad panels nrog xim dub. Kuv siv Acrylic Paints ntawm no koj tuaj yeem siv lawv ntawm qhov koj xaiv uas sib xyaw zoo nrog cov laug cam. Siv cov keeb kwm yav dhau dub kom thiaj ua rau lub vaj huam sib luag LED muaj zog thiab sawv tawm ntau dua. Ua lub qhov siv cua sov ntswj ntsia hlau lossis siv cov khoom hlau los yaj cov yas.

Nco tseg: Thov ceev faj thaum ua qhov.

Sijhawm: Xim

Cov lus qhia yooj yim: Kuv siv lub thawv yas thiab cov xim tuaj tawm yooj yim. Xyuas kom koj siv cov xim zoo zoo

Thaum Qhov Ntsuas thiab cov vaj huam sib luag tau pleev xim kom qhuav tawm hauv lub hnub thiab npaj rau kev sib sau ua ke.

Kuv tau txiav cov npoo ntxiv ntawm daim txiag ntoo nyob hauv Qhov Ntsuas Qhov Ntsuas thiab lub vaj huam sib luag pem hauv ntej kom txuag chaw.

Txheeb cov vis dis aus rau kev sib dhos!

Sijhawm: Avengers! Sib sau ua ke. (Sib sau ua ke lub ntsuas vaj huam sib luag thiab RPi nrog lub thawv)

Raws li pom hauv daim vis dis aus tso cov xov hlau raws li los ntawm kev ua peb qhov nyob hauv lub thawv loj. Ib qho rau RPi lub txhab nyiaj hluav taws xob xaim, ib qho rau lub touchpad vaj huam sib luag, thiab ib qho rau Qhov Ntsuas Qhov Ntsuas. Tsuas yog ib lub qhov xav tau rau lub thawv me me.

Cov lus qhia yooj yim: Txheeb xyuas cov rwb thaiv tsev ntawm cov xov hlau thiab xyuas seb cov xov hlau puas tau muag kom zoo ua ntej txuas rau hauv lub thawv.

Kauj Ruam 8: Kev Xeem Chaw Nrog VNC thiab Txoj Cai Kawg

Kev Xeem Chaw Nyob Nrog VNC thiab Txoj Cai Kawg
Kev Xeem Chaw Nyob Nrog VNC thiab Txoj Cai Kawg
Kev Xeem Chaw Nyob Nrog VNC thiab Txoj Cai Kawg
Kev Xeem Chaw Nyob Nrog VNC thiab Txoj Cai Kawg

Ib qho kev xeem zaum kawg ua ntej ntsuas ntsuas tau npaj txhij. Txuas koj RPi rau VNC Viewer thiab khiav qhov program.

Kuv ib txwm siv VNC server los khiav qhov haujlwm thiab debug ib qho tsis raug hauv qhov program. Txoj kev no kuv tuaj yeem tso RPi ncaj qha rau qhov chaw uas kuv xav sim yam tsis txuas lub saib sab nraud.

Txheeb nplooj ntawv no txhawm rau txuas koj li RPi rau VNC Server. (VNC neeg rau zaub mov)

Thaum koj tau txuas RPi rau VNC Server. Koj tuaj yeem khiav cov cai ntawm lub desktop virtual thiab debug qhov tsis raug.

Sijhawm: Khiav ntawm Kev Pib

Cov Lus Qhia Yooj Yim: Thaum koj tau txuas koj li Raspberry Pi rau lub khoos phis tawj virtual koj yuav kos npe nrog IP Chaw Nyob ntawm RPi. Tab sis yog tias koj tau txais qhov yuam kev hais tias RPi tsis kam txuas, nws yog vim qhov IP chaw nyob hloov pauv hauv RPI. Qhov no tuaj yeem tshwm sim thaum koj rov pib dua koj lub router lossis WiFi hotspot thiab tom qab ntawd sim nkag mus nrog tus qub chaw nyob. Tus router muab tus IP tshiab txhua lub sijhawm koj rov pib dua, tab sis yog tias koj nco qab tus IP qub ntawm RPi tsuas yog nce tus lej kawg los ntawm 1 thiab nkag mus. Piv txwv: Yog tus IP qub qub yog 190.148.1.100 ces nkag mus siv 190.148.1.101

Thaum koj tau txheeb xyuas yog tias txhua yam ua haujlwm tau zoo nws yog lub sijhawm rau kev sib dhos zaum kawg.

Ib txwm peb tsis tuaj yeem muaj lub khoos phis tawj virtual los tshuaj xyuas lossis khiav cov ntawv nab nab. Yog li cia peb ua qhov ntawd thaum pib.

Peb xav kom peb txoj haujlwm khiav ib zaug RPi khau raj. Txheeb xyuas lub vev xaib no kom paub meej ntxiv txog qhov no!

Yog tias koj RPi nyob ntawm Auto-login teeb tsa, tom qab ntawd txuas ntxiv mus;

Khiav cov lus txib hauv qab no hauv lub davhlau ya nyob twg ntawm RPi

sudo nano /thiab /profile

Scroll rau hauv qab thiab ntxiv kab hauv qab no:

sudo nab hab sej file_path &

File_path ntawm no hais txog txoj hauv kev ntawm cov ntaub ntawv nab hab sej qhov twg koj cov lej kawg tau khaws cia.

Nco tseg: Ampersand (&) tom kawg ntawm cov ntawv yuav tsum tau ntxiv kom koj txoj haujlwm khiav mus rau qhov system khau raj. Vim tias peb cov phiaj xwm muaj lub voj tsis muaj qhov kawg, cov kauj ruam no yog qhov yuav tsum tau txhawm rau txawm tias qhov haujlwm tsis ua haujlwm raws li qhov xav tau peb tseem tuaj yeem siv RPi desktop los hloov chaw.

Tom qab no nias CTRL-X thiab tom qab ntawd YPress Nkag mus ob zaug thiab koj yuav rov qab mus rau qhov hais kom ua davhlau ya nyob twg.

Reboot Pi

Tam sim no tus lej yuav tsum khiav thaum pib

Kauj Ruam 9: Kev Tswj Cable thiab Kev Sib Ntsib zaum kawg

Kev Tswj Cable thiab Kev Sib Ntsib zaum kawg
Kev Tswj Cable thiab Kev Sib Ntsib zaum kawg
Kev Tswj Cable thiab Kev Sib Ntsib zaum kawg
Kev Tswj Cable thiab Kev Sib Ntsib zaum kawg
Kev Tswj Cable thiab Kev Sib Ntsib zaum kawg
Kev Tswj Cable thiab Kev Sib Ntsib zaum kawg

Nrog koj zoo siab! ntawm kev ua tiav txoj haujlwm no. Kuv muab nws lo lus Tsawg heev li koj tau pom peb tau siv tsawg dua LEDs los qhia txhua qhov kev qhia tsim nyog thiab tseem nrog cov xim tshwj xeeb. Xav tias dawb siv cov xim sib txawv rau koj li LEDs xws li daj rau qhov taw qhia tig lossis lwm yam.

Yog tias koj tau ua txoj haujlwm no nyem rau "Kuv tau ua" thiab qhia koj cov kev paub. Qhia koj cov kev xav thiab tseem muaj cov lus qhia lossis lus pom ntawm qhov haujlwm no. Kuv yuav nyiam hnov qhov ntawd!

Kev Tswj Cable

Yog! Raws li koj yuav tau pom muaj ntau txoj xov hlau nkag mus thiab nyob ib puag ncig thiab tswj lawv yog qhov nyuaj. Kuv siv cov cim cim kab, kab xev thaiv, thiab cov hlua txuas kom zais cov xov hlau thiab tseem pleev xim rau lawv dub li koj tau pom hauv daim duab.

Cov Lus Qhia Yooj Yim: Vim tias koj tau tso cov ntiv tes ntxiv ntawm koj cov kab hluav taws xob ntau dua li qhov xav tau nws yog qhov muaj txiaj ntsig tam sim no los tswj lawv kom raug yam tsis muaj kev nyuab siab rau lawv! Jumper Wires txuas nrog RPi, yuav muaj kev sib cuag xoob. Yog tias qhov no tseem siv tus txiv neej rau poj niam jumper hlau txhawm rau txuas cov hlau thiab txuas lawv. Siv cov hlua txuas los khaws cov xov hlau nyob hauv qhov chaw kom nws tsis txav mus.

Tam sim no Qhov Ntsuas tau teeb tsa rau Caij! Txaus siab rau nws

PS: Hauv cov lus qhia ntxiv Kuv yuav nyiam txo cov xov hlau hauv Circuit Court thiab los nrog txoj phiaj xwm zoo dua. Yog tias kuv ua li ntawd kuv yuav qhia Cov Lus Qhia rau qhov ntawd!

Kauj Ruam 10: Qee Cov Duab ntawm Qhov Ntsuas

Qee Cov Duab ntawm Qhov Taw Qhia
Qee Cov Duab ntawm Qhov Taw Qhia
Qee Cov Duab ntawm Qhov Taw Qhia
Qee Cov Duab ntawm Qhov Taw Qhia
Qee Cov Duab ntawm Qhov Taw Qhia
Qee Cov Duab ntawm Qhov Taw Qhia
Qee Cov Duab ntawm Qhov Taw Qhia
Qee Cov Duab ntawm Qhov Taw Qhia

Ua tsaug rau koj nyeem Cov Lus Qhia no. Kuv vam tias koj nyiam nws ntau npaum li kuv tau ua hauv nws

Lub Sijhawm: Kuaj zaum kawg Hauv ntu lus saum toj no, koj tuaj yeem pom tias sai li sai tau thaum chav tsaus ntuj, "Hmo Pom Kev" tig rau thiab thaum nws ci dua nws tig tawm tam sim!

Ncua sij hawm: Npaj rau RollSome cov vis dis aus Kuv tau coj los qhia qhov ntsuas nyob hauv qhov pom kev. Txhua qhov qhab nia rau kuv cov viv ncaus caij tsheb kauj vab rau daim vis dis aus!

Pom zoo: