Cov txheej txheem:

Yuav Ua Li Cas DIY Arduino Obstacle Zam Txim Neeg Hlau Hauv Tsev: 4 Kauj Ruam
Yuav Ua Li Cas DIY Arduino Obstacle Zam Txim Neeg Hlau Hauv Tsev: 4 Kauj Ruam

Video: Yuav Ua Li Cas DIY Arduino Obstacle Zam Txim Neeg Hlau Hauv Tsev: 4 Kauj Ruam

Video: Yuav Ua Li Cas DIY Arduino Obstacle Zam Txim Neeg Hlau Hauv Tsev: 4 Kauj Ruam
Video: How I Made this Electric Car that can go Anywhere 2024, Hlis ntuj nqeg
Anonim
Image
Image

Nyob Zoo Cov Menyuam, Hauv Cov Lus Qhia no, koj yuav ua ib qho kev tiv thaiv kom tsis txhob muaj neeg hlau. Cov lus qhia no cuam tshuam nrog kev tsim cov neeg hlau nrog lub ntsuas hluav taws xob ultrasonic uas tuaj yeem txheeb xyuas cov khoom nyob ze thiab hloov lawv cov kev taw qhia kom zam cov khoom no. Lub ntsuas hluav taws xob ultrasonic yuav txuas rau lub cav servo uas niaj hnub ntsuas sab laug thiab sab xis nrhiav cov khoom hauv nws txoj kev.

Yog li, yam tsis muaj ado ntxiv, Cia peb pib!

Kauj Ruam 1: Yam Koj Xav Tau hauv Txoj Haujlwm no:

Yam Koj Xav Tau hauv Txoj Haujlwm no
Yam Koj Xav Tau hauv Txoj Haujlwm no
Yam Koj Xav Tau hauv Txoj Haujlwm no
Yam Koj Xav Tau hauv Txoj Haujlwm no

Nov yog Daim Ntawv Teev Npe:

1) Arduino Uno

2) Tsav Tsheb Tsav Tsheb

3) Iav Tsav, Ncej thiab log teeb

4) Servo Tsav

5) Ultrasonic Sensor

6) Li-ion Roj teeb (2x)

7) Cov Roj Teeb

8) Txiv neej thiab poj niam Jumper hlau

9) Soldering Hlau

10) Charger

Kauj Ruam 2: Daim duab Circuit Court

Daim duab Circuit Court
Daim duab Circuit Court

Ua hauj lwm:

Ua ntej mus ua haujlwm ntawm txoj haujlwm, nws yog ib qho tseem ceeb kom nkag siab tias ultrasonic sensor ua haujlwm li cas. Lub hauv paus ntsiab lus tom qab ua haujlwm ntawm ultrasonic sensor yog raws li hauv qab no:

Siv lub teeb liab sab nraud, Trig tus pin ntawm lub ntsuas hluav taws xob ultrasonic tau ua logic siab rau tsawg kawg 10µs. Ib qho sonic tawg los ntawm lub tshuab xa hluav taws xob xa. Qhov no suav nrog 8 tus mem tes ntawm 40KHz.

Cov teeb liab rov qab los tom qab tsoo saum npoo thiab tus txais tau pom lub teeb liab no. Echo tus pin yog siab los ntawm lub sijhawm xa cov teeb liab thiab tau txais nws. Lub sijhawm no tuaj yeem hloov pauv mus rau qhov deb siv qhov kev suav tsim nyog.

Lub hom phiaj ntawm txoj haujlwm no yog txhawm rau ua kom muaj kev txwv tsis pub neeg hlau siv ultrasonic sensor thiab Arduino. Txhua qhov kev sib txuas tau ua raws li daim duab qhia chaw. Kev ua haujlwm ntawm txoj haujlwm tau piav qhia hauv qab no.

Thaum tus neeg hlau siv lub zog, ob lub cav ntawm tus neeg hlau yuav ua haujlwm ib txwm thiab tus neeg hlau txav mus rau tom ntej. Lub sijhawm no, lub ntsuas hluav taws xob ultrasonic suav tsis txheeb qhov deb ntawm tus neeg hlau thiab lub ntsej muag cuam tshuam.

Cov ntaub ntawv no yog ua los ntawm Arduino. Yog hais tias qhov kev ncua deb ntawm tus neeg hlau thiab lub teeb meem tsawg dua 15cm, Tus Neeg Hlau nres thiab tshuaj xyuas sab laug thiab sab xis rau qhov kev ncua deb tshiab siv Servo Motor thiab Ultrasonic Sensor. Yog tias qhov kev ncua deb ntawm sab laug ntau dua li ntawm sab xis, tus neeg hlau yuav npaj rau sab laug. Tab sis ua ntej, nws thim rov qab me ntsis thiab tom qab ntawd ua rau Lub Cev Tsav Tsheb Sab laug tig rov qab.

Ib yam nkaus, yog tias txoj kev nrug deb tshaj li qhov nyob deb, Neeg Hlau npaj txoj kev sib hloov. Cov txheej txheem no txuas ntxiv mus tas li thiab tus neeg hlau txuas ntxiv mus yam tsis muaj kev cuam tshuam dab tsi.

Kauj Ruam 3: Programming Arduino UNO

#suav nrog

#suav nrog

#suav nrog

# txhais TRIG_PIN A1

# txhais ECHO_PIN A0

# txhais MAX_DISTANCE 200

# txhais MAX_SPEED 255 // teeb tsa ceev ntawm DC lub cav

# txhais MAX_SPEED_OFFSET 20

NewPing sonar (TRIG_PIN, ECHO_PIN, MAX_DISTANCE);

AF_DCMotor motor3 (3, MOTOR34_1KHZ);

AF_DCMotor motor4 (4, MOTOR34_1KHZ); Servo tswj;

boolean GoForward = tsis tseeb;

int nrug = 100; int speedSet = 0;

void teeb tsa () {

myservo.attach (10);

myservo.write (115); ncua (2000); nrug = readPing (); ncua (100); nrug = readPing (); ncua (100); nrug = readPing (); ncua (100); nrug = readPing (); ncua (100); }

void voj () {

int nrug R = 0; int nrug L = 0; ncua (40);

yog (nrug <= 15) {moveStop (); ncua (100); moveBackward (); ncua (300); moveStop (); ncua (200); nrugR = lookRight (); ncua (200); distanceL = saibLeft (); ncua (200);

yog (nrug R> = nrug L) {

turnRight (); moveStop (); } lwm {turnLeft (); moveStop (); }} lwm tus {moveForward (); } nrug = readPing (); }

int lookRight () {

myservo.write (50); ncua (500); int nrug = readPing (); ncua (100); myservo.write (115); rov nrug deb; }

int lookLeft () {

myservo.write (170); ncua (500); int nrug = readPing (); ncua (100); myservo.write (115); rov nrug deb; ncua (100); }

int readPing () {

ncua (70); int cm = sonar.ping_cm (); yog (cm == 0) {cm = 250; } rov cm; }

tsis muaj dabtsis moveStop () {

motor3.run (tso tawm);

motor4.run (tso tawm); }

tsis muaj dabtsis moveForward () {

yog (! goForward) {

GoForward = muaj tseeb;

motor3.run (FORWARD);

motor4.run (FORWARD); rau (speedSet = 0; speedSet <MAX_SPEED; speedSet += 2) // maj mam nqa nrawm kom tsis txhob ntsaws lub roj teeb nrawm dua {

motor3.setSpeed (speedSet);

motor4.setSpeed (speedSet); ncua (5); }}}

void moveBackward () {

GoForward = tsis tseeb;

motor3.run (rov qab);

motor4.run (rov qab); rau (speedSet = 0; speedSet <MAX_SPEED; speedSet += 2) // maj mam nqa nrawm kom tsis txhob ntsaws lub roj teeb nrawm dua {

motor3.setSpeed (speedSet);

motor4.setSpeed (speedSet); ncua (5); }}

void turnRight () {

motor3.run (FORWARD);

motor4.run (rov qab); ncua (500);

motor3.run (FORWARD);

motor4.run (FORWARD); }

void turnLeft () {

motor3.run (rov qab);

motor4.run (FORWARD); ncua (500);

motor3.run (FORWARD);

motor4.run (FORWARD); }

1) Rub tawm thiab teeb tsa Arduino Desktop IDE

  • windows -
  • Mac OS X -
  • Linux -

2) Rub tawm thiab muab tso rau NewPing lub tsev qiv ntawv (Ultrasonic sensor ua haujlwm lub tsev qiv ntawv) cov ntaub ntawv rau Arduino cov tsev qiv ntawv nplaub tshev.

  1. Rub tawm NewPing.rar hauv qab no
  2. Extract nws mus rau txoj kev - C: / Arduino / cov tsev qiv ntawv

3) Tshaj tawm cov cai rau Arduino pawg thawj coj saib ntawm USB cable

Download Code:

Kauj ruam 4: Zoo heev

Tam sim no koj tus neeg hlau tau npaj kom tsis txhob muaj teeb meem …

Kuv yuav zoo siab teb cov lus nug koj muaj

Email kuv: [email protected]

Lub Vev Xaib:

Sau npe yuav kuv tus YouTube Channel:

Koj li xyoob ntoo Instagram:

Facebook yog:

Ua Tsaug:)

Pom zoo: