"not declared in scope error", can't figure out why

Howdy! I have a "was not declared in this scope error" for two elements, "recvOneChar()" and "showAndSaveNewData();", both in lines 78 and 79 of the code. I think I might have a bracket error yet can't figure it out, any help is appreciated.

//LCD & IR initial config:
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <SD.h>

LiquidCrystal_I2C lcd (0x27, 16, 2);

const byte PulsesPerRevolution = 2;
const unsigned long ZeroTimeout = 100000;
const byte numReadings = 2;

volatile unsigned long LastTimeWeMeasured;
volatile unsigned long PeriodBetweenPulses = ZeroTimeout + 1000;
volatile unsigned long PeriodAverage = ZeroTimeout + 1000;
unsigned long FrequencyRaw;
unsigned long FrequencyReal;
unsigned long RPM;
unsigned int PulseCounter = 1;
unsigned long PeriodSum;

unsigned long LastTimeCycleMeasure = LastTimeWeMeasured;
unsigned long CurrentMicros = micros();
unsigned int AmountOfReadings = 1;
unsigned int ZeroDebouncingExtra;
unsigned long readings[numReadings];
unsigned long readIndex;  
unsigned long total; 
unsigned long average;

#define button_pin 7

//BOTON initial config:
// variables will change:
int button_press_count = 0;
int button_state = 0;
int prev_button_state = 0;

//SD
const int chipSelect = 4;
char receivedChar;
boolean newData = false;


void setup() {
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  attachInterrupt(digitalPinToInterrupt(2), Pulse_Event, RISING);
  delay(1000);

  delay(100);
  Serial.begin(9600);
  pinMode (button_pin, INPUT_PULLUP); //Set digi pin 7 as pull up button
  pinMode (13, OUTPUT);

  Serial.println("Button Count:");

  //SD
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
  Serial.println("<Arduino is ready>");

}
void loop() 
{ 
  recvOneChar();
  showAndSaveNewData();

  LastTimeCycleMeasure = LastTimeWeMeasured;
  CurrentMicros = micros();
  if (CurrentMicros < LastTimeCycleMeasure) {
    LastTimeCycleMeasure = CurrentMicros;
  }
  FrequencyRaw = 10000000000 / PeriodAverage;
  if (PeriodBetweenPulses > ZeroTimeout - ZeroDebouncingExtra || CurrentMicros - LastTimeCycleMeasure > ZeroTimeout - ZeroDebouncingExtra) {
    FrequencyRaw = 0;  // Set frequency as 0.
    ZeroDebouncingExtra = 2000;
  } else {
    ZeroDebouncingExtra = 0;
  }
  FrequencyReal = FrequencyRaw / 10000;

  RPM = FrequencyRaw / PulsesPerRevolution * 60;
  RPM = RPM / 10000;
  total = total - readings[readIndex];
  readings[readIndex] = RPM;
  total = total + readings[readIndex];
  readIndex = readIndex + 1;

  if (readIndex >= numReadings) {
    readIndex = 0;
  }
  average = total / numReadings;

  button_state = digitalRead(button_pin);
  if (button_state != prev_button_state) {
    if (button_state == HIGH) {
      digitalWrite(13, LOW);
    } else { //button press
      digitalWrite(13, HIGH);
      button_press_count++;
      Serial.println(button_press_count); //print the count
    }
    delay(50);
  }
  prev_button_state = button_state;

  Serial.print("Period: ");
  Serial.print(PeriodBetweenPulses);
  Serial.print("\tReadings: ");
  Serial.print(AmountOfReadings);
  Serial.print("\tFrequency: ");
  Serial.print(FrequencyReal);
  Serial.print("\tRPM: ");
  Serial.print(RPM);
  Serial.print("\tTachometer: ");
  Serial.println(average);
  lcd.setCursor(0, 0);
  lcd.print("RPM : ");
  lcd.print(average);
  lcd.print("   ");

  lcd.setCursor(0, 1);
  lcd.print("# vueltas : ");
  lcd.print(button_press_count);

}

void Pulse_Event() {
  PeriodBetweenPulses = micros() - LastTimeWeMeasured;
  LastTimeWeMeasured = micros();
  if (PulseCounter >= AmountOfReadings)  {
    PeriodAverage = PeriodSum / AmountOfReadings;
    PulseCounter = 1;
    PeriodSum = PeriodBetweenPulses;

    int RemapedAmountOfReadings = map(PeriodBetweenPulses, 40000, 5000, 1, 10);
    RemapedAmountOfReadings = constrain(RemapedAmountOfReadings, 1, 10);
    AmountOfReadings = RemapedAmountOfReadings;
  } else {
    PulseCounter++;
    PeriodSum = PeriodSum + PeriodBetweenPulses;
  }
}```

These two functions are not defined anywhere in your sketch.

Welcome to the forum.

The compiler is telling you: "I have been looking as far as I was allowed but I could not find the 'recvOneChar()' function or the 'showAndSaveNewData()' function. Since I can not compile it, I might as well stop and exit with an error".

In other words: those functions do no exist. Did you copy the code from someone else ? Can you give a link to that ? I think you forgot to copy everything.

[UPDATE] I found it here: Trying to make Serial monitor data to SD card - #5 by system

Yup! I was copying the code from that thread, yet they do not declare such functions

Therefore their code can not possibly work, or you made a mistake in copying.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.