当我尝试编译HelloKeypad演示草图时,我得到了一个编译器错误。
我使用的是一台Windows7计算机,使用的是一个很小的3.2主板。
我买了一个像这样的键盘:https://www.adafruit.com/products/1824
我从这里下载了keypad.zip文件:https://www.pjrc.com/teensy/td_libs_Keypad.html,我使用的是同一个网页上的示例草图:
/* @file HelloKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates the simplest use of the matrix Keypad library.
|| #
*/
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
Serial.begin(9600);
}
void loop(){
char key = keypad.getKey();
if (key){
Serial.println(key);
}
}以下是编译器消息。
Arduino: 1.6.6 (Windows 7), TD: 1.26, Board: "Teensy 3.2 / 3.1, Serial + Keyboard + Mouse + Joystick, 96 MHz optimized (overclock), US English"
In file included from C:\Users\FRESH1~1\AppData\Local\Temp\arduino_827e3ed6878980f03915bd59f832243c\HelloKeypad.ino:10:0:
C:\Users\fresh1011\Documents\Arduino\libraries\Keypad/Keypad.h:80:27: error: expected class-name before '{' token
class Keypad : public Key {
^
C:\Users\fresh1011\Documents\Arduino\libraries\Keypad/Keypad.h:90:2: error: 'Key' does not name a type
Key key[LIST_MAX];
^
C:\Users\fresh1011\Documents\Arduino\libraries\Keypad/Keypad.h:95:2: error: 'KeyState' does not name a type
KeyState getState();
^
C:\Users\fresh1011\Documents\Arduino\libraries\Keypad/Keypad.h:119:28: error: 'KeyState' has not been declared
void transitionTo(byte n, KeyState nextState);
^
Multiple libraries were found for "Keypad.h"
Used: C:\Users\fresh1011\Documents\Arduino\libraries\Keypad
Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Keypad
exit status 1
Error compiling.Keypad.zip文件是否已过期?
谢谢你的帮助。
发布于 2015-12-21 16:24:39
可以使用Arduino IDE 1.6.3而不是1.6.6。
根据pjrc forum中的以下post,它解决了库支持的问题。
https://stackoverflow.com/questions/34297589
复制相似问题