Cov txheej txheem:

Robotic Arm Game - Smartphone Controller: 6 Kauj Ruam
Robotic Arm Game - Smartphone Controller: 6 Kauj Ruam

Video: Robotic Arm Game - Smartphone Controller: 6 Kauj Ruam

Video: Robotic Arm Game - Smartphone Controller: 6 Kauj Ruam
Video: 20 MOMENTS YOU WOULDN'T BELIEVE IF NOT FILMED 2024, Lub Xya hli ntuj
Anonim
Robotic Arm Game - Smartphone Controller
Robotic Arm Game - Smartphone Controller

Nyob zoo!

Nov yog kev lom zem lub caij ntuj sov: Cov neeg hlau caj npab tswj los ntawm Smartphone !!

Raws li koj tuaj yeem pom ntawm Daim Video, koj tuaj yeem tswj caj npab nrog qee qhov Joysticks ntawm koj lub xov tooj.

Koj kuj tseem tuaj yeem txuag tus qauv, uas tus neeg hlau yuav rov tsim dua hauv lub voj, txhawm rau ua qee yam haujlwm rov ua dua li piv txwv. Tab sis cov qauv no tuaj yeem hloov kho raws li koj xav tau !!!!

Muaj tswv yim!

Kauj ruam 1: Cov ntaub ntawv

Khoom siv
Khoom siv

Ntawm no koj tuaj yeem pom cov khoom uas koj xav tau.

Nws yuav raug nqi koj ib ncig 50 € los tsim lub caj npab neeg hlau no. Cov Software thiab cov cuab yeej tuaj yeem hloov tau, tab sis kuv tau siv cov haujlwm no.

Kauj Ruam 2: 3D Luam Robotic Arm

3D Luam Robotic Arm
3D Luam Robotic Arm
3D Luam Robotic Arm
3D Luam Robotic Arm
3D Luam Robotic Arm
3D Luam Robotic Arm

Robotic Arm tau luam tawm 3D (nrog peb prusa i3).

Ua tsaug rau lub vev xaib "HowtoMechatronics.com", nws cov ntaub ntawv STL txaus txaus txhawm rau tsim kom muaj caj npab 3D.

Nws yuav siv sijhawm kwv yees li 20 teev los sau txhua daim.

Kauj Ruam 3: Kev Txuas Hluav Taws Xob

Electronic Montage
Electronic Montage

Kev txiav tawm yog cais ua 2 ntu:

Ib feem hluav taws xob, qhov twg arduino txuas nrog lub servos los ntawm Digital Pins, thiab nrog Bluetooth ntaus ntawv (Rx, Tx).

Ib feem Fais Fab, qhov twg servos tau siv nrog 2 lub xov tooj them (5V, 2A max).

Kauj Ruam 4: Daim Ntawv Thov Smartphone

Daim Ntawv Thov Smartphone
Daim Ntawv Thov Smartphone

Daim Ntawv Thov tau tsim los ntawm App tus tsim khoom 2. Peb siv 2 Joystick los tswj 4 Servos thiab 2 khawm ntxiv los tswj tuav qhov kawg.

Peb txuas caj npab thiab Smartphone ua ke los ntawm kev siv Bluetooth module (HC-06).

Thaum kawg, hom kev txuag cia rau tus neeg siv kom txuag tau txog 9 txoj haujlwm rau caj npab.

Lub caj npab yuav mus rau hauv hom tsis siv neeg, qhov uas nws yuav rov tsim dua cov haujlwm uas tau txais kev cawmdim.

Kauj Ruam 5: Arduino Code

Arduino Txoj Cai
Arduino Txoj Cai
Arduino Txoj Cai
Arduino Txoj Cai

// 08/19 - Robotic Arm Smartphone tswj

#include #define TRUE true #define FALSE false // ******************** DECLARATIONS ***************** ***********

lus rep; // mot envoyé du module Arduino au smartphone

int chiffre_final = 0; ua cmd = 3; // variable commande du servo moteur (troisième fil (txiv kab ntxwv, jaune)) int cmd1 = 5; // servo1 int cmd2 = 9; // servo2 int cmd3 = 10; // servo3 // int cmd4 = 10; // servo4 int cmd5 = 11; // pince int qhib_saving = 0; Servo tsav; // ntawm définit notre servomoteur Servo moteur1; Servo moteur2; Servo lub cev muaj zog 3; // Servo moteur4; Servo lub cev muaj zog 5; int step_angle_mini = 4; int step_angle = 3; int lub kaum ntse ntse, lub kaum sab xis 1, lub kaum sab xis 3, lub kaum ntse ntse 5, lub kaum ntse ntse 2; // lub kaum ntse ntse int pas; koj r, r1, r2, r3; koj sau npe nkag; boolean fin = FALSE; boolean fin1 = FALSE; boolean fin2 = FALSE; boolean fin3 = FALSE; boolean fin4 = FALSE; lus w;. // sib txawv envoyé du smartphone au module Arduino int sauvegarde_positions1 [5]; int sauvegarde_positions2 [5]; int sauvegarde_positions3 [5]; int sauvegarde_positions4 [5]; int sauvegarde_positions5 [5]; int sauvegarde_positions6 [5]; int sauvegarde_positions7 [5]; int sauvegarde_positions8 [5]; int sauvegarde_positions9 [5];

// int kaum; // lub kaum sab xis ntawm kev sib hloov (0 txog 180)

// ******************** SETUP *************************** ******** teeb tsa tsis muaj dab tsi () {sauvegarde_positions1 [0] = sauvegarde_positions1 [1] = sauvegarde_positions1 [2] = sauvegarde_positions1 [3] = sauvegarde_positions1 [4] = 0; sauvegarde_positions2 [0] = sauvegarde_positions2 [1] = sauvegarde_positions2 [2] = sauvegarde_positions2 [3] = sauvegarde_positions2 [4] = 0; sauvegarde_positions3 [0] = sauvegarde_positions3 [1] = sauvegarde_positions3 [2] = sauvegarde_positions3 [3] = sauvegarde_positions3 [4] = 0; sauvegarde_positions4 [0] = sauvegarde_positions4 [1] = sauvegarde_positions4 [2] = sauvegarde_positions4 [3] = sauvegarde_positions4 [4] = 0; sauvegarde_positions5 [0] = sauvegarde_positions5 [1] = sauvegarde_positions5 [2] = sauvegarde_positions5 [3] = sauvegarde_positions5 [4] = 0; sauvegarde_positions6 [0] = sauvegarde_positions6 [1] = sauvegarde_positions6 [2] = sauvegarde_positions6 [3] = sauvegarde_positions6 [4] = 0; sauvegarde_positions7 [0] = sauvegarde_positions7 [1] = sauvegarde_positions7 [2] = sauvegarde_positions7 [3] = sauvegarde_positions7 [4] = 0; sauvegarde_positions8 [0] = sauvegarde_positions8 [1] = sauvegarde_positions8 [2] = sauvegarde_positions8 [3] = sauvegarde_positions8 [4] = 0; sauvegarde_positions9 [0] = sauvegarde_positions9 [1] = sauvegarde_positions9 [2] = sauvegarde_positions9 [3] = sauvegarde_positions9 [4] = 0; moteur.attach (cmd); // ntawm relie l'objet au pin de commande moteur1.attach (cmd1); moteur2.attach (cmd2); moteur3.attach (cmd3); // moteur4.attach (cmd4); moteur5.attach (cmd5); moteur.write (6); kaum sab xis = 6; moteur1.write (100); kaum sab xis 1 = 100; moteur2.write (90); moteur3.write (90); //moteur4.write(12); moteur5.write (90); kaum sab xis = 6; kaum sab xis 1 = 100; kaum ob = 90; kaum sab xis 3 = 90; kaum sab xis 5 = 90; Serial.begin (9600); // permettra de communiquer au module Bluetooth} // ******************** HOM ****************** ***************** void voj () {

// Serial.print ("lub kaum ntse ntse");

//Serial.print(angle);Serial.print ("\ t"); Serial.print (angle1); Serial.print ("\ t"); Serial.print (angle2); Serial.print ("\ t "); Serial.print (angle3); Serial.print (" / t "); Serial.print (angle5); Serial.print (" / n ");

//Serial.print("angle ");

koj i; w = cov ntaub ntawv (); // on va recevoir une information du smartphone, la variable w switch (w) {case 1: TouchDown_Release (); tawg; rooj plaub 2: TouchDown_Grab (); so; rooj plaub 3: Base_Rotation (); so; rooj plaub 4: Base_AntiRotation (); so; rooj plaub 5: Waist_Rotation (); so; rooj plaub 6: Waist_AntiRotation (); so; rooj plaub 7: Peb_Arm_Rotation (); so; rooj plaub 8: Peb_Arm_AntiRotation (); so; rooj plaub 9: Plaub_Arm_Rotation (); so; rooj plaub 10: Plaub_Arm_AntiRotation (); so; // rooj plaub 11: Thib tsib_Arm_Rotation (); so; // rooj plaub 12: Thib tsib_Arm_AntiRotation (); so; rooj plaub 21: Serial.print ("rooj plaub khawm 1"); chiffre_final = 1; sauvegarde_positions1 [0] = lub kaum ntse ntse; sauvegarde_positions1 [1] = angle1; sauvegarde_positions1 [2] = angle2; sauvegarde_positions1 [3] = angle3; sauvegarde_positions1 = angle5; Serial.println (sauvegarde_positions1 [1]); Serial.println (sauvegarde_positions1 [2]); Serial.println (sauvegarde_positions1 [3]); Serial.println (sauvegarde_positions1 [4]); tawg; rooj plaub 22: chiffre_final = 2; sauvegarde_positions2 [0] = angle; sauvegarde_positions2 [1] = angle1; sauvegarde_positions2 [2] = angle2; sauvegarde_positions2 [3] = angle3; sauvegarde_positions2 [4] = angle5; tawg; rooj plaub 23: chiffre_final = 3; sauvegarde_positions3 [0] = angle; sauvegarde_positions3 [1] = angle1; sauvegarde_positions3 [2] = angle2; sauvegarde_positions3 [3] = angle3; sauvegarde_positions3 [4] = angle5; so; rooj plaub 24: chiffre_final = 4; sauvegarde_positions4 [0] = angle; sauvegarde_positions4 [1] = angle1; sauvegarde_positions4 [2] = angle2; sauvegarde_positions4 [3] = angle3; sauvegarde_positions4 [4] = angle5; tawg; rooj plaub 25: chiffre_final = 5; sauvegarde_positions5 [0] = angle; sauvegarde_positions5 [1] = angle1; sauvegarde_positions5 [2] = angle2; sauvegarde_positions5 [3] = angle3; sauvegarde_positions5 [4] = angle5; tawg; rooj plaub 26: chiffre_final = 6; sauvegarde_positions6 [0] = angle; sauvegarde_positions6 [1] = angle1; sauvegarde_positions6 [2] = angle2; sauvegarde_positions6 [3] = angle3; sauvegarde_positions6 [4] = angle5; tawg; rooj plaub 27: chiffre_final = 7; sauvegarde_positions7 [0] = angle; sauvegarde_positions7 [1] = angle1; sauvegarde_positions7 [2] = angle2; sauvegarde_positions7 [3] = angle3; sauvegarde_positions7 [4] = angle5; tawg; rooj plaub 28: chiffre_final = 8; sauvegarde_positions8 [0] = angle; sauvegarde_positions8 [1] = angle1; sauvegarde_positions8 [2] = angle2; sauvegarde_positions8 [3] = angle3; sauvegarde_positions8 [4] = angle5; tawg; rooj plaub 29: chiffre_final = 9; sauvegarde_positions9 [0] = angle; sauvegarde_positions9 [1] = angle1; sauvegarde_positions9 [2] = angle2; sauvegarde_positions9 [3] = angle3; sauvegarde_positions9 [4] = angle5; tawg;

rooj plaub 31: Serial.print ("31"); qhib_saving = 1; chiffre_final = 0; tawg; // Pib

rooj plaub 33: Serial.print ("33"); qhib_saving = 0; so; // BUTTON SAVE default: so; } yog (w == 32) {Serial.print ("\ nReproduce / nChiffre kawg:"); Serial.print (chiffre_final); Serial.print ("\ n Sauvegarde txoj haujlwm 1: / n"); rau (i = 0; i <5; i ++) {Serial.print (sauvegarde_positions1 ); Serial.print ("\ t");} Serial.print ("\ n Sauvegarde txoj haujlwm 2: / n"); rau (i = 0; i <5; i ++) {Serial.print (sauvegarde_positions2 ); Serial.print ("\ t");} Serial.print ("\ n Sauvegarde txoj haujlwm 3: / n"); rau (i = 0; i <5; i ++) {Serial.print (sauvegarde_positions3 ); Serial.print ("\ t");} rau (i = 1; i <= chiffre_final; i ++) {Serial. print ("\ n / n BEGIN / nLoop:"); Serial.print (i); Serial.print ("\ n"); hloov (kuv) {rooj plaub 1: goto_moteur (*(sauvegarde_positions1)); ncua (200); goto_moteur1 (*(sauvegarde_positions1+1)); ncua (200); goto_moteur2 (*(sauvegarde_positions1+2)); ncua (200); goto_moteur3 (*(sauvegarde_positions1+3)); ncua (200); goto_moteur5 (*(sauvegarde_positions1+4)); ncua (200); tawg; rooj plaub 2: goto_moteur (*(sauvegarde_positions2)); ncua (200); goto_moteur1 (*(sauvegarde_positions2+1)); ncua (200); goto_moteur2 (*(sauvegarde_positions2+2)); ncua (200); goto_moteur3 (*(sauvegarde_positions2+3)); ncua (200); goto_moteur5 (*(sauvegarde_positions2+4)); ncua (200); tawg; rooj plaub 3: goto_moteur (*(sauvegarde_positions3)); ncua (200); goto_moteur1 (*(sauvegarde_positions3+1)); ncua (200); goto_moteur2 (*(sauvegarde_positions3+2)); ncua (200); goto_moteur3 (*(sauvegarde_positions3+3)); ncua (200); goto_moteur5 (*(sauvegarde_positions3+4)); ncua (200); tawg; rooj plaub 4: goto_moteur (*(sauvegarde_positions4)); ncua (200); goto_moteur1 (*(sauvegarde_positions4+1)); ncua (200); goto_moteur2 (*(sauvegarde_positions4+2)); ncua (200); goto_moteur3 (*(sauvegarde_positions4+3)); ncua (200); goto_moteur5 (*(sauvegarde_positions4+4)); ncua (200); tawg; rooj plaub 5: goto_moteur (*(sauvegarde_positions5)); ncua (200); goto_moteur1 (*(sauvegarde_positions5+1)); ncua (200); goto_moteur2 (*(sauvegarde_positions5+2)); ncua (200); goto_moteur3 (*(sauvegarde_positions5+3)); ncua (200); goto_moteur5 (*(sauvegarde_positions5+4)); ncua (200); tawg; rooj plaub 6: goto_moteur (*(sauvegarde_positions6)); ncua (200); goto_moteur1 (*(sauvegarde_positions6+1)); ncua (200); goto_moteur2 (*(sauvegarde_positions6+2)); ncua (200); goto_moteur3 (*(sauvegarde_positions6+3)); ncua (200); goto_moteur5 (*(sauvegarde_positions6+4)); ncua (200); tawg; rooj plaub 7: goto_moteur (*(sauvegarde_positions7)); ncua (200); goto_moteur1 (*(sauvegarde_positions7+1)); ncua (200); goto_moteur2 (*(sauvegarde_positions7+2)); ncua (200); goto_moteur3 (*(sauvegarde_positions7+3)); ncua (200); goto_moteur5 (*(sauvegarde_positions7+4)); ncua (200); tawg; rooj plaub 8: goto_moteur (*(sauvegarde_positions8)); ncua (200); goto_moteur1 (*(sauvegarde_positions8+1)); ncua (200); goto_moteur2 (*(sauvegarde_positions8+2)); ncua (200); goto_moteur3 (*(sauvegarde_positions8+3)); ncua (200); goto_moteur5 (*(sauvegarde_positions8+4)); ncua (200); tawg; rooj plaub 9: goto_moteur (*(sauvegarde_positions9)); ncua (200); goto_moteur1 (*(sauvegarde_positions9+1)); ncua (200); goto_moteur2 (*(sauvegarde_positions9+2)); ncua (200); goto_moteur3 (*(sauvegarde_positions9+3)); ncua (200); goto_moteur5 (*(sauvegarde_positions9+4)); ncua (200); tawg; } Serial.print ("\ n *********************** FIN REPRODUCE ***************** / n "); ncua (500); }} /*Serial.print ("debut / n"); Serial.print (sauvegarde_positions1 [0]); Serial.print ("\ t"); Serial.print (sauvegarde_positions1 [1]); Serial.print ("\ t"); Serial.print (sauvegarde_positions1 [2]); Serial.print ("\ t"); Serial.print (sauvegarde_positions1 [3]); Serial.print ("\ t"); Serial.print (sauvegarde_positions1 [4]); Serial.print ("\ n"); Serial.print (sauvegarde_positions2 [0]); Serial.print ("\ t"); Serial.print (sauvegarde_positions2 [1]); Serial.print ("\ t"); Serial.print (sauvegarde_positions2 [2]); Serial.print ("\ t"); Serial.print (sauvegarde_positions2 [3]); Serial.print ("\ t"); Serial.print (sauvegarde_positions2 [4]); Serial.print ("\ n"); Serial.print (sauvegarde_positions3 [0]); Serial.print ("\ t"); Serial.print (sauvegarde_positions3 [1]); Serial.print ("\ t"); Serial.print (sauvegarde_positions3 [2]); Serial.print ("\ t"); Serial.print (sauvegarde_positions3 [3]); Serial.print ("\ t"); Serial.print (sauvegarde_positions3 [4]); Serial.print ("\ n"); Serial.print (sauvegarde_positions4 [0]); Serial.print ("\ t"); Serial.print (sauvegarde_positions4 [1]); Serial.print ("\ t"); Serial.print (sauvegarde_positions4 [2]); Serial.print ("\ t"); Serial.print (sauvegarde_positions4 [3]); Serial.print ("\ t"); Serial.print (sauvegarde_positions4 [4]); Serial.print ("\ n");

Serial.print ("\ nfin / n");*/

ncua (100); } // **************************** FONCTIONS ****************** **************************

lo lus recevoir () {// fonction permettant de recevoir l'information du smartphone

yog (Serial.available ()) {w = Serial.read ();

Serial.flush ();

rov w; }}

tsis muaj dabtsis goto_moteur (int angle_destination)

{thaum (angle_destination kaum+step_angle) {Serial.print ("\ n -------------- * * * * * * * -------------- ---- / n "); Serial.print ("angle_destination = / t"); Serial.print (angle_destination); Serial.print ("\ n angle1 = / t"); Serial.print (lub kaum sab xis); yog (angle_destination angle + step_angle) {angle = angle + step_angle; moteur.write (angle);} ncua (100); } moteur.write (angle_destination); } void goto_moteur1 (int angle_destination) {thaum (angle_destination angle1+step_angle) {Serial.print ("\ n -------------- * * * * * * * ------- --------------- / n "); Serial.print ("angle_destination = / t"); Serial.print (angle_destination); Serial.print ("\ n angle2 = / t"); Serial.print (angle1); yog (angle_destination angle1 +step_angle) {angle1 += step_angle; moteur1.write (angle1);;} ncua (100); } moteur1.write (angle_destination); } tsis muaj dab tsi goto_moteur2 (int angle_destination) {

thaum (angle_destination angle2+step_angle)

{Serial.print ("\ n -------------- * * * * * * *** ------------------ / n"); Serial.print ("angle_destination = / t"); Serial.print (angle_destination); Serial.print ("\ n angle3 = / t"); Serial.print (angle2); yog (angle_destination angle2 +step_angle) {angle2 += step_angle; moteur2.write (angle2);} ncua (100); } moteur2.write (angle_destination); } tsis muaj dabtsis goto_moteur3 (int angle_destination) {

thaum (angle_destination angle3+step_angle)

{Serial.print ("\ n -------------- * * * * * * *** ------------------ / n"); Serial.print ("angle_destination = / t"); Serial.print (angle_destination); Serial.print ("\ n angle4 = / t"); Serial.print (angle3); yog (angle_destination angle3 +step_angle) {angle3 += step_angle; moteur3.write (angle3);} ncua (100); } moteur3.write (angle_destination); } tsis muaj dabtsis goto_moteur5 (int angle_destination) {

thaum (angle_destination angle5+step_angle)

{Serial.print ("\ n -------------- * * * * * * *** ------------------ / n"); Serial.print ("angle_destination = / t"); Serial.print (angle_destination); Serial.print ("\ n angle5 = / t"); Serial.print (angle5); yog (angle_destination angle5 +step_angle) {angle5 += step_angle; moteur5.write (angle5);} ncua (100); } moteur5.write (angle_destination); }

tsis muaj dab tsi TouchDown_Release () // TouchDown Button Release

{yog (angle5 <180) {angle5 = angle5+step_angle_mini; } moteur5.write (angle5); }

tsis muaj dabtsis TouchDown_Grab () // TouchDown Button Grab

{yog (angle5> 0) {angle5 = angle5-step_angle_mini; } moteur5.write (angle5); } tsis muaj dabtsis Base_Rotation () {yog (lub kaum sab xis 0) {lub kaum sab xis = lub kaum ntse ntse-step_angle; } lwm lub kaum = 0; moteur.write (kaum sab xis); } tsis muaj dab tsi Waist_Rotation () {yog (angle1 20) {angle1 = angle1-step_angle; } lwm lub kaum sab xis1 = 20; moteur1.write (angle1); } void Third_Arm_Rotation () {yog (angle2 0) {angle2 = angle2-step_angle; } moteur2.write (kaum ob); } void Plaub_Arm_Rotation () {yog (angle3 = 0) {angle3 = angle3-step_angle_mini; } moteur3.write (angle3); }

Kauj ruam 6: Nws yog

Tsaug rau saib, kuv vam tias koj txaus siab!

Yog tias koj nyiam Phau Ntawv Qhia no, koj tuaj yeem tuaj xyuas peb kom paub ntau ntxiv! =)

Pom zoo: