Cov txheej txheem:
- Kauj ruam 1: Cov ntaub ntawv
- Kauj Ruam 2: Nyeem thiab Hloov Cov Ntaub Ntawv rau Kev Sib Koom
- Kauj Ruam 3: Txais thiab Ua Cov Ntaub Ntawv
- Kauj Ruam 4: Ua Kom Zoo Tshaj Cov Ntaub Ntawv
- Kauj Ruam 5: Nyob Qhov Twg?
Video: Tsheb kauj vab Infinity - Kev Qhia Tsheb kauj vab hauv tsev: 5 kauj ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:29
Thaum lub caij ntuj no, hnub txias thiab huab cua tsis zoo, cov neeg nyiam caij tsheb kauj vab tsuas muaj ob peb txoj hauv kev los qoj ib ce ua lawv nyiam ncaws pob. Peb tab tom nrhiav txoj hauv kev los ua kev qhia sab hauv tsev nrog tsheb kauj vab/tus kws qhia teeb tsa kom lom zem dua tab sis cov khoom lag luam feem ntau muaj los yog them nqi lossis tsuas yog ua kom txaus siab rau siv. Qhov no yog vim li cas peb thiaj pib txhim kho Tsheb kauj vab Infinity ua qhov qhib kev qhia ua video game. Tsheb kauj vab Infinity nyeem qhov nrawm thiab taw qhia los ntawm koj lub tsheb kauj vab thiab muab qib kev sib cuam tshuam uas tsis tuaj yeem pom yooj yim nrog cov kws qhia tsheb kauj vab.
Peb ua kom zoo dua ntawm qhov yooj yim muaj los ntawm Arduino microcontroller thiab ob peb daim ntawv luam tawm 3D kom ruaj ntseg cov cuab yeej pheej yig rau lub tsheb kauj vab ntawm tus kws qhia. Cov ntaub ntawv raug xa mus rau cov vis dis aus game ua nrog cov game nrov ua cav, Kev sib haum xeeb. Txog qhov kawg ntawm cov lus qhia no, koj yuav tsum tuaj yeem teeb tsa koj tus kheej lub ntsuas pa ntawm koj lub tsheb kauj vab thiab xa cov ntaub ntawv ntawm koj lub ntsuas mus rau Kev Sib Koom. Peb txawm suav nrog ib txoj hauv kev uas koj tuaj yeem caij nrog thiab sim tawm koj qhov teeb tsa tshiab. Yog tias koj txaus siab koom nrog koj tuaj yeem txheeb xyuas peb GitHub.
Kauj ruam 1: Cov ntaub ntawv
Cov npe khoom koj xav tau yuav txawv me ntsis; rau
piv txwv li, qhov loj ntawm koj lub tsheb kauj vab yuav txiav txim siab qhov ntev ntawm cov hlua jumper koj xav tau tab sis ntawm no yog cov ntu tseem ceeb koj yuav xav tau. Koj tuaj yeem yuav pom tus nqi pheej yig dua rau txhua daim ntawm lub vev xaib zoo li AliExpress tab sis tos 6 lub hlis rau kev xa khoom tsis yog ib qho kev xaiv yog li tau siv cov khoom kim dua me ntsis yog li qhov kev kwv yees tsis cuam tshuam.
1 x Arduino nano ($ 22.00)
1 x Mini Breadboard ($ 1.33/chav)
1 x 220 Ohm resistor ($ 1.00/pob)
1 x 10K Potentiometer ($ 1.80/chav)
1 x Hall sensor ($ 0.96)
20 cm x 6 mm 3D tshuab luam ntawv sij hawm siv ($ 3.33)
1 pob khoom x Ntau Yam Ntev M3 ntsia hlau thiab ntsia hlau ($ 6.82)
1 x Tsheb kauj vab speedometer hlau nplaum ($ 0.98)
Peb tau ntim cov khoom siv saum toj no nrog cov ntawv luam tawm 3D. Cov ntaub ntawv peb siv tau teev tseg hauv qab no thiab lawv suav nrog cov rooj sib tham zoo ib yam li cov duab thaum pib ntawm ntu no. Txhua cov ntaub ntawv tuaj yeem pom ntawm Thingiverse. Koj tuaj yeem siv lawv raws li-tab sis nco ntsoov tias qhov ntev uas peb siv sib phim koj lub tsheb kauj vab.
1. FrameConnection_PotentiometerHolder_U_Holder.stl
2. FrameConnection_Spacer.stl
3. BreadboardFrameHolder.stl
4. Pulley_PotentiometerSide.stl
5. Pot_PulleyConnection.stl
6. FrameConnection.stl
7. Pulley_HandleBarSide_Print2.stl
8. FrameToHallSensorConnector.stl
9. PotHolder.stl
10. HallSensorAttach.stl
Kauj Ruam 2: Nyeem thiab Hloov Cov Ntaub Ntawv rau Kev Sib Koom
Arduino thiab Unity code yuav ua haujlwm ua ke los sau, hloov thiab txheej txheem cov ntaub ntawv los ntawm cov ntsuas ntawm lub tsheb kauj vab. Kev sib koom siab yuav thov tus nqi los ntawm Arduino los ntawm kev xa ib txoj hlua los ntawm cov lej thiab tos kom Arduino teb nrog cov txiaj ntsig tau thov.
Ua ntej, peb npaj Arduino nrog lub tsev qiv ntawv Serial Command uas yog siv los tswj kev thov los ntawm Kev Sib Koom los ntawm kev sib koom ua ke thov txoj hlua nrog ua haujlwm. Kev teeb tsa yooj yim rau lub tsev qiv ntawv no tuaj yeem ua raws li hauv qab no;
#suav nrog "SerialCommand.h"
SerialCommand sCmd; void teeb () {sCmd.addCommand ("TRIGG", TriggHanlder); Serial.begin (9600); } void loop () {thaum (Serial.available ()> 0) {sCmd.readSerial (); }} tsis muaj dab tsi TriggHandler () { /*Nyeem thiab xa cov ntsuas ntawm no* /}
Kev ua haujlwm TriggHandler tau txuas nrog cov khoom SCmd. Yog tias cov ntawv tau txais cov hlua uas phim cov lus txib txuas (hauv qhov no TRIGG), kev ua haujlwm TriggHandler tau ua tiav.
Peb siv lub zog ntsuas ntsuas ntsuas lub kauj taw qhia thiab lub ntsuas qhov ntsuas kom ntsuas kev sib hloov ib feeb ntawm lub tsheb kauj vab. Kev nyeem los ntawm lub hwj chim tuaj yeem ua tau yooj yim siv kev tsim ua haujlwm los ntawm Arduino. Kev ua haujlwm TriggHandler tuaj yeem luam tawm tus nqi rau cov lej nrog cov kev hloov hauv qab no.
tsis muaj dab tsi TriggHandler () {
/*Nyeem tus nqi ntawm lub hwj chim*/ Serial.println (analogRead (ANALOGPIN)); }
Hall sensor muaj teeb tsa me ntsis ntxiv ua ntej peb tuaj yeem ntsuas qhov muaj txiaj ntsig. Contrary to potentiometer, tus nqi tam sim ntawd ntawm lub tsev sensor tsis muaj txiaj ntsig zoo. Txij li tau sim ntsuas qhov nrawm ntawm lub log, lub sijhawm nruab nrab ntawm qhov ua rau yog yam uas xav tau.
Txhua txoj haujlwm siv hauv Arduino code yuav siv sijhawm thiab yog tias cov hlau nplaum txuas nrog Hall sensor ntawm lub sijhawm tsis raug ntsuas yuav raug ncua ntawm qhov zoo tshaj lossis hla tag nrho qhov phem tshaj. Qhov no yog qhov tsis zoo vim tias Arduino tuaj yeem tshaj tawm qhov nrawm uas sib txawv ntau dua li qhov nrawm ntawm lub log.
Txhawm rau zam qhov no, peb siv qhov tshwj xeeb ntawm Arduinos hu ua txuas cuam tshuam uas tso cai rau peb ua kom muaj nuj nqis thaum twg tus lej digital tau teeb tsa nrog lub teeb liab nce. Kev ua haujlwm rpm_fun tau txuas nrog kev cuam tshuam nrog ib kab ntawm cov lej ntxiv rau teeb tsa teeb tsa.
void teeb tsa () {
sCmd.addCommand ("TRIGG", TriggHanlder); attachInterrupt (0, rpm_fun, RISING); Serial.begin (9600); } // Qhov ua haujlwm rpm_fun tau siv los xam qhov nrawm thiab tau txhais raws li; unsigned ntev lastRevolTime = 0; unsigned ntev revolSpeed = 0; void rpm_fun () {unsigned ntev revolTime = millis (); unsigned ntev deltaTime = revolTime - lastRevolTime; /*revolSpeed yog tus nqi xa mus rau Arduino code* / revolSpeed = 20000 / deltaTime; lastRevolTime = revolTime; } TriggHandler tuaj yeem xa cov ntaub ntawv tas li thaum thov. tsis muaj dab tsi TriggHanlder () { /*Nyeem qhov muaj nuj nqis ntawm lub hwj chim* / Serial.println (analogRead (ANALOGPIN)); Serial.println (revolSpeed); }
Tam sim no peb muaj txhua lub tsev tsim khoom uas tuaj yeem siv los tsim Arduino code uas yuav xa cov ntaub ntawv los ntawm cov ntawv xa mus rau thaum thov los ntawm Unity. Yog tias koj xav kom muaj daim ntawv theej tag nrho cov cai, koj tuaj yeem rub tawm nws ntawm peb GitHub. Txhawm rau ntsuas yog tias txoj cai tau teeb tsa kom raug, koj tuaj yeem siv lub ntsuas saib xa xa TRIGG; xyuas kom tseeb tias koj teeb txoj kab xaus rau Carriage rov qab. Tshooj tom ntej yuav tsom mus rau yuav ua li cas peb cov ntawv Unity tuaj yeem thov thiab tau txais cov ntaub ntawv los ntawm Arduino.
Kauj Ruam 3: Txais thiab Ua Cov Ntaub Ntawv
Kev sib sau yog software zoo muaj pub dawb rau cov nyiam ua haujlwm
nyiam ua game; nws los nrog ntau qhov kev ua haujlwm uas tuaj yeem txo qis rau lub sijhawm teeb tsa qee yam xws li xov lossis GPU programming (AKA ntxoov ntxoo) yam tsis txwv qhov ua tau nrog C# ntawv. Kev sib sau ua ke thiab Arduino microcontrollers tuaj yeem siv ua ke los tsim kev sib tham sib txawv nrog cov peev txheej me.
Lub hom phiaj ntawm cov lus qhia no yog los pab teeb tsa kev sib txuas lus ntawm Kev Sib Koom thiab Arduino yog li peb yuav tsis dhia dej tob dhau rau feem ntau ntawm cov yam ntxwv muaj nrog Unity. Muaj ntau ntau cov lus qhia zoo rau kev sib koom ua ke thiab zej zog tsis txaus ntseeg uas tuaj yeem ua haujlwm zoo dua los piav qhia txog kev sib sau ua haujlwm li cas. Txawm li cas los xij, muaj qhov khoom plig tshwj xeeb rau cov neeg uas tswj hwm lawv txoj hauv kev los ntawm cov lus qhia no uas ua haujlwm me me ntawm qhov ua tau zoo. Koj tuaj yeem rub tawm ntawm peb Github peb thawj zaug sim ua txoj hauv kev nrog lub cev tsheb kauj vab tiag tiag.
Ua ntej, cia mus dhau qhov tsawg kawg nkaus uas yuav tsum tau ua txhawm rau sib txuas lus nrog Arduino los ntawm kab ntawv. Nws yuav pom sai sai tias cov cai no tsis haum rau kev ua si tab sis nws yog qhov zoo mus los ntawm txhua kauj ruam thiab kawm paub qhov txwv yog dab tsi.
Hauv Kev Sib Koom, tsim qhov xwm txheej tshiab nrog ib qho GameObject uas tsis muaj npe hu ua ArduinoReceive ntawm tus neeg sau tus lej C# kuj tseem muaj npe ArduinoReceive. Tsab ntawv no yog qhov uas peb yuav ntxiv txhua txoj cai uas ua haujlwm sib txuas lus nrog Arduino.
Muaj lub tsev qiv ntawv uas yuav tsum nkag mus ua ntej peb tuaj yeem sib txuas lus nrog cov chaw nres nkoj ntawm koj lub computer; Kev sib koom siab yuav tsum tau teeb tsa kom tso cai siv qee lub tsev qiv ntawv. Mus rau Khoos phis tawj-> ProjectSerring-> Player thiab nyob ze rau Api Compatibility Level nyob rau hauv Configuration hloov. NET 2.0 Subset rau. NET 2.0. Tam sim no ntxiv cov cai hauv qab no rau saum cov ntawv;
siv System. IO. Ports;
Qhov no yuav tso cai rau koj nkag mus rau Chav Kawm SerialPort uas koj tuaj yeem txhais ua lub hom phiaj rau ArduinoReceive Class. Ua rau nws tus kheej kom tsis txhob cuam tshuam los ntawm lwm tsab ntawv.
ntiag tug SerialPort arduinoPort;
Lub hom phiaj arduinoPort tuaj yeem qhib los ntawm kev xaiv qhov chaw nres nkoj raug (piv txwv li USB uas Arduino txuas nrog) thiab tus nqi baud (piv txwv li qhov nrawm uas cov ntaub ntawv xa mus). Yog tias koj tsis paub meej tias qhov chaw nres nkoj twg Arduino tau ntsaws rau hauv koj tuaj yeem pom tawm hauv tus thawj tswj ntaus ntawv lossis qhib Arduino IDE. Txog tus nqi baud, tus nqi pib ntawm cov cuab yeej feem ntau yog 9600, tsuas yog xyuas kom koj muaj tus nqi no hauv koj li Arduino code thiab nws yuav tsum ua haujlwm.
Cov cai yuav tsum zoo li tam sim no;
siv System. Collections;
siv System. Collections. Generic; siv UnityEngine; siv System. IO. Ports; pej xeem chav kawm ArduinoReceive: MonoBehaviour {ntiag tug SerialPort arduinoPort; // Siv qhov no rau qhov pib tsis muaj dab tsi Pib () {arduinoPort = tshiab SerialPort ("COM5", 9600); arduinoPort. Open (); WriteToArduino ("TRIGG"); }}
Koj tus lej COM feem ntau yuav txawv. Yog tias koj nyob ntawm MAC, koj lub npe COM yuav muaj lub npe uas zoo li no /dev/cu.wchusbserial1420. Nco ntsoov tias cov cai los ntawm ntu 4 tau xa mus rau Arduino thiab cov saib txuas tau raug kaw rau qhov seem ntawm ntu no thiab tias cov cai no suav ua ke yam tsis muaj teeb meem.
Tam sim no cia peb xa daim ntawv thov mus rau Arduino txhua tus ncej thiab sau cov txiaj ntsig mus rau lub qhov rai console. Ntxiv qhov WriteToArduino ua haujlwm rau hauv chav kawm ArduinoReceive. Kev thauj rov qab thiab kab tshiab yog qhov tsim nyog rau Arduino code txhawm rau txheeb xyuas cov lus qhia kom raug.
ntiag tug tsis muaj dab tsi WriteToArduino (kab lus)
{message = message + "\ r / n"; arduinoPort. Write (lus); arduinoPort. BaseStream. Flush (); }
Txoj haujlwm no tuaj yeem raug hu ua Hloov Kho lub voj.
void hloov tshiab ()
{WriteToArduino ("TRIGG"); Debug. Log ("Tus nqi thawj:" + arduinoPort. ReadLine ()); Debug. Log ("Tus nqi thib ob:" + arduinoPort. ReadLine ()); }
Cov cai saum toj no yog yam tsawg kawg nkaus uas koj xav tau los nyeem cov ntaub ntawv los ntawm Arduino. Yog tias koj ua tib zoo mloog FPS muab los ntawm kev sib koom siab, koj yuav tsum pom qhov ua tau zoo poob qis. Hauv kuv qhov xwm txheej, nws mus los ntawm ib ncig 90 FPS yam tsis tau nyeem/sau ntawv mus rau 20 FPS. Yog tias koj txoj haujlwm tsis xav tau hloov kho tas li nws yuav txaus tab sis rau kev ua yeeb yaj kiab video, 20 FPS yog qhov tsawg heev. Tshooj lus tom ntej yuav npog yuav ua li cas koj tuaj yeem txhim kho kev ua tau zoo los ntawm kev siv ntau txoj xov.
Kauj Ruam 4: Ua Kom Zoo Tshaj Cov Ntaub Ntawv
Tshooj yav dhau los tau hais txog yuav teeb tsa qhov yooj yim li cas
kev sib txuas lus ntawm Arduino thiab Unity program. Qhov teeb meem loj nrog txoj cai no yog qhov ua tau zoo. Hauv nws qhov kev siv tam sim no, Kev sib koom siab yuav tsum tau tos rau Arduino kom tau txais, txheej txheem thiab teb cov lus thov. Lub sijhawm ntawd, Txoj Cai Kev Sib Koom yuav tsum tau tos kom thov kom ua tiav thiab tsis ua dab tsi ntxiv. Peb daws qhov teeb meem no los ntawm kev tsim xov uas yuav daws qhov kev thov thiab khaws qhov sib txawv ntawm cov xov tseem ceeb.
Txhawm rau pib, peb yuav tsum suav nrog cov tsev qiv ntawv xov los ntawm kev ntxiv;
siv System. Threading;
Tom ntej no, peb teeb tsa txoj haujlwm uas peb tab tom pib hauv cov xov. AsynchronousReadFromArduino pib los ntawm kev sau ntawv thov mus rau Arduino nrog WrtieToArduino ua haujlwm. Kev nyeem ntawv tau muab tso rau hauv ib qho kev sim-ntes, yog tias nyeem tas sijhawm, cov kev hloov pauv tseem nyob twj ywm thiab OnArduinoInfoFail muaj nuj nqi hu ua hloov ntawm OnArduinoInfoReceive.
Tom ntej no peb txheeb xyuas OnArduinoInfoFail thiab OnArduinoInfoReceive ua haujlwm. Txog qhov kev qhia no, peb luam tawm cov txiaj ntsig rau lub console tab sis koj tuaj yeem khaws cov txiaj ntsig rau hauv qhov hloov pauv uas koj xav tau rau koj txoj haujlwm.
ntiav void OnArduinoInfoFail ()
{Debug. Log ("Nyeem ntawv tsis tau"); } ntiag tug void OnArduinoInfoReceived (txoj hlua sib hloov, txoj hlua nrawm) {Debug. Log ("Readin Sucessfull"); Debug. Log ("Tus nqi thawj:" + kev sib hloov); Debug. Log ("Tus nqi thib ob:" + nrawm); }
Kauj ruam kawg yog pib thiab nres cov xov uas yuav thov qhov txiaj ntsig los ntawm Arduino. Peb yuav tsum ua kom ntseeg tau tias cov xov kawg tau ua tiav nrog nws txoj haujlwm kawg ua ntej pib qhov tshiab. Txwv tsis pub, ntau qhov kev thov tuaj yeem ua rau Arduino ntawm ib zaug uas tuaj yeem ua rau Arduino/Kev sib sau tsis sib xws thiab ua rau cov txiaj ntsig tsis tuaj yeem kwv yees tau.
ntiag tug xov activeThread = tsis muaj;
void Update () {if (activeThread == null ||! activeThread. IsAlive) {activeThread = xov tshiab (AsynchronousReadFromArduino); activeThread. Start (); }}
Yog tias koj sib piv qhov ua tau zoo ntawm cov cai nrog tus peb tau sau ntawm ntu 5, kev ua haujlwm yuav tsum tau txhim kho zoo dua.
ntiav void OnArduinoInfoFail ()
{Debug. Log ("Nyeem ntawv tsis tau"); }
Kauj Ruam 5: Nyob Qhov Twg?
Peb tau npaj qhov demo uas koj tuaj yeem rub tawm ntawm peb Github (https://github.com/AlexandreDoucet/InfinityBike), rub cov cai thiab kev ua si thiab caij hla peb txoj kev. Nws yog txhua yam teeb tsa rau kev tawm dag zog sai thiab peb vam tias nws tuaj yeem ua rau koj saj ntawm yam koj tuaj yeem tsim yog tias koj siv yam peb tau qhia koj nrog cov lus qhia no.
Khab nias
Cov koom tes nrog txoj haujlwm
Alexander Doucet (_Doucet_)
Maxime Boudreau (MxBoud)
Cov peev txheej sab nraud [Lub cav kev sib sau game] (https://unity3d.com)
Txoj haujlwm no tau pib tom qab peb nyeem cov lus qhia los ntawm Allan Zucconi "yuav ua li cas koom nrog Arduino nrog Kev Sib Koom" (https://www.alanzucconi.com/2015/10/07/how-to-int…)
Qhov kev thov los ntawm Arduino tau ua tiav siv lub tsev qiv ntawv SerialCommand (https://github.com/kroimon/Arduino-SerialCommand)
Pom zoo:
DIY Sab Hauv Tsev Tsheb Tsheb Ntse Tus Kws Qhia: 5 Kauj Ruam
DIY Sab Hauv Tsev Tsheb Tsheb Ntse Tus Kws Qhia: Taw qhia Qhov haujlwm no pib ua qhov hloov pauv yooj yim rau Schwinn IC Cov neeg tseem ceeb tsheb kauj vab sab hauv tsev uas siv cov ntsia hlau yooj yim thiab muaj cov ntaub qhwv rau qhov tsis kam ua haujlwm. Qhov teeb meem kuv xav daws yog tias lub suab ntawm cov ntsia hlau tau loj, yog li qhov ntau
Tuchless Hloov rau Cov Khoom Siv Hauv Tsev -- Tswj Koj Cov Khoom Siv Hauv Tsev Tsis Muaj Tuch Ib qho Hloov: 4 Cov Kauj Ruam
Tuchless Hloov rau Cov Khoom Siv Hauv Tsev || Tswj Koj Cov Khoom Siv Hauv Tsev Tsis Muaj Tuch Ib qho Hloov: Nov Yog Qhov Tuchless Hloov Rau Cov Khoom Siv Hauv Tsev. Koj Siv Tau Qhov No Mus Rau Txhua Qhov Chaw Hauv Pej Xeem Kom Pab Tau Tawm Tsam Ib Yam Kab Mob. Lub Circuit Court Raws Li Tsaus Sensor Circuit Ua Los Ntawm Op-Amp Thiab LDR. Qhov Tseem Ceeb Thib Ob Ntawm Qhov Circuit Court SR Flip-Flop Nrog Sequencell
Tsev Kawm Ntawv Nroog Tsev Kawm Ntawv Chaw Nres Tsheb Daim Ntawv Qhia: 7 Kauj Ruam (nrog Duab)
University Campus Student Parking Map: Ntau tus tub ntxhais kawm xav paub tias lawv tuaj yeem nres tsheb hauv lub tsev kawm ntawv qib siab li cas. Txhawm rau daws qhov teeb meem no, Kuv tsim daim duab qhia chaw nres tsheb ntawm thaj chaw tseem ceeb ntawm Utah State University lub tsev kawm ntawv. Daim duab qhia chaw yog rau cov tub ntxhais kawm kom nrawm nrawm saib seb qhov chaw nres tsheb twg yog
Tswj Cov Khoom Siv Hauv Tsev Hla LoRa - LoRa hauv Tsev Automation - LoRa Chaw Taws Teeb: 8 Kauj Ruam
Tswj Cov Khoom Siv Hauv Tsev Hla LoRa | LoRa hauv Tsev Automation | LoRa Kev Tswj Chaw Taws Teeb: Tswj thiab siv koj lub cuab yeej siv hluav taws xob los ntawm qhov deb (Kilometers) yam tsis muaj internet. Qhov no ua tau los ntawm LoRa! Hav, ua li cas, cov menyuam? Akarsh ntawm no los ntawm CETechQhov PCB no tseem muaj cov zaub OLED thiab 3 qhov txuas uas
SMD SOLDERING 101 - SAWV DAWS HAUV TSEV HAUV TSEV, HOT AIR BLOWER, SMD STENCIL THIAB HAND SOLDERING: 5 Kauj Ruam
SMD SOLDERING 101 | Siv Cov Phaj Kub, Cov cua kub cua sov, SMD STENCIL THIAB YUAV TSHUAJ: Nyob zoo! Nws yog ib qho yooj yim zoo nkauj los ua cov soldering …. Thov siv qee qhov flux, Tshav kub rau saum npoo thiab siv cov tshuaj txhuam tab sis thaum nws los rau hauv cov khoom siv SMD nws yuav tsum muaj txuj ci me ntsis thiab qee yam cuab yeej thiab khoom siv ntxiv. Hauv Cov Lus Qhia no, Kuv yuav qhia koj kuv