Cov txheej txheem:

Saib Serial Monitor Over Bluetooth: 4 Cov Kauj Ruam
Saib Serial Monitor Over Bluetooth: 4 Cov Kauj Ruam
Anonim
Saib Serial Monitor Tshaj Bluetooth
Saib Serial Monitor Tshaj Bluetooth

Txoj haujlwm no siv HC-05 Bluetooth module los hloov qhov kev sib txuas uas ib txwm siv los saib lub koob yees duab.

Cov ntaub ntawv:

  • Arduino -
  • Breadboard -
  • Jumper xov hlau -
  • HC -05 Bluetooth module -

Kauj ruam 1: Code

Txoj cai no yog ib qho piv txwv kev sib txuas lus yooj yim coj los ntawm cov piv txwv hauv Arduino IDE. Koj tuaj yeem pom nws hauv: Cov Ntaub Ntawv> Piv Txwv> Kev Sib Txuas> Ascii Table

/*

ASCII cov lus Luam tawm cov nuj nqis byte hauv txhua qhov ua tau: - raws li cov lej binary tseem ceeb - raws li ASCII -cim cov lej, hex, octal, thiab binary qhov tseem ceeb Rau ntau ntxiv ntawm ASCII, saib https://www.asciitable.com thiab https:// www.asciitable.com Lub Circuit: Tsis xav tau kho vajtse sab nraud. tsim xyoo 2006 los ntawm Nicholas Zambetti <https://www.asciitable.com> hloov kho 9 Plaub Hlis 2012 los ntawm Tom Igoe Cov piv txwv tus lej no yog nyob rau qhov chaw pej xeem. https://www.asciitable.com */void teeb () {Serial.begin (9600); thaum (! Serial) {; // tos rau qhov chaw nres nkoj txuas mus txuas. Xav tau rau ib txwm USB chaw nres nkoj nkaus xwb} Serial.println ("ASCII Table ~ Character Map"); } int thisByte = 33; lub voj void () {Serial.write (thisByte); Serial.print (", dec:"); Serial.print (thisByte); Serial.print (", hex:"); Serial.print (thisByte, HEX); Serial.print (", oct:"); Serial.print (thisByte, OCT); Serial.print (", rau hauv:"); Serial.println (thisByte, BIN); yog (thisByte == 126) {thaum (tseeb) {txuas ntxiv; }} thisByte ++; }

  • Nco ntsoov koj tus nqi baud tau teeb tsa rau 9600
  • Yuav luag txhua txoj cai uas siv txuas txuas mus rau lub khoos phis tawj yuav ua haujlwm, tab sis qhov no tsuas yog piv txwv yooj yim.

Kauj ruam 2: Circuit Court

Circuit Court
Circuit Court

Tom qab cov cai tau muab tso rau hauv pawg thawj coj, txiav lub hwj chim. Tom ntej no, Txuas lub Bluetooth module rau hauv Circuit Court raws li pom saum toj no:

  • GND rau hauv av
  • VCC to 5v pin
  • TXD to PIN 0
  • RXD to pin 1

Kauj Ruam 3: Txuas Bluetooth

Bluetooth Kev Sib Txuas
Bluetooth Kev Sib Txuas
Bluetooth Kev Sib Txuas
Bluetooth Kev Sib Txuas
Bluetooth Kev Sib Txuas
Bluetooth Kev Sib Txuas
  1. Hwj chim ntawm Arduino
  2. Qhib koj lub khoos phis tawj Bluetooth chaw
  3. Pair nrog HC-05 module
  4. Nrhiav tus module lub npe chaw nres nkoj hauv "khoom siv thiab tshuab luam ntawv":
  5. Hauv Arduino IDE, xaiv qhov chaw nres nkoj ntawm Bluetooth module (kuv yog COM10)
  6. Qhib tus saib xyuas raws li ib txwm los saib cov ntaub ntawv nkag

Kauj Ruam 4: Cov Kauj Ruam Ntxiv

Nov yog qee qhov kev xaiv uas koj yuav xav sim:

  • Koj tuaj yeem siv cov chaw nres nkoj virtual hloov chaw, tab sis kuv pom tias siv qhov tiag tiag ua haujlwm tau sai dua (thiab feem ntau yooj yim dua).
  • Koj kuj tseem tuaj yeem siv cov txheej txheem no nrog tus qauv Firmata piv txwv kom tso cai rau wireless tswj nrog Ua (teeb tsa nrawm rau 9600 ua ntej)

Pom zoo: