Cov txheej txheem:

Lub Teeb Xyoob (Txuas Teeb): 3 Kauj Ruam
Lub Teeb Xyoob (Txuas Teeb): 3 Kauj Ruam

Video: Lub Teeb Xyoob (Txuas Teeb): 3 Kauj Ruam

Video: Lub Teeb Xyoob (Txuas Teeb): 3 Kauj Ruam
Video: txhob ua kuv kub 100.Tub Huas Xyooj MV2023 2024, Hlis ntuj nqeg
Anonim
Teeb Xyoob (Txuas Teeb)
Teeb Xyoob (Txuas Teeb)

Nyob zoo thiab txais tos!

Lub teeb xyoob yog lub teeb sib txuas uas teeb thaum lub ceeb toom tau txais ntawm lub xov tooj Android uas nws tau txuas nrog. Lub hom phiaj ntawm cov lus qhia no yog los qhia koj txog theem tsim ntawm txoj haujlwm: los ntawm cov cuab yeej kho vajtse, mus rau Bluetooth Tsawg Zog (BLE) txuas thiab Android daim ntawv thov tsim.

Rau peb lub teeb, peb xaiv cov yas cog rau qhov tsim kom zoo nkauj tsim. Txog qhov haujlwm no, cov ntawv ceeb toom uas tau tshwm sim yog los ntawm cov ntawv thov hauv qab no: hu, sms/mms, facebook, tub txib, instagram, whatsapp ang gmail. Ib lub teeb xim yog ntaus nqi rau txhua hom kev ceeb toom.

Rau qhov haujlwm no, koj yuav xav tau:

  • UC nrog kev sib xyaw BLE module: nFR51822 RedBearLab
  • 3 NeoPixel Nplhaib (12 RGB LEDs)
  • Ib lub Android smartphone
  • Hauv Studio

Txhua qhov kev ceeb toom muaj qhov tshwj xeeb tshwj xeeb, nyob ntawm nws qhov tseem ceeb. Piv txwv li, kev ceeb toom hu tuaj yog qhov tseem ceeb tshaj li kev ceeb toom Facebook. Hauv qhov xwm txheej ntawd, LEDs xim yuav cuam tshuam nrog kev ceeb toom hu tuaj.

Lub xov tooj ntawm tes uas peb tsim daim ntawv thov yog Samsung Galaxy A5.

Kauj Ruam 1: Tshooj Kho Vajtse

Kho vajtse Tshooj
Kho vajtse Tshooj

Peb architecture yog yooj yim heev.

Txuas NeoPixel Ring pins rau nRF51822 pawg thawj coj raws li hauv qab no:

  • Inout Cov ntaub ntawv tus pin ntawm NeoPixel Ring rau qhov chaw nres nkoj 3 ntawm uC.
  • Vcc ntawm NeoPixel Ring rau 3.3V ntawm uC.
  • GND ntawm NeoPixel Ring rau GND ntawm uC.

Koj tuaj yeem pom tias peb tsis siv Cov Ntaub Ntawv Tso Tawm tus pin ntawm NeoPixel Ring. Qhov ntawd yog vim cov ntaub ntawv Input pins ntawm peb NeoPixel Rings peb siv hauv txoj haujlwm no txhua tus txuas nrog tib lub chaw nres nkoj ntawm nRF51822 board (tus pin 3).

Kauj ruam 2: Software Tshooj

Software Tshooj
Software Tshooj
Software Tshooj
Software Tshooj
Software Tshooj
Software Tshooj

1. Kev Sib Txuas Bluetooth Tsawg Zog:

Hauv kev sib txuas lus BLE, tus neeg rau zaub mov (uas yog nyob rau hauv peb cov ntaub ntawv uC) thiab cov neeg siv khoom (lub xov tooj ntawm tes) sib pauv cov ntaub ntawv siv GATT kev sib pauv. Hauv cov kev lag luam ntawd, cov ntaub ntawv tau teeb tsa hierarchically hauv ntu hu ua cov kev pabcuam, uas pab pawg cov tswv yim cuam tshuam nrog cov neeg siv cov ntaub ntawv hu ua yam ntxwv. Hauv peb qhov xwm txheej, cov ntaub ntawv ntim khoom tau yooj yim vim peb tsuas muaj ib cov ntaub ntawv dhau los ntawm tus neeg siv khoom mus rau server (saib daim duab saum toj no).

  • ntawm tus neeg rau zaub mov: Txhawm rau siv tau nrf51822 pawg thawj coj los ua BLE server, xub nruab "BLEPeripheral.h" lub tsev qiv ntawv ntawm Arduino IDE. Lub tsev qiv ntawv no muab kev npaj ua kom siv tau zoo rau kev tsim cov kev pabcuam thiab tus yam ntxwv thiab tshaj tawm.
  • ntawm cov neeg siv khoom: Txhawm rau pib BLE kev sib txuas lus hauv Android Studio, xub teeb tsa BLE kev tso cai hauv Manifest file. Tom qab ntawd, hauv cov ntaub ntawv activity_main.xml, ntxiv 4 khawm: luam theej duab, nres luam theej duab, txuas thiab txiav tawm uas yuav tso cai rau daim ntawv thov txhawm rau tshuaj xyuas BLE cov cuab yeej nyob ze, nres qhov scan, txuas thiab txuas mus rau lub cuab yeej. Hauv cov ntaub ntawv main_activity.java, siv cov haujlwm uas cuam tshuam nrog cov nyees khawm yav dhau los: startScanning (), stopscanning (), connectToDeviceSelected (), disconnectDeviceSelected (). Thaum kawg, siv cov haujlwm rov qab uas tau hu thaum lub xeev hloov pauv tus neeg siv khoom..

2. Kev ceeb toom kev tswj hwm

  • ntawm cov neeg siv khoom (ntawm Android Studio): Txhawm rau mloog cov ntawv ceeb toom los ntawm lub xov tooj ntawm tes, siv lub mloog lus ceeb toom uas tau qhib thaum muaj kev ceeb toom tshwm sim hauv kab xwm txheej. Tus neeg mloog daim ntawv ceeb toom no yuav xa "lus", hu ua lub hom phiaj, mus rau lub luag haujlwm tseem ceeb thaum ceeb toom tshaj tawm lossis tshem tawm. Qhov "xov xwm" no muaj cov cai ceeb toom uas pab txheeb xyuas daim ntawv thov uas tshaj tawm qhov kev ceeb toom. Txhawm rau ua cov ntawv ceeb toom hauv lub luag haujlwm tseem ceeb, tsim kom muaj tus txais xov tooj cua uas yuav tau txais cov lus los ntawm tus neeg mloog ceeb toom. Tom qab ntawd, nyob ntawm tus lej ceeb toom, tus yam ntxwv sib txawv raug xa mus rau tus neeg rau zaub mov.
  • ntawm tus neeg rau zaub mov (ntawm Arduino IDE): kev ceeb toom uas muaj qhov muaj txiaj ntsig tshaj plaws tau tshwm sim.

Kauj Ruam 3: Kauj Ruam 3: Cov ntawv txuas nrog

Ntawm no, koj yuav pom txhua qhov chaws qhov chaws.

Pom zoo: