Yuav Ua Li Cas Txuas Bluetooth Module Rau Arduino

Cov txheej txheem:

Yuav Ua Li Cas Txuas Bluetooth Module Rau Arduino
Yuav Ua Li Cas Txuas Bluetooth Module Rau Arduino

Video: Yuav Ua Li Cas Txuas Bluetooth Module Rau Arduino

Video: Yuav Ua Li Cas Txuas Bluetooth Module Rau Arduino
Video: Bluetooth module HC-06 and Arduino 2024, Tej zaum
Anonim

Cia txuas lub wireless Bluetooth module rau Arduino thiab kawm paub yuav ua li cas kom tau txais cov ntaub ntawv los ntawm nws thiab hloov ntaub ntawv los ntawm lub koos pis tawj rau nws.

Bluetooth module
Bluetooth module

Tsim nyog

  • - Arduino;
  • - bluetooth module;
  • - khoos phis tawj;
  • - txuas xov hlau.

Cov Lus Qhia

Kauj ruam 1

Muaj ntau qhov kev siv ntawm Bluetooth modules. Txhua tus muaj nws tus yam ntxwv, tab sis feem ntau lawv txhua yam zoo sib xws. Xav txog tus neeg sawv cev ntawm HC-06 bluetooth module.

Cov qauv no ua haujlwm ntawm zaus ntawm 2.40 GHz txog 2.48 GHz thiab txhawb qhov bluetooth specification version 2.1 + EDR (qis zog siv, nce cov ntaub ntawv tiv thaiv thiab kev sib txuas tau yooj yim ntawm cov khoom siv Bluetooth). Ruaj txais tos nrog cov txheej txheem tau lees tias tsis pub dhau 10 meters.

Lub hom phiaj ntawm lub koob ntawm lub bluetooth module yog raws li nram no:

- VCC thiab GND - "ntxiv rau" thiab "rho tawm" ntawm qhov module fais fab mov, voltages los ntawm 3, 6 txog 6 volts yog txaus siab;

- TX thiab RX - lub tshuab txais thiab txais ntawm cov qauv;

- MCU-INT (Xwm) yog ib qho xwm txheej tso tawm;

- Tseeb (Rov qab) - pib dua thiab rov ua dua ntawm tus qauv, qhov no nws yog nqa los ntawm lub laj thawj qis.

Thaum kawg ob qho kev pom zoo zaum kawg yuav tsis koom nrog; feem ntau koj tuaj yeem nrhiav tau cov qauv tsis muaj cov kev pom zoo txhua.

Lub hom phiaj ntawm bluetooth module koob
Lub hom phiaj ntawm bluetooth module koob

Kauj ruam 2

Cia txuas lub bluetooth module rau Arduino raws li daim duab hauv qab no. Thov nco ntsoov tias lub transmitter (Tx) ntawm Arduino txuas nrog lub receiver (Rx) ntawm tus qauv, thiab hloov ua lwm yam.

Cov xwm txheej nawj qhia tus lej siab thaum tus qauv tau ua ke nrog lwm tus ntaus bluetooth, thiab qis thaum nws tsis ua khub. Koj tuaj yeem nyeem nws tus nqi los ntawm txuas rau Arduino tus pin thiab muab nws tus pinMode (pinStatus, INPUT) hom kev ua haujlwm thiab yog li kawm paub lub xeev ntawm tus qauv. Tab sis cov cim qhia xwm txheej tsis ua haujlwm zoo rau txhua tus qauv, yog li peb yuav tsis siv nws hauv qhov ua piv txwv.

Daim duab ntawm kev txuas bluetooth module rau Arduino
Daim duab ntawm kev txuas bluetooth module rau Arduino

Kauj ruam 3

Qhov tshwm sim yuav tsum muaj tej yam xws li yees duab.

Bluetooth module txuas nrog Arduino
Bluetooth module txuas nrog Arduino

Kauj ruam 4

Wb sau zoo li cov duab kos thiab xa nws mus rau hauv Arduino nco. Peb yuav nyeem cov ntaub ntawv los ntawm bluetooth module thiab txheej txheem nws. Hauv qhov no, thaum lub cim "1" los ntawm qhov module, peb yuav taws lub teeb ci LED, thiab thaum "0" tuaj txog, tua nws.

Peb tig ntawm kev sib dhos Circuit Court nrog Arduino thiab bluetooth module txuas rau nws. Qhov tseeb txuas txuas tam sim nkag mus rau hauv kev sib txuas standby hom, uas yuav qhia los ntawm kev sib zog raws sijhawm ntawm LED.

Teeb duab rau Arduino ua haujlwm nrog Bluetooth
Teeb duab rau Arduino ua haujlwm nrog Bluetooth

Kauj ruam 5

Tam sim no koj xav tau ntxiv cov bluetooth ntaus ntawv rau cov npe khoom siv tau ntseeg. Qhib Bluetooth ntawm koj lub computer, mus rau Chaw -> Li -> Bluetooth. Peb nco ntsoov tias peb bluetooth module yog pom rau lub khoos phis tawm. Xaiv nws los ntawm daim ntawv thiab nyem khawm Txuas. Hauv lub npov, sau lub cim lus zais 1234. Yog tias qhov sib ntxiv tau zoo, lub cuab yeej yuav tshwm hauv cov npe nrog Paired cim.

Yog tias koj xav txuas rau koj qhov bluetooth module ntawm koj lub xov tooj ntawm smartphone, tom qab ntawd tus txheej txheem zoo ib yam: tig bluetooth ntawm koj lub xov tooj smartphone, kuaj lub module txuas nrog Arduino, ua khub nrog nws.

Khub nrog lub tshuab ntaus bluetooth
Khub nrog lub tshuab ntaus bluetooth

Kauj Ruam 6

Txhawm rau txuas rau bluetooth module, koj tuaj yeem siv ntau yam program uas tuaj yeem txuas nrog COM chaw nres nkoj. Piv txwv, xws li HyperTerminal, PuTTY, Tera Term, Termite thiab lwm yam. Lawv yog txhua tus pub dawb thiab muab faib dawb hauv Is Taws Nem.

Qhov yooj yim ntawm TeraTerm yog tias nws cia li sau cov npe nkag COM uas tau muab rau koj lub khoos phis tawj bluetooth module. Tshaj tawm qhov kev pab cuam, xaiv qhov kev sib txuas Serial, xaiv qhov sib xws bluetooth COM chaw nres nkoj los ntawm cov npe, nyem OK.

Yog tias muaj qhov yuam kev thaum lub sijhawm sib txuas, qhov kev zov me nyuam yuav tso tawm cov lus ceeb toom sib xws. Yog tias qhov kev sib txuas ntawm koj lub khoos phis tawm nrog lub bluetooth module tau ua tiav, ces koj yuav pom lub davhlau ya davhlau dub nyob ntawm koj xub ntiag.

Sau tus lej 1 los ntawm cov keyboard rau hauv daim teb no - thiab LED rau ntawm tus lej 13 ntawm Arduino yuav taws, nkag mus 0 - nws yuav tawm mus.

Peb txuas rau bluetooth module ntawm bluetooth los ntawm computer
Peb txuas rau bluetooth module ntawm bluetooth los ntawm computer

Kauj Ruam 7

Ib yam li ntawd, koj tuaj yeem txuas rau bluetooth module ntawm koj lub smartphone. Rub tawm lub bluetooth davhlau ya nyob twg daim ntawv thov xws li Bluetooth Terminal. Txuas rau ntawm tus qauv thiab sau cov lus txib 0 lossis 1.

Yog li, peb tau kawm txog yuav ua li cas txuas ntawm bluetooth mus rau Arduino thiab hloov ntaub ntawv rau nws.

Pom zoo: