Попытка заставить клавиатуру работать на моем arduino uno, и я получаю следующие ошибки:
7SegDisKeypad:14:5: error: expected unqualified-id before numeric constant
int 1 == A0;
^
7SegDisKeypad:15:5: error: expected unqualified-id before numeric constant
int 2 = A1;
^
7SegDisKeypad:16:5: error: expected unqualified-id before numeric constant
int 3 = A2;
^
7SegDisKeypad:17:5: error: expected unqualified-id before numeric constant
int 4 = A3;
^
7SegDisKeypad:18:5: error: expected unqualified-id before numeric constant
int 5 = 5;
^
7SegDisKeypad:19:5: error: expected unqualified-id before numeric constant
int 6 = 4;
^
7SegDisKeypad:20:5: error: expected unqualified-id before numeric constant
int 7 = 3;
^
7SegDisKeypad:21:5: error: expected unqualified-id before numeric constant
int 8 = 2;
^
D:\GoogleDownloads\7SegDisKeypad\7SegDisKeypad.ino: In function 'void loop()':
D:\GoogleDownloads\7SegDisKeypad\7SegDisKeypad.ino:244:14: warning: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if (key == "1") {
^~~
Multiple libraries were found for "Keypad.h"
Used: C:\Users\Spudd\Documents\Arduino\libraries\Keypad
exit status 1
expecte
d безусловный идентификатор перед цифрой c константа
Это мой код :
#include <Keypad.h>
int E = 13;
int D = 12;
int C = 11;
int DP = 10;
int B = 9;
int A = 8;
int F = 7;
int G = 6;
int 1 == A0;
int 2 = A1;
int 3 = A2;
int 4 = A3;
int 5 = 5;
int 6 = 4;
int 7 = 3;
int 8 = 2;
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {A0, A1, A2, A3}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5,4,3,2}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void dp() {
//High == off, LOW == On
digitalWrite(E, LOW);
digitalWrite(D, LOW);
digitalWrite(C, LOW);
digitalWrite(DP, HIGH);
digitalWrite(B, LOW);
digitalWrite(A, LOW);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
}
void one() {
//High == off, LOW == On
digitalWrite(E, LOW);
digitalWrite(D, LOW);
digitalWrite(C, HIGH);
digitalWrite(DP, LOW);
digitalWrite(B, HIGH);
digitalWrite(A, LOW);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
}
void two() {
//High == off, LOW == On
digitalWrite(E, HIGH);
digitalWrite(D, HIGH);
digitalWrite(C, LOW);
digitalWrite(DP, LOW);
digitalWrite(B, HIGH);
digitalWrite(A, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
}
void three() {
digitalWrite(E, LOW);
digitalWrite(D, HIGH);
digitalWrite(C, HIGH);
digitalWrite(DP, LOW);
digitalWrite(B, HIGH);
digitalWrite(A, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
}
void four() {
digitalWrite(E, LOW);
digitalWrite(D, LOW);
digitalWrite(C, HIGH);
digitalWrite(DP, LOW);
digitalWrite(B, HIGH);
digitalWrite(A, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void five() {
digitalWrite(E, LOW);
digitalWrite(D, HIGH);
digitalWrite(C, HIGH);
digitalWrite(DP, LOW);
digitalWrite(B, LOW);
digitalWrite(A, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void six() {
digitalWrite(E, HIGH);
digitalWrite(D, HIGH);
digitalWrite(C, HIGH);
digitalWrite(DP, LOW);
digitalWrite(B, LOW);
digitalWrite(A, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void seven() {
//High == off, LOW == On
digitalWrite(E, LOW);
digitalWrite(D, LOW);
digitalWrite(C, HIGH);
digitalWrite(DP, LOW);
digitalWrite(B, HIGH);
digitalWrite(A, HIGH);
digitalWrite(F, LOW);
digitalWrite(G, LOW);
}
void eight() {
//High == off, LOW == On
digitalWrite(E, HIGH);
digitalWrite(D, HIGH);
digitalWrite(C, HIGH);
digitalWrite(DP, LOW);
digitalWrite(B, HIGH);
digitalWrite(A, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void nine() {
//High == off, LOW == On
digitalWrite(E, LOW);
digitalWrite(D, HIGH);
digitalWrite(C, HIGH);
digitalWrite(DP, LOW);
digitalWrite(B, HIGH);
digitalWrite(A, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void zero() {
//High == off, LOW == On
digitalWrite(E, HIGH);
digitalWrite(D, HIGH);
digitalWrite(C, HIGH);
digitalWrite(DP, LOW);
digitalWrite(B, HIGH);
digitalWrite(A, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, LOW);
}
void a() {
//High == off, LOW == On
digitalWrite(E, HIGH);
digitalWrite(D, LOW);
digitalWrite(C, HIGH);
digitalWrite(DP, LOW);
digitalWrite(B, HIGH);
digitalWrite(A, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void b() {
//High == off, LOW == On
digitalWrite(E, HIGH);
digitalWrite(D, HIGH);
digitalWrite(C, HIGH);
digitalWrite(DP, LOW);
digitalWrite(B, LOW);
digitalWrite(A, LOW);
digitalWrite(F, HIGH);
digitalWrite(G, HIGH);
}
void c() {
//High == off, LOW == On
digitalWrite(E, HIGH);
digitalWrite(D, HIGH);
digitalWrite(C, LOW);
digitalWrite(DP, LOW);
digitalWrite(B, LOW);
digitalWrite(A, HIGH);
digitalWrite(F, HIGH);
digitalWrite(G, LOW);
}
void d() {
//High == off, LOW == On
digitalWrite(E, HIGH);
digitalWrite(D, HIGH);
digitalWrite(C, HIGH);
digitalWrite(DP, LOW);
digitalWrite(B, HIGH);
digitalWrite(A, LOW);
digitalWrite(F, LOW);
digitalWrite(G, HIGH);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(E, OUTPUT);
pinMode(D, OUTPUT);
pinMode(C, OUTPUT);
pinMode(DP, OUTPUT);
pinMode(B, OUTPUT);
pinMode(A, OUTPUT);
pinMode(F, OUTPUT);
pinMode(G, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
char key = keypad.getKey();
if (key == "1") {
one();
}
}
Кажется, что это какая-то ошибка с переменными, я понимаю, почему возникает ошибка нескольких библиотек, однако я не могу понять, в чем проблема с другими ошибками. Это, наверное, просто что-то очень простое, что я пропустил! Любая помощь будет оценена! :) Спасибо!