dimanche 12 juin 2016

arduino if statement giving error


I am working on some arduino code and my program keeps on giving me this error,

ISO C++ forbids comparison between pointer and integer [-fpermissive] 

I've tried searching on the internet to solve this issue but, either the solution is incorrect, or irrelevant. here is where the arduino software is saying the problem is,

if((millis - incLastDebounce) > debounceDelay) {

and if you need the rest of the code here it is,

#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;
}

hopefully you can find the problem and help.


Aucun commentaire:

Enregistrer un commentaire