找回密码
 立即注册

QQ登录

只需一步,快速开始

点击进入授权页面

只需一步,快速开始

  • QQ空间
  • 回复
  • 收藏

参加活动: 1

组织活动: 0

  • TA的每日心情
    开心
    2017-10-16 11:43
  • 签到天数: 395 天

    [LV.9]以坛为家II

    Or2 管理员 2016-10-16 21:21 楼主
    快上车,来不及解释了










    主要用到的材料有:

    Genuino 101

    TB2i2rsaam5V1BjSspoXXa8VXXa_!!665708651 (1).jpg
    履带电机
    TB2y2d.nFXXXXX9XFXXXXXXXXXX_!!128600268.jpg

    其他
    QQ截图20161017151222.jpg

    制作过程

    把履带上任意一节的铁心拆下,将两个履带合并成一个加长履带

    QQ截图20161017153026.jpg

    然后就是3D打印(由mostfun Pro打印)

    QQ截图20161017153336.jpg

    组装好大概是这个样子

    QQ截图20161017153529.jpg

    这个样子

    QQ截图20161017153602.jpg


    代码和电路原理在二楼

    奖品和纪念品收到啦
    谢谢 Arduino中文社区,谢谢各位赞助商
    QQ截图20161029164356.jpg





    打赏,是超越赞的一种表达
    代码和电路由ppeach桃子老师鼎力支持
    先上代码
    [AppleScript] 纯文本查看 复制代码
    #include <Motor.h>
    #include <Servo.h>
    #include <CurieBLE.h>
    
    const int SU1 = 11;
    const int SU2 = 12;
    
    const int ledPin = 13;
    
    volatile int counter1 = 0;
    volatile int counter2 = 0;
    
    char receiveData = 0, old_receiveData = 0;
    char servopos = 90;
    int rpm1 = 0, rpm2 = 0;
    float Speed1 = 255, Speed2 = 255;
    const char gunPin = 3;
    const char servoPin = 9;
    
    BLEPeripheral blePeripheral;
    BLEService uartService("6E400001B5A3F393E0A9E50E24DCCA9E");
    BLECharacteristic rxCharacteristic("6E400002B5A3F393E0A9E50E24DCCA9E", BLEWriteWithoutResponse, 20);
    BLECharacteristic txCharacteristic("6E400003B5A3F393E0A9E50E24DCCA9E", BLENotify , 20);
    
    Motor myMotor;
    Servo myservo;
    
    void setup()
    {
      Serial.begin(9600);
      pinMode(ledPin, OUTPUT);
      pinMode(gunPin, OUTPUT);
    
      blePeripheral.setLocalName("BLE_Car");
      blePeripheral.setAdvertisedServiceUuid(uartService.uuid());
    
      blePeripheral.addAttribute(uartService);
      blePeripheral.addAttribute(rxCharacteristic);
      blePeripheral.addAttribute(txCharacteristic);
    
      blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler);
      blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);
    
      rxCharacteristic.setEventHandler(BLEWritten, rxCharacteristicWritten);
    
      blePeripheral.begin();
    
      myMotor.init();
      myMotor.enable();
    
      myservo.attach(servoPin);
      myservo.write(servopos);
    
      attachInterrupt(SU1, Counter1, FALLING);
      attachInterrupt(SU2, Counter2, RISING);
    }
    
    void loop()
    {
      switch (receiveData) {
        case '1': myMotor.forward(Speed1, Speed2); break; //小车前进
        case '2': myMotor.backward(Speed1, Speed2); break; //小车后退
        case '3': myMotor.turnLeft(Speed1, Speed2); break; //小车左转
        case '4': myMotor.turnRight(Speed1, Speed2); break; //小车右转
    
        case '5': servopos = servopos + 5; myservo.write(servopos); delay(200); break; //持续旋转炮台
        case '6': servopos = servopos - 5; myservo.write(servopos); delay(200); break; //持续旋转炮台
        case '7': myservo.write(servopos); break; //锁定炮台位置
        case '8': fire(); break; //持续发射水弹
    
        case '0': myMotor.stop(); stopFire(); break; //停止开火 && 停止发射水弹
    
        default: myMotor.stop(); myMotor.disable(); break; //错误命令,停止电机,关闭使能
      }
    
    
      getSpeed();
      Speed2 = Speed1 + (rpm1 - rpm2) * 0.05;
    
      Serial.print(rpm1);
      Serial.print("r/min  ");
      Serial.print(rpm2);
      Serial.print("r/min \r\n");
    
      blePeripheral.poll();
    }
    
    void fire()
    {
      digitalWrite(gunPin, HIGH);
    }
    
    void stopFire()
    {
      digitalWrite(gunPin, LOW);
    }
    
    void getSpeed()
    {
      long nowTime = millis();
      static long oldTime = 0;
    
      if ((nowTime - oldTime) > 1000) {
        detachInterrupt(SU1);
        detachInterrupt(SU2);
    
        rpm1 = counter1 / 20 * 60;
        rpm2 = counter2 / 20 * 60;
    
        counter1 = 0;
        counter2 = 0;
    
        oldTime = nowTime;
    
        attachInterrupt(SU1, Counter1, FALLING);
        attachInterrupt(SU2, Counter2, FALLING);
      }
    }
    
    void Counter1()
    {
      counter1++;
    }
    
    void Counter2()
    {
      counter2++;
    }
    
    void blePeripheralConnectHandler(BLECentral& central)
    {
      Serial.print("Connected event, central: ");
      Serial.println(central.address());
      digitalWrite(ledPin, HIGH);
    }
    
    void blePeripheralDisconnectHandler(BLECentral& central)
    {
      Serial.print("Disconnected event, central: ");
      Serial.println(central.address());
      digitalWrite(ledPin, LOW);
    }
    
    void rxCharacteristicWritten(BLECentral& central, BLECharacteristic& characteristic)
    {
      Serial.print("Characteristic event, written: ");
    
      if (characteristic.value()) {
        receiveData = *characteristic.value();
        Serial.println(char(receiveData));
      }
    }


    库和原理图打包在附件
    一库一图.rar (86.7 KB, 下载次数: 68)
    打赏,是超越赞的一种表达

    1人打赏

    顶一个:lol:lol
    大神,水弹部分咋搞     
    楼主 那个蓝牙软件求分享!舵机和水枪的接线能详细说明下吧?谢谢!
    赞                     
    模具用了多少钱
    打赏作者鼓励一下!
    Or2 管理员 2016-12-3 16:42
    8#

    是3D打印的
    打赏,是超越赞的一种表达
    可以求个打印用到的模型吗,谢谢楼主
    楼主的电机的接收、发射端是怎么接的呀
    12下一页
    发新帖
    发表评论
    高级模式  
    您需要登录后才可以回帖 登录 | 立即注册  
    关闭

    推荐主题 上一条 /2 下一条