我正在处理一些arduino代码,我的程序一直在给我这个错误,
ISO C++ forbids comparison between pointer and integer [-fpermissive]
我已尝试在互联网上搜索以解决此问题但是,解决方案不正确或无关紧要。这里是arduino软件说的问题所在,
if((millis - incLastDebounce) > debounceDelay) {
如果您需要其余的代码,那么
#include <LiquidCrystal.h>
int freq = 0;
int change = 0;
const int incPin = 3;
const int setPin = 2;
int incButtonState;
int setButtonState;
int incPreviousState;
int setPreviousState;
int incLastDebounce;
int setLastDebounce;
const int debounceDelay = 50;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
pinMode(setPin, INPUT);
pinMode(incPin, INPUT);
lcd.print("Frequency: " + freq);
}
void loop() {
// put your main code here, to run repeatedly:
int incReading = digitalRead(incPin);
int setReading = digitalRead(setPin);
if(setReading != setPreviousState) {
setLastDebounce = millis();
}
if(incReading != incPreviousState) {
incLastDebounce = millis();
}
if((millis - setLastDebounce) > debounceDelay) {
if(setReading != setButtonState) {
setButtonState = setReading;
}
if(setButtonState == HIGH) {
//Okay so here you will do your set lcd voodoo
}
}
if((millis - incLastDebounce) > debounceDelay) {
if(incReading != buttonState) {
incButtonState = incReading;
}
if(buttonState == HIGH) {
// here you can put the lcd code
change = change + 500;
if(change == 10500){
change = 0;
}
}
}
incPreviousState = incReading;
setPreviousState = setReading;
}
希望你能找到问题和帮助。
答案 0 :(得分:2)
看起来你在millis
之后缺少括号,所以不是调用函数,而是试图用它的内存地址进行算术运算。
这可能会更好:
if ((millis() - incLastDebounce) > debounceDelay) {