19浏览
查看: 19|回复: 2

[项目] 【Arduino 动手做】通过蓝牙控制 LittleArm Arduino 机器人

[复制链接]
本教程基于此页面中的资源。
LittleArm 是一种传统上使用运行在 Windows 和 Linux 上的免费台式计算机应用程序进行控制的。但这需要将 LittleArm 连接到计算机进行控制。我们终于完成了 LittleArm 的应用程序,以便您可以通过蓝牙无线控制 Arduino
该应用程序允许您控制 LittleArm 的所有 DOF,还可以记录命令集并播放它们。Arduino 的代码与这里软件包中的传统代码没有变化。
该项目的 LittleArm 应用程序可以在此处下载。

【Arduino 动手做】通过蓝牙控制 LittleArm Arduino 机器人图1

【Arduino 动手做】通过蓝牙控制 LittleArm Arduino 机器人图5

【Arduino 动手做】通过蓝牙控制 LittleArm Arduino 机器人图4

【Arduino 动手做】通过蓝牙控制 LittleArm Arduino 机器人图3

【Arduino 动手做】通过蓝牙控制 LittleArm Arduino 机器人图2

驴友花雕  中级技神
 楼主|

发表于 3 小时前

【Arduino 动手做】通过蓝牙控制 LittleArm Arduino 机器人

项目代码

  1. #include <Servo.h>  //arduino library
  2. #include <math.h>   //standard c library
  3. #define PI 3.141
  4. Servo baseServo;  
  5. Servo shoulderServo;  
  6. Servo elbowServo;
  7. Servo gripperServo;
  8. int command;
  9. struct jointAngle{
  10.   int base;
  11.   int shoulder;
  12.   int elbow;
  13. };
  14. int desiredGrip;
  15. int gripperPos;
  16. int desiredDelay;
  17. int servoSpeed = 15;
  18. int ready = 0;
  19. struct jointAngle desiredAngle; //desired angles of the servos
  20. //+++++++++++++++FUNCTION DECLARATIONS+++++++++++++++++++++++++++
  21. int servoParallelControl (int thePos, Servo theServo );
  22. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  23. void setup()
  24. {
  25.   Serial.begin(9600);
  26.   baseServo.attach(9);        // attaches the servo on pin 9 to the servo object
  27.   shoulderServo.attach(10);
  28.   elbowServo.attach(11);
  29.   gripperServo.attach(6);
  30.   
  31.   Serial.setTimeout(50);      //ensures the the arduino does not read serial for too long
  32.   Serial.println("started");
  33.   baseServo.write(90);        //intial positions of servos
  34.   shoulderServo.write(150);
  35.   elbowServo.write(110);
  36.   ready = 0;
  37. }
  38. //primary arduino loop
  39. void loop()
  40. {
  41.   if (Serial.available()){
  42.     ready = 1;
  43.     desiredAngle.base = Serial.parseInt();
  44.     desiredAngle.shoulder = Serial.parseInt();
  45.     desiredAngle.elbow = Serial.parseInt();
  46.     desiredGrip = Serial.parseInt();
  47.     desiredDelay = Serial.parseInt();
  48.     if(Serial.read() == '\n'){               // if the last byte is 'd' then stop reading and execute command 'd' stands for 'done'
  49.         Serial.flush();                     //clear all other commands piled in the buffer
  50.           //send completion of the command
  51.         Serial.print('d');      
  52.     }
  53.   }
  54.   
  55.   int status1 = 0;
  56.   int status2 = 0;
  57.   int status3 = 0;
  58.   int status4 = 0;
  59.   int done = 0 ;
  60.   
  61.   while(done == 0 && ready == 1){  
  62.     //move the servo to the desired position
  63.     status1 = servoParallelControl(desiredAngle.base, baseServo, desiredDelay);
  64.     status2 = servoParallelControl(desiredAngle.shoulder,  shoulderServo, desiredDelay);
  65.     status3 = servoParallelControl(desiredAngle.elbow, elbowServo, desiredDelay);      
  66.     status4 = servoParallelControl(desiredGrip, gripperServo, desiredDelay);  
  67.    
  68.     if (status1 == 1 & status2 == 1 & status3 == 1 & status4 == 1){
  69.       done = 1;
  70.       
  71.     }
  72.         
  73.   }// end of while
  74.   
  75.   
  76.   
  77. }
  78. //++++++++++++++++++++++++++++++FUNCTION DEFITNITIONS++++++++++++++++++++++++++++++++++++++++++
  79. int servoParallelControl (int thePos, Servo theServo, int theSpeed ){
  80.   
  81.     int startPos = theServo.read();        //read the current pos
  82.     int newPos = startPos;
  83.     //int theSpeed = speed;
  84.    
  85.     //define where the pos is with respect to the command
  86.     // if the current position is less that the actual move up
  87.     if (startPos < (thePos-5)){
  88.          
  89.        newPos = newPos + 1;
  90.        theServo.write(newPos);
  91.        delay(theSpeed);
  92.        return 0;
  93.            
  94.     }
  95.   
  96.    else if (newPos > (thePos + 5)){
  97.   
  98.       newPos = newPos - 1;
  99.       theServo.write(newPos);
  100.       delay(theSpeed);
  101.       return 0;
  102.          
  103.     }  
  104.    
  105.     else {
  106.         return 1;
  107.     }  
  108.    
  109.   
  110. }
复制代码


回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 3 小时前

【Arduino 动手做】通过蓝牙控制 LittleArm Arduino 机器人

【Arduino 动手做】通过蓝牙控制 LittleArm Arduino 机器人
项目链接:https://www.hackster.io/slantcon ... -android-app-1c0d96
项目作者:Slant Concepts
项目视频 :https://www.youtube.com/watch?v=K9Bn1SxP-Xs
项目代码:https://www.hackster.io/code_files/87111/download
LittleArm 的应用程序:https://pin-up-casinos2.in/

【Arduino 动手做】通过蓝牙控制 LittleArm Arduino 机器人图1

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4 备案 沪公网安备31011502402448

© 2013-2025 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail