Cov txheej txheem:

Arduino Tswj Cov Neeg Hlau Caj Npab Los Ntawm Lego Mindstorm: 6 Kauj Ruam
Arduino Tswj Cov Neeg Hlau Caj Npab Los Ntawm Lego Mindstorm: 6 Kauj Ruam

Video: Arduino Tswj Cov Neeg Hlau Caj Npab Los Ntawm Lego Mindstorm: 6 Kauj Ruam

Video: Arduino Tswj Cov Neeg Hlau Caj Npab Los Ntawm Lego Mindstorm: 6 Kauj Ruam
Video: Could this tiny tube of metal fix our broken suspension? - Edd China's Workshop Diaries 28 2024, Hlis ntuj nqeg
Anonim
Image
Image

Rov ua dua ob lub qub Lego Mindstorm motors rau hauv rab phom tuav tswj los ntawm Arduino Uno.

Qhov no yog Hack Sioux Falls qhov haujlwm uas peb sib tw cov menyuam los tsim qee yam txias nrog Arduino.

Kauj Ruam 1: Qhov Yuav Tsum Tau

Cov khoom siv xav tau:

  • 2 loj Lego ev3 lub siab lub cev muaj zog
  • Ntau yam ntawm Lego cov cuab yeej thev naus laus zis thiab cov zog
  • Ib Arduino Uno
  • Tsav tsheb
  • Ib daig ntawm perfboard
  • Cov xov hlau ntev
  • 4 resistors
  • 4 cov nyees khawm
  • Lub roj teeb USB nqa tau
  • Ib tug usb charger
  • Solder thiab soldering hlau
  • Teeb ntawm cov ntsia hlau
  • Ib tug hlau txiav

Kauj Ruam 2: Tshem Lub Tsev Tsav Tsheb

Pib los ntawm kev tshem cov ntsia hlau rau sab nraub qaum ntawm ob lub cav, tom qab ntawd tshem lub kaus mom dawb. Koj tuaj yeem muab lawv pov tseg.

Rub lub cav tawm, ua kom tsis txhob tshem ib qho ntawm lub zog ntawm sab hauv. Yog tias koj tshem tawm ib qho ntawm lub zog, tsuas yog rub lawv rov qab rau hauv qhov chaw.

Thaum cov motors tau raug tshem tawm, txiav tawm lub plugin ntawm qhov kawg ntawm lub cav nrog cov xaim txiav.

Kauj Ruam 3: Cuam Tshuam ntawm Cov Ntev Ntev

Ntxiv Motors rau Motor Board
Ntxiv Motors rau Motor Board

Cuab yeej ntawm qee qhov tshiab, ntev dua xaim. Qhov no yooj yim dua li nws zoo li thiab tsuas yog siv ob peb feeb yog tias koj paub tias koj tab tom ua dab tsi.

Muab lub cav rov qab rau hauv lub hnab yas, tom qab ntawd ntswj nws rov qab. Tam sim no koj tuaj yeem pib tsim sab caj npab. Koj tuaj yeem tsim koj tus kheej tsim lossis tawm ntawm ib qho hauv daim duab.

Kauj Ruam 4: Ntxiv Cov Tsav Tsheb rau Tsav Tsheb

Siv Phillips ntswj ntsia hlau los ntsaws cov xov hlau los ntawm lub cav mus rau hauv lub rooj tsav tsheb raws li qhia hauv daim duab. Tom qab ntawd ntsaws lub rooj tsavxwm rau hauv Arduino Uno.

Txiav lub USB them nyiaj ib nrab, nthuav tawm cov xaim sab hauv. Tshem tawm cov rwb thaiv tsev, tom qab ntawd hle ob txoj hauv kev zoo thiab tsis zoo. Tom qab ntawd ntsaws nws rau hauv lub rooj tsav tsheb

Kauj Ruam 5: Tsim Hloov Pawg Thawj Coj

Tsim Hloov Pawg Thawj Coj
Tsim Hloov Pawg Thawj Coj
Tsim Hloov Pawg Thawj Coj
Tsim Hloov Pawg Thawj Coj
Tsim Hloov Pawg Thawj Coj
Tsim Hloov Pawg Thawj Coj

Solder ntawm tus tiv thaiv, hloov pauv, thiab xov hlau mus rau lub perfboard zoo li daim duab.

Ntxiv ob peb tus poj niam txuas tus pin rau ntawm perfboard thiab lub rooj tsav tsheb zoo li daim duab qhia, tom qab ntawd txuas ob.

Kauj Ruam 6:

Duab
Duab
Duab
Duab

Txuas lub Arduino rau hauv lub khoos phis tawj thiab tso cov lej no rau hauv Arduino.

Peb siv lub tsev qiv ntawv tsav tsheb los ntawm Adafruit, tab sis lwm lub tsev qiv ntawv tsav tsheb yuav ua haujlwm ib yam.

#suav nrog

int buttonLeft = A0; int buttonRight = A1; int khawmOpen = A2; int khawmClose = A3; AF_DCMotor motorRotate (1); AF_DCMotor motorGrabber (2); teeb tsa tsis muaj dab tsi () {Serial.begin (9600); // teeb tsa Lub tsev qiv ntawv Serial ntawm 9600 bps Serial.println ("Tsav lub cev!"); pinMode (buttonLeft, INPUT); pinMode (buttonRight, INPUT); pinMode (khawm qhib, INPUT); pinMode (khawm kaw, INPUT); // qhib lub cav motorRotate.setSpeed (200); motorGrabber.setSpeed (200); motorRotate.run (QHIA); motorGrabber.run (QHIA); } void loop () {int buttonStateLeft = digitalRead (buttonLeft); int buttonStateRight = digitalRead (buttonRight); int buttonStateOpen = digitalRead (khawm qhib); int buttonStateClose = digitalRead (khawm kaw); yog (buttonStateLeft == HIGH) {Serial.println ("Button Left"); motorRotate.run (rov qab); ncua (250); motorRotate.run (QHIA); } lwm tus yog (buttonStateRight == HIGH) {Serial.println ("Button Right"); motorRotate.run (FORWARD); ncua (250); motorRotate.run (QHIA); } lwm tus yog (buttonStateOpen == HIGH) {Serial.println ("Khawm Qhib"); motorGrabber.run (rov qab); ncua (150); motorGrabber.run (QHIA); } lwm tus yog (buttonStateClose == HIGH) {Serial.println ("Khawm Kaw"); motorGrabber.run (FORWARD); ncua (150); motorGrabber.run (NYEEM); }}

Pom zoo: