Cov txheej txheem:

Arduino Servo Nruas Tshuab: 4 Cov Kauj Ruam
Arduino Servo Nruas Tshuab: 4 Cov Kauj Ruam

Video: Arduino Servo Nruas Tshuab: 4 Cov Kauj Ruam

Video: Arduino Servo Nruas Tshuab: 4 Cov Kauj Ruam
Video: Jason Barnes, baterista gracias a un brazo robótico - le mag 2024, Hlis ntuj nqeg
Anonim
Image
Image

Nov yog qhov yooj yim ob lub micro-servo thiab Arduino Uno tswj lub tshuab nruas lossis neeg hlau. Cov servos tau teeb tsa ntawm L-zoo li tus ntoo uas tau tuav rau lub nruas nruas nrog 4 tus hlau nplaum muaj zog. Lub caj npab servo tau muab khi rau ob txoj hlua uas ua haujlwm ua lub nruas-pas. Nws nrov heev tab sis tsis nrov heev. Ntau qhov nrov nrov tuaj yeem tau txais los ntawm kev siv tus qauv loj servos thiab cov nruas tiag uas yog hnyav dua me ntsis. Tab sis qhov ntawd tseem yuav xav tau lub zog cais cais rau cov servos. Los ntawm kev siv micro-servos Arduino cov khoom siv txaus txaus tam sim no rau lub zog lawv ncaj qha yam tsis muaj lub zog sib cais.

Cov vis dis aus qhia kuv qhov kev sim ntawm kev ua haujlwm yooj yim ntawm Wipeout nruas solo. Yog lawm nws tsis yog qhov tseeb 160 ntaus ib feeb tab sis qhov ntawd tuaj yeem yooj yim tau los ntawm kev ntxiv lwm qhov kev pabcuam uas yuav zoo nkauj heev. Kuv tsis tau suav qhov dab tsi saum toj kawg nkaus bpm uas tuaj yeem tau txais los ntawm kev siv servo thiab nws xav tau qee qhov qeeb hauv kev tau txais cov nruas los ntawm nws qhov chaw nres tsheb mus rau lub nruas taub hau.

Cov lus sib dhos uas koj tuaj yeem tsim tsuas yog txwv los ntawm koj lub tswv yim thiab lub tshuab nruas yog cov phooj ywg zoo tshaj plaws los ua si nrog ntau dua li lub tshuab nruas digital, yog tias koj yog tshuab raj.

Tsuas yog qhov poob qis yog lub suab nrov servo uas tsis yog qhov pom tau tiag tiag txawm hais tias lub koob yees duab suab zoo li tuaj tos nws qhov tsim nyog.

Kauj ruam 1: Tsim kom muaj Servo Bracket

Ua kom Servo Bracket
Ua kom Servo Bracket
Ua kom Servo Bracket
Ua kom Servo Bracket

Cov khoom siv no yog tsim los ntawm qee daim kab xev ntawm kev nyiam plywood uas kuv muaj ntawm tes. Kuv tsim L-puab los ntawm bolted ob daim ua ke nrog hlau L-bracket. Tom qab ntawd ib qho me me ntawm cov ntoo tau lo rau saum kab txaij los tuav ob lub servos.

Kuv muaj ob lub tswv yim pab ua ke uas kuv tau ntsia rau ntawm cov ntoo.

Kuv siv 4 lub hlau nplaum neodymium los tuav lub bracket rau lub nruas nruas.

Kauj Ruam 2: Hlau Servos rau Arduino Uno

Hlau Servos rau Arduino Uno
Hlau Servos rau Arduino Uno

Cov servos vcc (nruab nrab xaim) mus rau Arduino 5 v pins.

Cov av hauv av mus rau Arduino av.

Cov xov hlau teeb liab mus rau tus pin 6 thiab 7.

Cov ntaub thaiv npog servo yuav ua rau nws yooj yim dua yog tias koj muaj.

Kauj Ruam 3: Arduino Code…

Hauv qab no yog daim duab yooj yim los ua si Wipeout. Koj tsuas yog yuav tsum hloov kho txoj haujlwm servo rau koj teeb tsa tshwj xeeb.

Muaj kev lom zem!

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#suav nrog "servo.h"

// servo nruas Jim Demello Lub Rau Hli 2018

Servo myservo1, myservo2;

int servoPin6 = 6; // servo cov

int servoPin7 = 7;

tsis muaj dab tsi myServo (int servoPosition, int servoNumber) {

yog (servoNumber == 1) {

myservo1.write (servoPosition);

}

yog (servoNumber == 2) {

myservo2.write (servoPosition);

}

}

void doOneEighthNote (int servoNumber, int tuav) {

int delayVal = 60;

yog (servoNumber == 1) {

yog (ntaus) {yeej = 10; // yog tuav = 1 ces ntxiv me ntsis ntxiv servo nqis rau thump zog

}

myServo (150 + yeej, servoNumber); // lej

ncua (delayVal);

myServo (100, servoNumber); // nce

ncua (delayVal);

}

yog (servoNumber == 2) {

yog (ntaus) ntaus = -10;

myServo (60 + yeej, servoNumber); // lej

ncua (delayVal);

myServo (80, servoNumber); // nce

ncua (delayVal);

}

}

void teeb tsa ()

{

// Serial.begin (9600);

myservo1.attach (servoPin6, 1000, 2000); // txuas cov servo ntawm tus pin 9 rau cov khoom siv servo

myservo1.write (100);

myservo2.attach (servoPin7, 1000, 2000); // txuas cov servo ntawm tus pin 9 rau cov khoom siv servo

myservo2.write (90);

}

void voj () {

rub tawm (); // rub tawm lub nruas niaj hnub

// doOneEighthNote (2, 0);

ncua (40);

}

tsis muaj dab tsi rub tawm () {

doOneEighthNote (2, 1); doOneEighthNote (1,0); doOneEighthNote (2, 0); doOneEighthNote (1,0); // thawj parm yog tus lej servo thiab parm thib ob raug ntaus (1 = ntaus, 0 = tsis ntaus)

doOneEighthNote (2, 1); doOneEighthNote (1,0); doOneEighthNote (2, 0); doOneEighthNote (1,0);

doOneEighthNote (2, 1); doOneEighthNote (1,0); doOneEighthNote (2, 0); doOneEighthNote (1,0);

doOneEighthNote (2, 1); doOneEighthNote (1,0); doOneEighthNote (2, 0); doOneEighthNote (1,0);

doOneEighthNote (2, 1); doOneEighthNote (1,0); doOneEighthNote (2, 0); doOneEighthNote (1,0);

doOneEighthNote (2, 0); doOneEighthNote (1,0); doOneEighthNote (2, 1); doOneEighthNote (1,0);

doOneEighthNote (2, 0); doOneEighthNote (1,0); doOneEighthNote (2, 0); doOneEighthNote (1,0);

doOneEighthNote (2, 1); doOneEighthNote (1,0); doOneEighthNote (2, 0); doOneEighthNote (1,0);

doOneEighthNote (2, 1); doOneEighthNote (1,0); doOneEighthNote (2, 0); doOneEighthNote (1,0);

doOneEighthNote (2, 1); doOneEighthNote (1,0); doOneEighthNote (2, 0); doOneEighthNote (1,0);

doOneEighthNote (2, 1); doOneEighthNote (1,0); doOneEighthNote (2, 0); doOneEighthNote (1,0);

doOneEighthNote (2, 1); doOneEighthNote (1,0); doOneEighthNote (2, 0); doOneEighthNote (1,0);

doOneEighthNote (2, 1); doOneEighthNote (1,0); doOneEighthNote (2, 0); doOneEighthNote (1,0);

doOneEighthNote (2, 0); doOneEighthNote (1,0); doOneEighthNote (2, 1); doOneEighthNote (1,0);

doOneEighthNote (2, 0); doOneEighthNote (1,0); doOneEighthNote (2, 1); doOneEighthNote (1,0);

doOneEighthNote (2, 0); doOneEighthNote (1,0); doOneEighthNote (2, 0); doOneEighthNote (1,0);

}

Pom zoo: