Error compiling for board Arduino Mega or Mega 2560 for multi sketch

Hi,
I searched and did:
Tools > Board > Boards Managehttps://forum.arduino.cc/newr> install & Update.
error still.
Thanks for help.
Adam

// include the library code:
#include <LiquidCrystal.h>

#include "ACDC.h"
#include "CAPACITOR.h"
#include "COMPONENTS.h"
#include "OSCILLOSCOPE.h"
#include "PWM.h"

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void Setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");

  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);

}

void loop() {
  // ACDC.ACDCLoop();
  // CAPACITOR.CAPACITORLoop();
  // COMPONENTS.COMPONENTSLoop();
  // OSCILLOSCOPE.OSCILLOSCOPELoop();
  PWM.PWMLoop();
}
class PWMGen {

  private:
    const int pwmPin = 30; // assigns pin 12 to variable pwm
    const int potcyc = A6; // assigns analog pot input A0 to vary the cyc of pwm
    const int potfre = A7; // assigns analog pot input A1 to vary the cfrequency of pwm

  public:

    void PWMSetup()  // setup loop
    {
     // Serial.begin(9600);
      pinMode(pwmPin, OUTPUT);
      // Don't use pinMode() with analogRead()
    }

    void PWMLoop()
    {
      float dutyCycleVal = analogRead(potcyc) / 1024.0;
      int delayVal = map(analogRead(potfre), 0, 1024, 2000, 0); // delay in

      digitalWrite(pwmPin, HIGH);
      delayMicroseconds(delayVal * dutyCycleVal); // The ON part of the cycle
      digitalWrite(pwmPin, LOW);
      delayMicroseconds(delayVal * (1.0 - dutyCycleVal));  // The OFF part of the cycle
    }
};

PWMGen PWM;

ERROR:

Arduino: 1.8.13 (Windows 7), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"





















C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10813 -build-path C:\Users\HUA~1.DEL\AppData\Local\Temp\arduino_build_751777 -warnings=none -build-cache C:\Users\HUA~1.DEL\AppData\Local\Temp\arduino_cache_398538 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose E:\ENGINEERING\DIY\Electronic\meter\Arduino Multimeter\00_MAIN\MEGA2560.MAIN\MEGA2560.MAIN.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10813 -build-path C:\Users\HUA~1.DEL\AppData\Local\Temp\arduino_build_751777 -warnings=none -build-cache C:\Users\HUA~1.DEL\AppData\Local\Temp\arduino_cache_398538 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose E:\ENGINEERING\DIY\Electronic\meter\Arduino Multimeter\00_MAIN\MEGA2560.MAIN\MEGA2560.MAIN.ino

Using board 'mega' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Detecting libraries used...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\sketch\\MEGA2560.MAIN.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE

Alternatives for LiquidCrystal.h: [LiquidCrystal-1.0.7@1.0.7]

ResolveLibrary(LiquidCrystal.h)

  -> candidates: [LiquidCrystal-1.0.7@1.0.7]

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\HUA.DELLV-PC\\Documents\\Arduino\\libraries\\LiquidCrystal-1.0.7\\src" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\sketch\\MEGA2560.MAIN.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\HUA.DELLV-PC\\Documents\\Arduino\\libraries\\LiquidCrystal-1.0.7\\src" "C:\\Users\\HUA.DELLV-PC\\Documents\\Arduino\\libraries\\LiquidCrystal-1.0.7\\src\\LiquidCrystal.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE

Generating function prototypes...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\HUA.DELLV-PC\\Documents\\Arduino\\libraries\\LiquidCrystal-1.0.7\\src" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\sketch\\MEGA2560.MAIN.ino.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\preproc\\ctags_target_for_gcc_minus_e.cpp" -DARDUINO_LIB_DISCOVERY_PHASE

"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\HUA.DELLV-PC\\Documents\\Arduino\\libraries\\LiquidCrystal-1.0.7\\src" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\sketch\\MEGA2560.MAIN.ino.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\sketch\\MEGA2560.MAIN.ino.cpp.o"

Compiling libraries...

Compiling library "LiquidCrystal-1.0.7"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\HUA.DELLV-PC\\Documents\\Arduino\\libraries\\LiquidCrystal-1.0.7\\src" "C:\\Users\\HUA.DELLV-PC\\Documents\\Arduino\\libraries\\LiquidCrystal-1.0.7\\src\\LiquidCrystal.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\libraries\\LiquidCrystal-1.0.7\\LiquidCrystal.cpp.o"

Compiling core...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -c -g -x assembler-with-cpp -flto -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\wiring_pulse.S" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\wiring_pulse.S.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\wiring_analog.c" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\wiring_analog.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\hooks.c" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\hooks.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\wiring.c" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\wiring.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\WInterrupts.c" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\WInterrupts.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\wiring_digital.c" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\wiring_digital.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\wiring_pulse.c" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\wiring_pulse.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\wiring_shift.c" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\wiring_shift.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\CDC.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\CDC.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\HardwareSerial.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\HardwareSerial.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\HardwareSerial0.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\HardwareSerial0.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\HardwareSerial1.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\HardwareSerial1.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\HardwareSerial2.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\HardwareSerial2.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\HardwareSerial3.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\HardwareSerial3.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\IPAddress.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\IPAddress.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\PluggableUSB.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\PluggableUSB.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Print.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\Print.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Stream.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\Stream.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Tone.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\Tone.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\USBCore.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\USBCore.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\WMath.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\WMath.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\WString.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\WString.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\abi.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\abi.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\main.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\main.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\new.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\new.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\wiring_pulse.S.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\WInterrupts.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\hooks.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\wiring.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\wiring_analog.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\wiring_digital.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\wiring_pulse.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\wiring_shift.c.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\CDC.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\HardwareSerial.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\HardwareSerial0.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\HardwareSerial1.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\HardwareSerial2.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\HardwareSerial3.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\IPAddress.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\PluggableUSB.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\Print.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\Stream.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\Tone.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\USBCore.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\WMath.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\WString.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\abi.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\main.cpp.o"

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc-ar" rcs "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\core.a" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\core\\new.cpp.o"

Archiving built core (caching) in: C:\Users\HUA~1.DEL\AppData\Local\Temp\arduino_cache_398538\core\core_arduino_avr_mega_cpu_atmega2560_0c812875ac70eb4a9b385d8fb077f54c.a

Linking everything together...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega2560 -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777/MEGA2560.MAIN.ino.elf" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\sketch\\MEGA2560.MAIN.ino.cpp.o" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\libraries\\LiquidCrystal-1.0.7\\LiquidCrystal.cpp.o" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777/core\\core.a" "-LC:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777" -lm

C:\Users\HUA~1.DEL\AppData\Local\Temp\cchRA17o.ltrans0.ltrans.o: In function `main':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to `setup'

collect2.exe: error: ld returned 1 exit status

Using library LiquidCrystal-1.0.7 at version 1.0.7 in folder: C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\LiquidCrystal-1.0.7 

exit status 1

Error compiling for board Arduino Mega or Mega 2560.


Did you mean setup (lower case)?

1 Like

Thanks.
Great.

Hi again,
I added one more sub, came out: “expected unqualified-id before string constant“
Also, do I need modify:

void ch_select(byte n) {
AS
void ACDCCh_select(byte n) {
class ACDCMeter {
  
private:
// define autoranging channel pins
#define CH0  2
#define CH1  3
#define CH2  4
#define CH3  5

const uint16_t Time_Out = 50000,  // time out in microseconds
               Periods  = 10;     // number of periods of measurement (for AC voltage only)

// variables
byte ch_number;
const uint16_t res_table[4] = {2444, 244, 94, 47},  // voltage divider resistances in tenths kOhms
                              total_res = 22444;                   // total resistance in tenths kOhms
uint16_t current_res;
volatile byte per;

public:

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

  pinMode(CH0, OUTPUT);
  pinMode(CH1, OUTPUT);
  pinMode(CH2, OUTPUT);
  pinMode(CH3, OUTPUT);

  ch_number = 0;
  ch_select(ch_number);

  // ADC and analog comparator configuration
  ADMUX  = 0x03;
  ADCSRA = 0x87;
  ADCSRB = (0 << ACME);  // select AIN1 as comparator negative input
  ACSR   = 0x13;         // turn on analog comparator

  ///////////////////////
  Serial.print("ch_number.1 = ");
  Serial.println(ch_number);
  ////////////////////////////

}

// analog comparator ISR
ISR (ANALOG_COMP_vect)
{
  byte count = 0;
  for (byte i = 0; i < 50; i++) {
    if ( ACSR & 0x20 )
      count++;
  }

  if (count > 48)
    per++;
}

// main loop
void ACDCLoop()
{
  bool dc_flag = 0; // DC voltage flag bit
  int32_t sum = 0;  // sum of all readings
  uint16_t n = 0;   // number of readings (samples)

  ACSR = (1 << ACI);   // clear analog comparator interrupt flag
  ACSR = (1 << ACIE);  // enable analog comparator interrupt

  uint32_t current_m = micros();  // save current millis
  byte current_per = per;         // save current period number
  while ( (current_per == per) && (micros() - current_m < Time_Out) ) ;

  if ( micros() - current_m >= Time_Out ) { // if there's time out event ==> voltage signal is DC
    dc_flag = 1;
    for (byte i = 0; i < 200; i++) {
      ADCSRA |= 1 << ADSC;   // start conversion
      while (ADCSRA & 0x40); // wait for conversion complete
      int16_t an = (int16_t)(ADCL | (uint16_t)ADCH << 8) - 511;
      sum += an;
      n++;         // increment number of readings
      delay(1);
    }
  }

  else {   // here, voltage signal is AC
    current_m = micros();  // save current millis()
    per = 0;
    while ( (per < Periods) && (micros() - current_m < (uint32_t)Time_Out * Periods) ) {
      ADCSRA |= 1 << ADSC;   // start conversion
      while (ADCSRA & 0x40); // wait for conversion complete
      int32_t an = (int16_t)(ADCL | (uint16_t)ADCH << 8) - 511;
      sum += sq(an);  // sq: square
      n++;            // increment number of readings
    }
  }

  ACSR = (0 << ACIE);  // disable analog comparator interrupt
  uint32_t total_time = micros() - current_m;  // used to claculate frequency

  ///////////////////////
  Serial.print("ADMUX,BIN = ");
  Serial.println(ADMUX, BIN);
  ////////////////////////////

  // voltage calculation
  float v;
  if (dc_flag)  // if voltage signal is DC
    v = (4 * sum) / n; // calculate Arduino analog channel DC voltage in milli-Volts

  else  // here voltage signal is AC
    v = 4 * sqrt(sum / n); // calculate Arduino analog channel RMS voltage in milli-Volts

  // claculate actual (input) voltage in milli-Volts (apply voltage divider equation)
  v = v * (float)total_res / current_res;
  v /= 1000;  // get voltage in Volts

  uint16_t v_abs = abs(int16_t(v));
  if ( (v_abs >= 10 && ch_number == 0) || (v_abs >= 100 && ch_number == 1) || (v_abs >= 250 && ch_number == 2) ) {
    ch_number++;
    ch_select(ch_number);
    delay(10);
    return;
    ///////////////////////
    Serial.print("ch_number.2 = ");
    Serial.println(ch_number);
    ////////////////////////////

  }

  if ( (v_abs < 220 && ch_number == 3) || (v_abs < 80 && ch_number == 2) || (v_abs < 8 && ch_number == 1) ) {
    ch_number--;
    ch_select(ch_number);
    delay(10);
    return;

    ///////////////////////
    Serial.print("ch_number.3 = ");
    Serial.println(ch_number);
    ////////////////////////////

  }

  char _buffer[8];
  lcd.setCursor(0, 1);
  if ( v < 0)
    lcd.print('-');
  else
    lcd.print(' ');
  if (v_abs < 10)
    sprintf( _buffer, "%01u.%02u", v_abs, abs((int16_t)(v * 100)) % 100 );
  else if ( v_abs < 100)
    sprintf( _buffer, "%02u.%01u", v_abs, abs((int16_t)(v * 10)) % 10 );
  else
    sprintf( _buffer, "%03u ", v_abs );

  lcd.print(_buffer);
  if (dc_flag)
    lcd.print("VDC        ");
  else {
    lcd.print("VAC ");
    // calculate signal frequency in Hz
    uint32_t period_time = total_time / Periods;
    float freq = 1000000.0 / period_time;
    sprintf( _buffer, "%02u.%02uHz", (uint16_t)freq % 100, (uint16_t)(freq * 100) % 100 );
    lcd.print(_buffer);
  }

  delay(500);    // wait half a second

}

void ch_select(byte n) {
  switch (n) {
    case 0:
      digitalWrite(CH0, HIGH);
      digitalWrite(CH1, LOW);
      digitalWrite(CH2, LOW);
      digitalWrite(CH3, LOW);

      Serial.print("CH0 = ");
      Serial.println(CH0);

      break;
    case 1:
      digitalWrite(CH0, LOW);
      digitalWrite(CH1, HIGH);
      digitalWrite(CH2, LOW);
      digitalWrite(CH3, LOW);

      Serial.print("CH1 = ");
      Serial.println(CH1);

      break;
    case 2:
      digitalWrite(CH0, LOW);
      digitalWrite(CH1, LOW);
      digitalWrite(CH2, HIGH);
      digitalWrite(CH3, LOW);

      Serial.print("CH2 = ");
      Serial.println(CH2);

      break;
    case 3:
      digitalWrite(CH0, LOW);
      digitalWrite(CH1, LOW);
      digitalWrite(CH2, LOW);
      digitalWrite(CH3, HIGH);

      Serial.print("CH3 = ");
      Serial.println(CH3);
  }
  current_res = res_table[n];
  delay(1000);
}
};

ACDCMeter ACDC;

ERROR:

Arduino: 1.8.13 (Windows 7), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"





















C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10813 -build-path C:\Users\HUA~1.DEL\AppData\Local\Temp\arduino_build_751777 -warnings=none -build-cache C:\Users\HUA~1.DEL\AppData\Local\Temp\arduino_cache_398538 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose E:\ENGINEERING\DIY\Electronic\meter\Arduino Multimeter\00_MAIN\MEGA2560.MAIN\MEGA2560.MAIN.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\HUA.DELLV-PC\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10813 -build-path C:\Users\HUA~1.DEL\AppData\Local\Temp\arduino_build_751777 -warnings=none -build-cache C:\Users\HUA~1.DEL\AppData\Local\Temp\arduino_cache_398538 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose E:\ENGINEERING\DIY\Electronic\meter\Arduino Multimeter\00_MAIN\MEGA2560.MAIN\MEGA2560.MAIN.ino

Using board 'mega' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Detecting libraries used...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\sketch\\MEGA2560.MAIN.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE

Alternatives for LiquidCrystal.h: [LiquidCrystal-1.0.7@1.0.7]

ResolveLibrary(LiquidCrystal.h)

  -> candidates: [LiquidCrystal-1.0.7@1.0.7]

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\HUA.DELLV-PC\\Documents\\Arduino\\libraries\\LiquidCrystal-1.0.7\\src" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\sketch\\MEGA2560.MAIN.ino.cpp" -o nul -DARDUINO_LIB_DISCOVERY_PHASE

Using cached library dependencies for file: C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\LiquidCrystal-1.0.7\src\LiquidCrystal.cpp

Generating function prototypes...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\HUA.DELLV-PC\\Documents\\Arduino\\libraries\\LiquidCrystal-1.0.7\\src" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\sketch\\MEGA2560.MAIN.ino.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\preproc\\ctags_target_for_gcc_minus_e.cpp" -DARDUINO_LIB_DISCOVERY_PHASE

"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\HUA.DELLV-PC\\Documents\\Arduino\\libraries\\LiquidCrystal-1.0.7\\src" "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\sketch\\MEGA2560.MAIN.ino.cpp" -o "C:\\Users\\HUA~1.DEL\\AppData\\Local\\Temp\\arduino_build_751777\\sketch\\MEGA2560.MAIN.ino.cpp.o"

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:30:0,

                 from C:\Users\HUA~1.DEL\AppData\Local\Temp\arduino_build_751777\sketch\MEGA2560.MAIN.ino.cpp:1:

ACDC.h:63:1: error: expected unqualified-id before string constant

 ISR (ANALOG_COMP_vect)

 ^

In file included from E:\ENGINEERING\DIY\Electronic\meter\Arduino Multimeter\00_MAIN\MEGA2560.MAIN\MEGA2560.MAIN.ino:46:0:

C:\Users\HUA~1.DEL\AppData\Local\Temp\arduino_build_751777\sketch\ACDC.h: In member function 'void ACDCMeter::ACDCLoop()':

ACDC.h:160:3: error: 'lcd' was not declared in this scope

   lcd.setCursor(0, 1);

   ^~~

Using library LiquidCrystal-1.0.7 at version 1.0.7 in folder: C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\LiquidCrystal-1.0.7 

exit status 1

expected unqualified-id before string constant


Why?

Does this really belong inside of the ACDCMeter class?

Never use preprocessor macros for constants like that, the preprocessor doesn't follow any scope rules. Use constexpr static uint8_t CH0 = 2; instead (or without the static if it's outside of a class).

My guess is that you forgot to #include <avr/interrupt.h> in ACDC.h.

Edit: Don't define interrupt service routines inside of classes, they are free functions.
Upon further inspection, this applies to most of your functions: why are they member functions of a class if you can only have a single instance? Why not just use free functions?

1 Like

Thank you.
I'll check the all sketch.
BTW. the ACDC compiling well in a independent sketch.
and also should I put the ISR at main code? or what other function can replaced it here?