Cov txheej txheem:

Tsim Koj Tus Kheej Lub Tsev Qiv Arduino: 5 Kauj Ruam
Tsim Koj Tus Kheej Lub Tsev Qiv Arduino: 5 Kauj Ruam

Video: Tsim Koj Tus Kheej Lub Tsev Qiv Arduino: 5 Kauj Ruam

Video: Tsim Koj Tus Kheej Lub Tsev Qiv Arduino: 5 Kauj Ruam
Video: Tsis Hlub Tso Luag Yuav - SODA Poj Laib Khej Me (Cover) 2024, Kaum ib hlis
Anonim
Tsim Koj Tus Kheej Arduino Library
Tsim Koj Tus Kheej Arduino Library

Hav sawv daws. Hauv qee qhov haujlwm koj yuav tsum tsim koj lub tsev qiv ntawv thaum koj tsis tuaj yeem siv cov tsev qiv ntawv npaj tau. Lossis koj tuaj yeem tsim koj lub tsev qiv ntawv los ntawm nws tus qauv. Hnub no, kuv yuav qhia koj yooj yim npaum li cas koj tuaj yeem tsim koj lub tsev qiv ntawv thiab siv hauv koj tus lej…

Kauj ruam 1: Qhia

=> Dab tsi yog. H FİLE?

Ib daim ntawv H yog cov ntaub ntawv header uas tau hais los ntawm C, C ++ lossis Lub Hom Phiaj-C qhov chaws cov ntaub ntawv. Nws yuav muaj qhov hloov pauv, qhov ruaj khov, thiab kev ua haujlwm uas tau siv los ntawm lwm cov ntaub ntawv hauv qhov haujlwm ua haujlwm. H cov ntaub ntawv tso cai siv feem ntau los sau ib zaug thiab hais los ntawm lwm cov ntaub ntawv thaum xav tau.

=> Vim li cas peb thiaj siv C lossis C ++ rau kev tsim peb lub tsev qiv ntawv?

Arduino software suav nrog kev txhim kho ib puag ncig (IDE) thiab cov tsev qiv ntawv. IDE tau sau hauv Java thiab ua raws ib puag ncig ntawm cov lus ua lus. Cov tsev qiv ntawv tau sau ua C thiab C ++ thiab suav nrog AVR-GCC thiab AVR Libc..

Kauj ruam 2: Piv txwv CODE

Hauv qhov haujlwm no peb tsim lub tsev qiv ntawv ntawm HC-SR04 sensor.

#suav nrog "mylibrary.h"

HC HC, HC1;

void teeb tsa () {

Serial.begin (9600); HC.trigPin (A0); HC.echoPin (A1); HC1.trigPin (A2); HC1.echoPin (A3); }

void voj () {

ob npaug nrug1 = HC.calculate (A1, A0); ob npaug nrug2 = HC1.calculate (A3, A2);

Serial.print ("nrug1 =");

Serial.println (nrug 1); Serial.print ("nrug2 ="); Serial.println (nrug 2); ncua (500); }

Kauj ruam 3: PARTS

XEEM
XEEM

Nov yog cov npe ntawm ntu uas kuv tau siv los ua txoj haujlwm no:

  • Arduino UAS
  • Cov qhob cij
  • HC-SR04 *2 (koj tuaj yeem siv ib qho nkaus xwb)
  • Jumper Wires (txiv neej rau txiv neej thiab txiv neej rau poj niam)

Kauj Ruam 4: SCHEMA

SCHEMA
SCHEMA

Kauj ruam 5: RESULT

Pom zoo: