debounceA + debounceB not working

hey.
i have a small problem with the debouncing that i'm using.
here is the code.

void debounceA()
{
int readingA = digitalRead(buttonAPin);

if (readingA != lastButtonAState)
{
lastDebounceTimeA = millis();
looptriggerA = millis();
}
if ((millis() - lastDebounceTimeA) > debounceDelay)
{
if (readingA != buttonAState)
{
buttonAState = readingA;
}
}
lastButtonAState = readingA;
lastDebounceTimeA = 0;
return;
}

void debounceB() // Debounce A2 input
{
int readingB = digitalRead(buttonBPin);

if (readingB != lastButtonBState)
{
lastDebounceTimeB = millis();
looptriggerB = millis();
}
if ((millis() - lastDebounceTimeB) > debounceDelay)
{
if (readingB != buttonBState)
{
buttonBState = readingB;
}
}
lastButtonBState = readingB;
lastDebounceTimeB = 0;
return;

later down the road i'm using

debounceA();

and i get the error message 'debounceA' was not declared in this scope.
i have no idea what could be wrong

Post a complete Arduino sketch. Use Code Tags.

Instead of declaring two identical methods, you should use arrays and create one method which takes an index to the arrays. Your debounce code is overcomplicated and hard to understand since a lot of code is missing. But one one of your problems is that you need to check the debounce time in the first "if" - when the second "if" is executed, "lastDebounceTimeX" will always be very close to the value of "millis()" since that is what it has just been set to in the first "if".

Like this ?

 // Set pin numbers:
const int buttonAPin = A1;     // The number of the pushbutton pins
const int buttonBPin = A2;

const int ledPin = 13;        // The number of the LED pin
const int RelayA = 2;        // The number of the relay coil drive pin
const int RelayB = 3;
const int RelayC = 11;

// Define Variables
int buttonAState = HIGH;
int lastButtonAState = HIGH;

int RUNNING = LOW;
int OCCUPIED = LOW;

int buttonBState = HIGH;
int lastButtonBState = HIGH;

// The following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.

unsigned long lastDebounceTimeA = 0;
unsigned long lastDebounceTimeB = 0;

unsigned long debounceDelay = 50;
unsigned long loopdelayA = 500;
unsigned long looptriggerA;
unsigned long loopdelayB = 500;
unsigned long looptriggerB;
unsigned long RUNNINGtime = 3000;
unsigned long RUNNINGtrigger;

#include <LiquidCrystal.h>

// Select the pin used on LCD
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  Serial.begin(9600);

  pinMode(ledPin, OUTPUT);
  pinMode(RelayA, OUTPUT);
  pinMode(buttonAPin, INPUT_PULLUP);
  pinMode(RelayB, OUTPUT);
  pinMode(buttonBPin, INPUT_PULLUP);
  pinMode(RelayC, OUTPUT);



  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("KEVino 2017");
  lcd.setCursor(0, 1);
  lcd.print("RAILCROSS");
  delay(1000);
  // Scroll 16 positions (string length)to the left
  // To move it offscreen left:
  {
    for (int positionCounter = 0; positionCounter < 16; positionCounter++);
    // Scroll one position left:
    lcd.scrollDisplayRight();
    // Wait a bit
    delay(30);
    {
      lcd.begin(16, 2);
      lcd.setCursor(0, 0);
      lcd.print("Railcross");
    }


    void debounceA();

    int readingA = digitalRead(buttonAPin);

    if (readingA != lastButtonAState)
    {
      lastDebounceTimeA = millis();
      looptriggerA = millis();
    }
    if ((millis() - lastDebounceTimeA) > debounceDelay)
    {
      if (readingA != buttonAState)
      {
        buttonAState = readingA;
      }
    }
    lastButtonAState = readingA;
    lastDebounceTimeA = 0;
    return;
  }

  void debounceB();                    // Debounce A2 Input

  int readingB = digitalRead(buttonBPin);

  if (readingB != lastButtonBState)
  {
    lastDebounceTimeB = millis();
    looptriggerB = millis();
  }
    if ((millis() - lastDebounceTimeB) > debounceDelay)
  {
  if (readingB != buttonBState)
    {
      buttonBState = readingB;
    }
  }
  lastButtonBState = readingB;
                     lastDebounceTimeB = 0;
                     return;
}

void START()                        // 1/2 second pulse on Relay A,
{ // RUNNING set HIGH,,Relay C set.
  RUNNINGtrigger = millis();
  digitalWrite(RelayA, HIGH);
  digitalWrite(RelayC, HIGH);
  delay(500);
  digitalWrite(RelayA, LOW);
}
void STOP()                       // 1/2 second pulse on Relay B,
{ // Running set LOW,, Relay C cleared.
  RUNNINGtrigger = millis();
  digitalWrite(RelayB, HIGH);
  digitalWrite(RelayC, LOW);
  delay(500);
  digitalWrite(RelayB, LOW);
  RUNNING = LOW;
}

void loop()
{
  lcd.setCursor(13, 0);       // Display seconds elapsed
  lcd.print(millis() / 1000);
  debounceA();               // Debounce the sensor inputs
  debounceB();
  digitalWrite(ledPin, OCCUPIED);     // Use LED to indicate OCCUPIED

  if (buttonAState == LOW || buttonBState == LOW)
  {
    OCCUPIED = HIGH;
    RUNNINGtrigger = millis();
    Serial.write("OCCUPIED");
    Serial.println();
    lcd.setCursor(0, 1);
    lcd.print("Occupied");
  }
  else
  {
    OCCUPIED = LOW;
    lcd.setCursor(0, 1);
    lcd.print("     ");
  }

  if (OCCUPIED == HIGH && RUNNING == LOW)
  {
    START();
    Serial.write("START");
    Serial.println();
    lcd.setCursor(8, 1);
    lcd.print("RUNNING");
  }

  if (RUNNING == HIGH)
    if ((millis() - RUNNINGtrigger) > RUNNINGtime)
    {
      STOP();
      Serial.write("STOP");
      Serial.println();
      lcd.setCursor(8, 1);
      lcd.print("     ");
    }
}

Danois90:
Instead of declaring two identical methods, you should use arrays and create one method which takes an index to the arrays. Your debounce code is overcomplicated and hard to understand since a lot of code is missing. But one one of your problems is that you need to check the debounce time in the first "if" - when the second "if" is executed, "lastDebounceTimeX" will always be very close to the value of "millis()" since that is what it has just been set to in the first "if".

I've posted the full code for the project if that helps to understand more, if it's still not worth it, what would be a better way to do it

gfvalvo:
Post a complete Arduino sketch. Use Code Tags.

ive done it

Did you try to modify your code as suggested in #2?

You've apparently pasted your debounce functions into the middle of the setup function. There are other changes from the code you initially posted that aren't helping either, but I'd suggest that you fix the first problem & take another look.

Danois90:
Did you try to modify your code as suggested in #2?

don't know wich line i shall modify and how.

So I guess that you have copy-pasted some code from the interweb which does not work and now you want the arduino forum to fix it for you? Please hire a programmer or try in gigs and collabs.

Danois90:
So I guess that you have copy-pasted some code from the interweb which does not work and now you want the arduino forum to fix it for you? Please hire a programmer or try in gigs and collabs.

that was kinda uncalled for.
ive got everything else working except the debounce. as far as i can see code wise.
no need to sound snappy. ive never used debounce before and thats why i turn to the forum for help.
and yes the debounce function is copied but that shouldnt really matter if i could get it to work.