我一直在使用电容式按钮为 Arduino 编写乒乓球游戏,但我收到“没有匹配函数调用 'CapacitiveSensor::CapacitiveSensor()'”错误。这是我上过的课程的代码错误:
//Input.cpp
#include <CapacitiveSensor.h>
#include "Input.h"
#include "Arduino.h"
Input::Input (byte sPin, byte rPin1, byte rPin2) { //I get the error on this line
upButton = CapacitiveSensor(sPin, rPin1);
downButton = CapacitiveSensor(sPin, rPin2);
}
//Continued for bChk
然后这是标题:
//Input.h
#ifndef Input_H
#define Input_H
#include "Arduino.h"
#include <CapacitiveSensor.h>
class Input{
public:
const static byte up = 0;
const static byte down = 1;
CapacitiveSensor upButton;
CapacitiveSensor downButton;
boolean bChk(byte button);
Input(byte sPin, byte rPin1, byte rPin2);
};
#endif
我知道标准命名约定说常量应该大写,但它们已经被保留了。而且变量等应该是私有的。我很懒。此外,我在与调用构造函数的行不同的行上得到错误......我也没有创建 CapacitiveSensor 类。
我在 Mac 上,如果这很重要(我对此表示怀疑)。