Cov txheej txheem:

Neopixel Led Sawb Reacting rau Myoware Muscle Sensor: 6 Cov Kauj Ruam
Neopixel Led Sawb Reacting rau Myoware Muscle Sensor: 6 Cov Kauj Ruam

Video: Neopixel Led Sawb Reacting rau Myoware Muscle Sensor: 6 Cov Kauj Ruam

Video: Neopixel Led Sawb Reacting rau Myoware Muscle Sensor: 6 Cov Kauj Ruam
Video: how to make ARGB LED strip at home (WS2812 LED module) make gaming RGB strip 2024, Hlis ntuj nqeg
Anonim
Neopixel Coj Sawb Rov Ua Rau Myoware Muscle Sensor
Neopixel Coj Sawb Rov Ua Rau Myoware Muscle Sensor

Lub hom phiaj yog txhawm rau txhim kho cov leeg nqaij nrog kev pab los ntawm Arduino thiab ua cov ntaub ntawv nkag mus nrog Adafruit IO thiab rov qab muab cov zis tawm nrog lub ntsuas kom lub teeb tig los ntawm dawb mus rau liab rau ib feeb.

Muscle Sensor Dab tsi yog Cov Muscle Sensor ntsuas cov hluav taws xob ua haujlwm ntawm cov leeg thiab ua cov teeb liab tso tawm uas tuaj yeem nyeem tau yooj yim los ntawm lub microcontroller. Electromyography (EMG) ntsuas cov leeg ua haujlwm lossis ua haujlwm hluav taws xob hauv kev teb rau lub paj hlwb ua rau cov leeg mob. Qhov kev sim no yog siv los pab txheeb xyuas qhov txawv txav ntawm cov leeg nqaij leeg. Thaum kuaj, ib lossis ntau rab koob me me (tseem hu ua electrodes) tau tso los ntawm daim tawv nqaij mus rau hauv cov leeg.

Rau txoj haujlwm no koj xav tau: -MyoWare cov leeg nqaij -EEMG electrodes -NodeMCU (esp8266) -Silicon npog hlau -USB micro cable -Neopixel coj sawb

Cov tsev qiv ntawv koj yuav xav tau: -Adafruit io Arduino (tsawg kawg version 2.3.0) -Adafruit Neopixel (version 1.2.5) -Adafruit MQTT library (1.0.3) -Arduino HttpClients (0.4.0) Yog tias koj tsis muaj te cov tsev qiv ntawv tau teeb tsa tsis tau. Tom qab ntawd mus rau Sketch> suav nrog Tsev Qiv Ntawv> Tswj Tsev Qiv Ntawv… ntaus ntawv: [lub npe tsev qiv ntawv koj xav teeb tsa] hauv kev tshawb nrhiav.

Kauj Ruam 1: Txuas Myoware Muscle Sensor (tshwj xeeb tshaj yog rau Cov Uas Tsis Tau Ua Haujlwm Nrog Nws Ua Ntej)

Yog tias koj tsis tau ua haujlwm nrog Myoware Muscle Sensor, nws yog qhov zoo ua ntej nkag siab tias lub ntsuas ntsuas tau txuas nrog thiab nyeem tau li cas hauv Serial monitor hauv Arduino. Txoj haujlwm no yog txheej txheem txheej txheem uas muaj nyob hauv ntau phau ntawv twb tau piav qhia lawm. Adafruit platform tau piav qhia meej txog qhov no ua haujlwm li cas hauv ob peb kauj ruam:

learn.adafruit.com/getting-started-with-my…

Yog tias tag nrho cov kauj ruam no tau ua, koj yuav pom hauv koj daim ntawv saib xyuas uas qhov txiaj ntsig hloov thaum koj ua kom koj cov leeg nruj. Thaum koj ua nrig thiab zawm koj cov leeg cov txiaj ntsig yuav tsum nce thiab thaum koj so koj cov leeg cov txiaj ntsig no yuav tsum nqes dua.

Tseem ceeb Cov kauj ruam no tsuas yog teeb tsa lub sensor. Cov cai uas koj tau siv tsis tsim nyog rau tas ntawm phau ntawv qhia. Tsuas yog txoj hauv kev koj tso lub sensor nws tus kheej tseem zoo ib yam rau cov theem tom ntej.

Kauj ruam 2: Adafruit IO Teeb

Adafruit IO Teeb
Adafruit IO Teeb
Adafruit IO Teeb
Adafruit IO Teeb
Adafruit IO Teeb
Adafruit IO Teeb

Thawj kauj ruam yog nkag mus lossis tsim tus as khauj hauv Adafruit IO, xauj mus rau Adafruit IO. Adafruit IO yog huab huab, uas koj tuaj yeem txuas rau hauv is taws nem. Adafruit IO ua cov ntaub ntawv muaj txiaj ntsig nrog cov ntaub ntawv sib txuas.

Thaum koj nyob hauv koj tus as khauj:

Tsim Analog FeedNext, koj yuav tsum tsim cov khoom noj hu ua Analog. Yog tias koj xav tau kev pab pib nrog tsim txau ntawm Adafruit IO, txheeb xyuas Adafruit IO Feed Basics qhia (Raws li ntawm daim duab 1 thiab 2).

Ntxiv Gauge Thaiv thiab Kab Kab Kab BlockNext, tsim lub dashboard tshiab thiab sau nws raws li koj xav kom nws lub npe (qhia hauv duab 3, 4 thiab 5 los ua lub dashboard tshiab). Nco ntsoov tias koj tau xaiv Analog pub ua cov ntaub ntawv.

Thaum koj nyob hauv lub dashboard ntxiv qhov ntsuas Gauge tshiab nyem rau ntawm xiav ntxiv rau hauv kaum sab xis saum toj. Lub npe thaiv txhua yam koj xav tau (qhia hauv duab 6 thiab 7), thiab muab nws tus nqi siab tshaj ntawm 1024 thiab tus nqi qis ntawm 0 (tus nqi ntawm cov leeg nqaij).

Rov ua zoo ib yam nrog Kab kab thaiv kab (duab 8) raws li hais saum toj no nrog Gauge block.

Yog tias koj tau ua tiav saum toj no, koj yuav tsum muaj lub vijtsam zoo ib yam li daim duab kawg.

Kauj Ruam 3: Arduino Tswv Yim

Arduino tswv yim
Arduino tswv yim
Arduino tswv yim
Arduino tswv yim
Arduino tswv yim
Arduino tswv yim
Arduino tswv yim
Arduino tswv yim

Hauv kauj ruam 1 koj tau ua tiav teeb tsa thaiv kab mob MyoWare Muscle sensor kom raug. Cov kauj ruam no peb yuav dhia mus rau Arduino code uas los nrog txuas mus rau kauj ruam 2 Adafruit IO dashboard. Qhov kawg ntawm cov kauj ruam no, koj yuav pom cov txiaj ntsig ntawm Myoware Muscle sensor hauv ob qhov thaiv uas koj tau teeb tsa.

Arduino teeb tsa

Nco ntsoov tias koj tau teeb tsa lub tsev qiv ntawv uas tau sau tseg saum toj no hauv kev qhia.

Peb yuav ua haujlwm nrog daim duab piv txwv. Yog li qhib Cov Ntawv> Piv txwv> Adafruit IO Arduino> adafruitio_08_analog_in (daim duab 1). Vim li cas daim duab no? vim tias peb tab tom teeb tsa lub tswv yim ib feem ntawm phau ntawv no. MyoWare Muscle sensor ua rau siv cov khoom sib xws. Yog tias koj xav dhia dej ntau ntxiv rau cov ncauj lus hais txog analog.

Txhawm rau teeb tsa lub network teeb tsa, nyem rau ntawm config.h tab hauv daim duab. Koj yuav tsum teeb tsa koj li Adafruit IO lub npe siv hauv IO_USERNAME txhais, thiab koj li Adafruit IO tus yuam sij hauv IO_KEY txhais. Koj tuaj yeem pom koj lub npe siv thiab tus yuam sij nyob rau sab xis ntawm lub vijtsam hauv koj Arduino IO (piv txwv ntawm daim duab 2)

#define IO_USERNAME "koj_username"

#define IO_KEY "koj_key"

WiFi Config WiFi tau qhib los ntawm lub hauv paus hauv config.h yog li yog tias koj siv ib qho ntawm WiFi cov laug cam txhawb nqa, koj tsuas yog yuav tsum hloov kho WIFI_SSID thiab WIFI_PASS xaiv hauv config.h tab.

#define WIFI_SSID "your_ssid" #define WIFI_PASS "your_pass"

Arduino CodeIf koj muaj kev hloov pauv te teeb tsa saum toj no, peb tuaj yeem mus ntxiv rau qhov tseeb code, adafruit_08_analog_in. Tus pin tiv thaiv hauv qhov piv txwv no yog statet ntawm AO. Nov yog tus pin raug raws li koj tau tso koj cov leeg nqaij tso rau ntawm lub rooj tsav khoom hauv qib 2.

Qhov piv txwv no siv lub ntsuas hluav taws xob, vim tias peb siv cov leeg nqaij peb yuav hloov lub npe no. Nws tsis muaj teeb meem yog tias koj ua qhov no, nws yuav tsuas yog ua kom zoo dua qub. Hloov PHOTOCELL_PIN mus rau MUSCLESENSOR_PIN ua qhov no hauv ob qhov chaw ntawm daim duab.

/************************ Piv txwv pib ntawm no ********************** *********/

// analog pin 0 #define PHOTOCELL_PIN A0

Hauv qhov codeline kawg tau muab ncua. Qhov kev ncua no yog 1 thib ob, peb tab tom teeb tsa yog 2 vib nas this yog li 2000. Peb ua qhov no vim tias muaj daim ntawv tso cai ntawm Adafruit IO nrog cov ntaub ntawv txwv, nyob hauv ob vib nas this cov duab kos tshaj qhov txwv cov ntaub ntawv thiab nws yuav muab TSHUAJ TSHWJ XEEB.. Dab tsi txhais tau tias tsis muaj los qhov tseem ceeb hauv. Teeb qhov no rau ob vib nas this tiv thaiv qhov no.

// tos ib pliag (1000 milliseconds == 1 thib ob) ncua (2000);

Nov yog qhov koj yuav tsum tau hloov pauv hauv daim duab kos kom nws ua haujlwm. Yog koj xav paub raws nraim li cas tag nrho cov cai ua haujlwm. Koj tuaj yeem pom nws ntawm kev kawm Adafruit, nrog kev piav qhia ntawm txhua txoj cai thaiv.

CheckUpload cov duab kos rau koj lub rooj tsavxwm, thiab qhib Arduino Serial Monitor. Tam sim no koj pawg thawj coj yuav tsum txuas rau Adafruit IO.

Tam sim no koj tuaj yeem tuav koj txhais caj npab, thiab koj yuav tsum pom qhov hloov pauv qhov raug xa mus rau Adafruit IO (zoo li hauv daim duab 3). Yog tias koj tsis pom ib qho txiaj ntsig hauv Serial monitor, xyuas seb koj puas tau teeb tsa Baud tus nqi hauv Serial monitor rau 115200.

Adafruit IO DashboardCheck koj lub dashboard ntawm Adafruit IO, thiab koj yuav tsum pom qhov ntsuas thiab kab kab lus teb rau qhov hloov pauv ntawm MyoWare Muscle Sensor qhov tseem ceeb.

Kauj Ruam 4: Adafruit IO Trigger Setup

Adafruit IO Trigger Teeb
Adafruit IO Trigger Teeb
Adafruit IO Trigger Teeb
Adafruit IO Trigger Teeb

Txog tam sim no peb muaj peev xwm los tawm tswv yim los ntawm MyoWare Muscle sensor mus rau Adafruit IO ua haujlwm. Tam sim no peb tab tom yuav pib nyeem cov ntaub ntawv no. Yog li ntawd tom qab 5 zaug tus nqi siab dua X ntawm Muscle sensor tau kuaj pom, qhov kev ua yog ua los ntawm Neopixel coj sawb.

Nqe lus no yog rau kuv qhov uas kuv yuav tsum tshuaj xyuas seb kuv yuav nyeem Adafruit IO keeb kwm li cas. Kuv tau ua haujlwm nrog Feeds thiab Dashboards ua ntej, yog li kuv xav tias pub thiab dashboard uas tau tsim tuaj yeem nyeem qhov no thiab tsim qhov ua ntawm no hauv Arduino. Txog tam sim no kuv tsis tau ua tiav. Tom qab kev tshawb fawb ntau thiab Adafruit IO, Kuv pom tias qhov kev nqis tes ua tuaj yeem cuam tshuam nrog Kev Ua Haujlwm hauv Adafruit IO. Kawm paub ntau ntxiv txog Triggers.

Ib qho ntxiv FeedBefore peb tuaj yeem ua rau Trigger peb yuav tsum tsim lwm qhov pub kom peb tuaj yeem sau nws hauv Arduino kom tau txais te tso tawm. Tsim kev pub mis nrog lub npe AlertTriggered.

Ua kom muaj TriggerNext rau headers Pub thiab Dashboard yog Trigger, mus ntawm no. Tsim tus txhais tshiab. Koj yuav raug nug yog tias koj xav tsim Reactive Trigger lossis Schedule Trigger, xaiv Reactive Trigger thiab nyem rau ntawm create. Qhov no yog vim koj tsuas xav ua qee yam thaum muaj qee yam tshwm sim (duab 1).

Ib yam ntawm cov khoom yuav tsum tau teeb tsa (Cov kauj ruam tom ntej kuj tseem muaj nyob hauv daim duab 2).- Xaiv cov khoom sib piv thaum xub thawj Yog, yog li cov tswv yim yuav raug coj los ntawm no.

-Yog koj xaiv qhov zoo dua, qhov no vim tias koj xav ua qee yam thaum tus nqi ntau dua li tus lej.

-Comperison tus nqi koj tuaj yeem nkag mus rau koj tus lej xav tau los qhib lub zog. Kuv tau ua 600 qhov no.

-Nrog arduino koj yuav tsum tau txais cov lus tawm tswv yim thaum nws ntau dua 600: yog li Tom qab ntawd xaiv tshaj tawm cov lus rau:.

-Cov tom qab uas koj tuaj yeem xaiv koj qhov pub thib ob tsim AlertTriggered.

Thaum kawg nyem rau ntawm tsim.

Kauj Ruam 5: Neopixel Tso Tawm

Neopixel Tso Tawm
Neopixel Tso Tawm

Kauj ruam kawg yog tsim cov zis. Ua tiav hauv Arduino kos duab uas koj tau kho, los ntawm kev hu rau AlertTriggered pub (uas koj tau tsim hauv qib dhau los).

Yuav kom muaj peev xwm tsim tawm koj yuav tsum xub txuas Neopixel coj sawb rau NodeMCU.- + 5v (sab laug) xaim ntawm koj cov hlua coj ntawm 3v ntawm koj NodeMCU- GND (txoj cai) xaim ntawm G ntawm Node (G = GND))- Chaw xaim DIN ntawm LED ntawm D5 (lossis lwm qhov chaw nres nkoj D)

CodeI tau suav tag nrho cov duab kos nrog kev hloov pauv hauv cov kauj ruam no ua cov ntawv (tuaj yeem pom nyob hauv qab ntawm cov kauj ruam no). Nov yog tib daim duab uas koj tau ua haujlwm nrog ob peb kauj ruam dhau los tab sis tam sim no Daim Sketch zaum kawg suav nrog cov kauj ruam uas koj yuav tsum tau ua txhawm rau tsim kom tau cov txiaj ntsig. adafruitio_musclesensor_neopixel cov ntaub ntawv. Qhov no ua haujlwm nrog config.h koj tau teeb tsa yav dhau los nrog koj cov ntaub ntawv. Al cov lej thaiv tau suav nrog cov lus pom yog li koj tuaj yeem pom dab tsi tshwm sim.

Cov ntaub ntawv tso tawm dab tsi tau teev tseg Hauv cov cai no kuv tau tsim qhov ua rau, thaum AlertTriggered (qhov peb tau tshaj tawm hauv qib dhau los dhau tus nqi ntau dua 600) tau ua rau ntau dua 5 zaug. Qhov no txhais tau tias thaum nws tshwm sim, Neopixel coj sawb tau teeb los ntawm dawb rau liab. Qhov no yuav tshwm sim rau ib pliag thiab dua li lub xeev liab yuav ploj mus thiab tau rov qab mus rau lub xeev dawb dua.

Ua kom pom tseeb rau koj raws li tus programmer, txheej txheej kawg yog rau Serial Monitor. Qhov txiaj ntsig yog dab tsi thiab thaum twg koj tau ua rau qib ceeb toom. Ua ke nrog ntxiv cov vib nas this thaum lub xeev ceeb toom qhib, kom txog rau tom qab 60 vib nas this nws hloov mus rau Lub Xeev ceeb toom tawm dua. Yog li qhov no yog nyob ntawm yeem.

// los qhia cov vib nas this dhau hauv Serial Monitor thaum lub alartstate nyob ntawm Serial.println ("Ob vib nas this dhau:"); Serial.println (secondsPassed); } lwm {secondsPassed = 0; }

Tshawb xyuas yog tias koj muaj cov theem ua tiav lossis tau txais daim duab kos adafruitio_musclesensor_neopixel cov ntaub ntawv nrog koj tus kheej teeb tsa.h koj tuaj yeem xa nws mus rau koj NodeMCU. Yog tias nws ua tiav koj yuav tsum pom qee yam zoo ib yam li hauv qab no hauv koj li Serial Monitor:

Txuas mus rau Adafruit IO…

Adafruit IO txuas nrog. Xa -> 23 Xa -> 78

Duab 1 yog Serial Monitor thaum nws nyob hauv Alertmode.

Nws tsis ua haujlwm? Txheeb xyuas cov hauv qab no- Txheeb xyuas yog tias config.h suav nrog hauv txoj hauv kev- Koj puas tau tso qhov raug Adafruit IO Username thiab Key- Koj puas tau tso rau hauv SSID txoj cai Wifi tus lej zais- Koj puas tau tso cov xov txuas ntawm MyoWare Muscle Sensor txoj cai thiab los ntawm Neopixel Led Sawb

Los yog txheeb xyuas cov kauj ruam dhau los.

Kauj Ruam 6: Cov txiaj ntsig

Hooray koj ua tiav! Txhawm rau ua kom pom thiab pom qhov khoom kawg hauv kev nqis tes kuv tau suav nrog daim vis dis aus.

Pom zoo: