一个失败的 Arduino 项目

古语云“拳是两扇门,全凭脚打人”,无论是中华武术,跆拳道还是空手道,踢腿都是重要的内容。我的教练踢腿速度很快,通常还没有看清脚就已经提到眼前。因此我打算测试踢腿速度的设备,将这个速度进行量化。

方案是使用触摸来判断,在地面和脚靶上分别放置两个导电的装置然后计算从抬脚到接触到的时间差。进行判断接触的传感器还是 MPR121.。最终东西做出来了,但是意外发现这个方案存在致命缺点最后只能放弃。

image001

image002

image003

完整的代码:

#include <Wire.h>
#include "Adafruit_MPR121.h"

// You can have up to 4 on one i2c bus but one is enough for testing!
Adafruit_MPR121 cap = Adafruit_MPR121();

// Keeps track of the last pins touched
// so we know when buttons are 'released'
uint16_t lasttouched = 0;
uint16_t currtouched = 0;

void showdata(unsigned int value)
{
   //这是数码管要求的数据头信息
    Serial.write(0xff);
    Serial.write(0x00);
    Serial.write(0x04);  //显示四位数值
    if (value>9999) {  // 9999
        Serial.write(0x09);
        Serial.write(0x09);
        Serial.write(0x09);
        Serial.write(0x09);
    } else
        if (value >999) { //9.999
           Serial.write(value / 1000 + 0x80);
           Serial.write((value - value /1000 * 1000) / 100);      
           Serial.write((value - value /100 * 100) / 10); 
           Serial.write(value % 10);
        }
        else
           {
           Serial.write(value / 1000);
           Serial.write((value - value /1000 * 1000) / 100);      
           Serial.write((value - value /100 * 100) / 10); 
           Serial.write(value % 10);
          }
              
      
   //最后一位是亮度
     Serial.write(0);
      
}

// the setup function runs once when you press reset or power the board
void setup() {
  Serial.begin(115200);
 

  // Default address is 0x5A, if tied to 3.3V its 0x5B
  // If tied to SDA its 0x5C and if SCL then 0x5D
  if (!cap.begin(0x5A)) {
    Serial.println("MPR121 not found, check wiring?");
    while (1);
  }
 // Serial.println("MPR121 found!");  
}

int elsp=0;

// the loop function runs over and over again forever
void loop() {
   // Get the currently touched pads
  currtouched = cap.touched();

  //Touch 11 Release -- Start
  //Touch 7  Touch -- End
  //Tpuch 5  Reset

  if (!(currtouched & _BV(11)) && (lasttouched & _BV(11)) ) {
      if (elsp==0) {
       // Serial.println("Start");
        elsp=millis();
      }
    }
  if ((currtouched & _BV(7)) && !(lasttouched & _BV(7)) ) {
      if (elsp!=0) {
           // Serial.println("Stop");
            //Serial.println(millis()-elsp);
            showdata(millis()-elsp);
            elsp=0;
          }
        }

  if (!(currtouched & _BV(5)) && (lasttouched & _BV(5)) ) {
      //Serial.println("reset timer");
      showdata(0);
      elsp=0;
    }

  // reset our state
  lasttouched = currtouched;
  if (elsp!=0) {showdata(millis()-elsp);}

}

 

工作的视频
https://v.qq.com/x/page/j0518su7n6x.html

遇到的问题如下:
1. MPR121 是通过母座插在一块 Shield板上的,但是座子和MPR121接触不好,这对于触摸传感器来说是致命的。最后只得直接从压线座飞线到 MPR121上;
2. 负责接触脚的金属一直有问题。起初使用的是和之前石头剪刀布游戏机一样的纸壳贴锡箔,但是测试发现一脚上去就会碎掉。后来我特地用502沾了一个结果发现感应非常不灵敏,可能是因为面积过大导致的。之前的石头剪刀布游戏机最终人是要站在上面的,有充分的时间来进行感知,而这次的装置,脚接触一次很快就会收回,因此对于准确性和灵敏度要求都会比较高;
3. 因为是触摸感应,所以对线的长度接触之类是比较敏感的,在使用中发现布线会比较麻烦,脚靶那一端经常会被“踢飞”,有了线之后会影响发挥;
综合上述的原因,使用触摸的方案来进行踢腿速度测试是不可行的。

当然我们还是能从这个设备学习到很多,首先是前面的三点失败的总结,此外还有对于那种大的数码管控制,在未来通过其他方法改进,我相信总有一天能够做出测试踢腿速度的设备.

《一个失败的 Arduino 项目》有2个想法

回复 zhihui 取消回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注