如何通过Android智能手机通过蓝牙控制制作吹雪机3.0

这是通过Android手机的蓝牙控制机器人割草机变成DIY吹雪机的最短时间记录




这是吹雪机的第三个版本。我从战斗机器人中做出的第一个选择。我正在为比赛做准备的割草机的第二个选择一段简短介绍了这些“产品”的视频已经在Geektimes上发布了,也位于帖子底部的扰流板中。

机器人的当前设计非常简单。刮刀将雪的顶层清除掉。底层从吹雪机的下方向侧面扔。动力单元是手动割草机的内燃发动机,容量为0.9 hp 推进发动机是VAZ雨刮器的齿轮电动机。ICE旋转螺丝。螺钉的气流和机械冲击使积雪从表面上升,并通过风管将其抛向侧面。吹雪机周围的裙边可防止雪飞散。螺纹橡胶可显着提高设备的渗透性。


管理学


通过Android手机进行蓝牙控制。Arduino nano + Monster Motor Shield +蓝牙HC-06

蓝牙HC-06的工作电压为3.3V,即 为了进行正确的操作,有必要进行逻辑电平的转换。没有这个,电路将工作,但是可能会出现问题。

关于Monster Motor Shield,有很多有争议的问题,有人声称婚姻比例很高。我非常喜欢这块板,因为它可保持高达30A的电流。


Arduino的


为了从Bluetooth HC-06接收数据,我使用了软件串行,以便通过硬件串行端口通过终端进行调试。尤其需要跟踪来自Arduino的数据。在最简单的草图中,我们通过蓝牙检查收到的字符并打开引擎驱动程序。
Arduino代码
#include <SoftwareSerial.h>
#define BRAKEVCC 0
#define CW   1
#define CCW  2
#define BRAKEGND 3
#define CS_THRESHOLD 100

int inApin[2] = {7, 4};  // INA: Clockwise input
int inBpin[2] = {8, 9}; // INB: Counter-clockwise input
int pwmpin[2] = {5, 6}; // PWM input

int statpin = 10;

SoftwareSerial mySerial(2, 3); // RX, TX
char a,b;

void setup()  
{
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


 pinMode(statpin, OUTPUT);

  // Initialize digital pins as outputs
  for (int i=0; i<2; i++)
  {
    pinMode(inApin[i], OUTPUT);
    pinMode(inBpin[i], OUTPUT);
    pinMode(pwmpin[i], OUTPUT);
  }
  // Initialize braked
  for (int i=0; i<2; i++)
  {
    digitalWrite(inApin[i], LOW);
    digitalWrite(inBpin[i], LOW);
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
    digitalWrite(statpin, HIGH);
    
  if (mySerial.available()){
        a=mySerial.read();

    if(a=='F'){
  motorGo(0, CW, 1023);
  motorGo(1, CW, 1023);
    }
    if(a=='B'){
  motorGo(0, CCW, 1023);
  motorGo(1, CCW, 1023);
    }
    if(a=='L'){
  motorGo(0, CW, 1023);
  motorGo(1, CCW, 1023);
    }
    if(a=='R'){
  motorGo(0, CCW, 1023);
  motorGo(1, CW, 1023);
    }
     if(a=='I'){
  motorGo(0, CW, 500);
  motorGo(1, CW, 1023);
    }
    if(a=='G'){
  motorGo(0, CW, 1023);
  motorGo(1, CW, 500);
    }
    if(a=='H'){
  motorGo(0, CCW, 1023);
  motorGo(1, CCW, 500);
    }
    if(a=='J'){
  motorGo(0, CCW, 500);
  motorGo(1, CCW, 1023);
    }
       if(a=='S'){
  motorOff(1);
  motorOff(2);
    }

    Serial.write(a);
    }else{
      
    }
  
}


void motorOff(int motor)
{
  // Initialize braked
  for (int i=0; i<2; i++)
  {
    digitalWrite(inApin[i], LOW);
    digitalWrite(inBpin[i], LOW);
  }
  analogWrite(pwmpin[motor], 0);
}

void motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
{
  if (motor <= 1)
  {
    if (direct <=4)
    {
      // Set inA[motor]
      if (direct <=1)
        digitalWrite(inApin[motor], HIGH);
      else
        digitalWrite(inApin[motor], LOW);

      // Set inB[motor]
      if ((direct==0)||(direct==2))
        digitalWrite(inBpin[motor], HIGH);
      else
        digitalWrite(inBpin[motor], LOW);

      analogWrite(pwmpin[motor], pwm);
    }
  }
}



Andoid


在Google Play上,有大量现成的用于远程控制的应用程序总而言之,我最喜欢这个应用程序。


接口

应用程序逻辑该应用
程序通过蓝牙发送当前每按一次的按钮组合的代码。
  • “ S”-停止
  • “ F”-继续
  • “ B”-返回
  • “ L”-左侧
  • “ R”-右侧
  • “我”-向前并向右
  • “ G”-向前和向左
  • “ H”-右后
  • “ J”-左后

既可以通过按键也可以使用陀螺仪进行管理。该应用程序的功能相当简单,但这已经足够。

录影带




视频吹雪机1.0和2.0
, . -. , , , ..



PS:下一个项目是自主水下机器人。我正在为X-Prize竞赛做准备:)。链接它仍然可以节省$ 2000。

报名截止日期为2016年6月30日(太平洋标准时间晚上11:59 /太平洋标准时间下午4:59)。注册费为$ 2,000.00 USD。

Source: https://habr.com/ru/post/zh-CN388581/


All Articles