Cov txheej txheem:

Sib cuam tshuam Servo Tsav Nrog NodeMCU: 6 Cov Kauj Ruam (nrog Duab)
Sib cuam tshuam Servo Tsav Nrog NodeMCU: 6 Cov Kauj Ruam (nrog Duab)

Video: Sib cuam tshuam Servo Tsav Nrog NodeMCU: 6 Cov Kauj Ruam (nrog Duab)

Video: Sib cuam tshuam Servo Tsav Nrog NodeMCU: 6 Cov Kauj Ruam (nrog Duab)
Video: Технический разговор TUDev с профессором Борой Озкан - Финтех и будущее финансов 2024, Kaum ib hlis
Anonim
Interfacing Servo Tsav Nrog NodeMCU
Interfacing Servo Tsav Nrog NodeMCU

Nyob zoo sawv daws, Nov yog kuv thawj qhov haujlwm Qhia.

Yog li koj xav pib nrog NodeMCU? Zoo, kuv nyob ntawm no los qhia rau koj. Hnub no, kuv yuav qhia koj yuav pib li cas nrog NodeMCU. Cia peb mus!

NodeMCU muaj nyob rau hauv board ESP8266-12E ua rau lub rooj tsavxwm haum rau IoT (Internet Ntawm Yam). Hauv Cov Lus Qhia Kuv yuav qhia koj yuav pib li cas nrog Servo siv NodeMCU.

Kauj Ruam 1: Cov Ntaub Ntawv Yuav Tsum Tau

Cov Ntaub Ntawv Yuav Tsum Tau
Cov Ntaub Ntawv Yuav Tsum Tau
Cov Ntaub Ntawv Yuav Tsum Tau
Cov Ntaub Ntawv Yuav Tsum Tau
Cov Ntaub Ntawv Yuav Tsum Tau
Cov Ntaub Ntawv Yuav Tsum Tau

Nov yog cov npe ntawm cov khoom siv xav tau kom pib nrog NodeMCU,

Kho vajtse Cheebtsam

  1. NodeMCU
  2. Servo Tsav
  3. Pawg Mov Ci
  4. Jumper Hlau
  5. Micro USB Cable

Software Cheeb Tsam

Arduino IDE Cov

Kauj Ruam 2: Cov Lus Qhia Kho Vajtse

Kev Qhia Kho Vajtse
Kev Qhia Kho Vajtse
Kev Qhia Kho Vajtse
Kev Qhia Kho Vajtse

Breadboard yog dab tsi?

Nws yog lub hauv paus tsim qauv, qhov uas koj tuaj yeem ntsaws cov khoom thiab tshem tawm lawv tau yooj yim. Thov xa mus rau daim duab kom pom tias nws tsim sab hauv. Feem ntau muaj 2 txoj hlua ntawm txhua sab uas qhia txog txoj hlua fais fab. Nws tau ua kom yooj yim txuas txhua qhov ntawm (-) thiab (+) ua ke.

Dab tsi yog Servo?

Servo motors yog cov cuab yeej zoo uas tuaj yeem tig mus rau lub kaum ntse ntse tshwj xeeb lossis hu ua txoj haujlwm.

Feem ntau, lawv muaj servo caj npab uas tuaj yeem tig 180 degrees. Siv NodeMCU, peb tuaj yeem tswj hwm servo kom mus rau txoj haujlwm tshwj xeeb. Yooj yim li ntawd! Ntawm no peb yuav pom yuav ua li cas txuas lub cav servo thiab tom qab ntawd yuav ua li cas tig nws mus rau txoj haujlwm sib txawv.

Kev sib txuas rau Servo

Txoj haujlwm tom ntej yog txuas koj lub cav servo. Muaj ob hom sib txawv ntawm servo:

  1. Dawb - Liab - Dub wired servo
  2. Txiv kab ntxwv - Liab - Xim av wired servo

Yog tias koj lub servo muaj Dawb - Liab - Cov xov dub, tom qab ntawd txuas nws raws li hauv qab no

  • Cov hlau dawb txuas rau Digital tus pin D4
  • Cov xaim dub txuas rau GND tus pin
  • Cov hlau liab txuas rau 3V3 tus pin

Yog tias koj lub servo muaj Txiv kab ntxwv - Liab - Xim av xaim, tom qab ntawd txuas nws raws li hauv qab no

  • Txiv kab ntxwv hlau txuas rau Digital tus pin D4.
  • Cov xim daj txuas rau GND tus pin
  • Cov hlau liab txuas rau 3V3 tus pin

Kauj ruam 3: Rub tawm Arduino IDE

Rub tawm Arduino IDE
Rub tawm Arduino IDE

Txhawm rau pib peb yuav tsum rub tawm Arduino IDE (Kev Txhim Kho Ib Leeg Ib puag ncig) thiab qee tus tsav tsheb tsim nyog.

  1. Txhawm rau rub tawm lub software lub taub hau mus rau Arduino qhov chaw:
  2. Nyem rau ntawm Software Nyem rau ntawm Windows, Mac lossis Linux raws li koj li Operating System.
  3. Koj tuaj yeem pub dawb yog tias koj xav tau lossis tsuas yog rub tawm.
  4. Thaum qhov no ua tiav, koj yuav tsuas xav tau txuas ntxiv cov kauj ruam txhawm rau rub nws mus rau koj lub computer.
  5. Koj ua tiav!

Kauj Ruam 4: Npaj Arduino IDE

Npaj Arduino IDE
Npaj Arduino IDE
Npaj Arduino IDE
Npaj Arduino IDE

Tom qab rub tawm Arduino IDE mus rau

  1. Cov ntaub ntawv tab thiab tom qab ntawv nyem rau Preferences.
  2. Hauv Tus Thawj Saib Xyuas Haujlwm Ntxiv URLs ntxiv qhov txuas hauv qab no (https://arduino.esp8266.com/stable/package_esp8266com_index.json)
  3. Nyem OK thiab tom qab ntawd mus rau
  4. Cov cuab yeej - Cov laug cam - Tus thawj tswj tuav

Hauv kev tshawb nrhiav hom esp8266> nyem esp8266 los ntawm ESP8266 Zej Zog - Nyem Nruab

Tam sim no koj tau teeb tsa Arduino IDE los ua haujlwm nrog NodeMCU.

Kauj Ruam 5: Coding Sijhawm

Sijhawm Coding
Sijhawm Coding

Cov kauj ruam tom ntej yog sau qee cov cai los tswj hwm Servo.

Rub tawm "Servo.ino" cov ntaub ntawv thiab qhib nws hauv Arduino IDE. Tom qab ntawd Tsim cov duab kos tshiab thiab muab cov lej hauv qab no tso rau hauv arduino IDE thiab nyem Upload.

#suav nrog

Servo tsav;

void teeb tsa () {

servo.attach (2); // D4 ib

servo.write (0); cov.

ncua (2000);

}

void voj () {

servo.write (90); cov.

ncua (1000);

servo.write (0); cov.

ncua (1000);

}

Txoj cai yuav siv sijhawm li ob peb feeb txhawm rau rub tawm thiab tom qab ntawd koj yuav tsum pom Servo hloov lub kaum sab xis ntawm 0 ° txog 90 ° ntawm lub sijhawm teev tseg hauv txoj cai.

Koj tuaj yeem tinker nrog nws yog tias koj nyiam, lossis tsuas yog siv nws zoo li nws yog.

Kauj Ruam 6: Tshaj Tawm Koj Txoj Haujlwm

Rub tawm Koj Txoj Haujlwm
Rub tawm Koj Txoj Haujlwm
Rub tawm Koj Txoj Haujlwm
Rub tawm Koj Txoj Haujlwm
  1. Mus cuab yeej
  2. Pawg Thawj Coj> NodeMCU 1.0 (ESP - 12E Module)
  3. Chaw nres nkoj (Xaiv qhov chaw zoo)

** Nco ntsoov tias koj tau xaiv koj tus qauv NodeMCU thiab qhov chaw nres nkoj raug txheeb xyuas (saib duab).

Tom qab ntawd tsuas yog nyem lub pob Upload **

Pom zoo: