#include "ServoEasing.h"
ServoEasing servoTop;
ServoEasing servoBottom;
const int action_pin = 2;
int location = 31;
// Below numbers should be adjusted in case the facemask does not close/open to desired angle
int bottom_closed = 107;
int top_closed = 167;
int bottom_open = 20;
int top_open = 20;
void setup()
{
pinMode(action_pin, INPUT_PULLUP);
servoTop.attach(9);
servoBottom.attach(10);
setSpeedForAllServos(190);
servoTop.setEasingType(EASE_CUBIC_IN_OUT);
servoBottom.setEasingType(EASE_CUBIC_IN_OUT);
synchronizeAllServosStartAndWaitForAllServosToStop();
}
void loop()
{
int proximity = digitalRead(action_pin);
if (proximity == LOW)
{
if (location > bottom_open) {
servoTop.setEaseTo(top_open);
servoBottom.setEaseTo(bottom_open);
synchronizeAllServosStartAndWaitForAllServosToStop();
location = bottom_open;
delay(600);
} else {
servoTop.setEaseTo(top_closed);
servoBottom.setEaseTo(bottom_closed);
synchronizeAllServosStartAndWaitForAllServosToStop();
location = bottom_closed;
delay(600);
}
}
}
FQBN: arduino:megaavr:nona4809
Using board 'nona4809' from platform in folder: C:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8
Using core 'arduino' from platform in folder: C:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8
Detecting libraries used...
C:\Users\paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5/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=atmega4809 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DAVR_NANO_4809_328MODE -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP -IC:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino/api/deprecated -IC:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino -IC:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\variants\nona4809 C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\sketch\sketch_nov12a.ino.cpp -o nul
Alternatives for ServoEasing.h: [ServoEasing@3.4.0]
ResolveLibrary(ServoEasing.h)
-> candidates: [ServoEasing@3.4.0]
C:\Users\paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5/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=atmega4809 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DAVR_NANO_4809_328MODE -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP -IC:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino/api/deprecated -IC:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino -IC:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\variants\nona4809 -IC:\Users\paolo\Documents\Arduino\libraries\ServoEasing\src C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\sketch\sketch_nov12a.ino.cpp -o nul
Alternatives for Servo.h: [Servo@1.2.2]
ResolveLibrary(Servo.h)
-> candidates: [Servo@1.2.2]
C:\Users\paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5/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=atmega4809 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DAVR_NANO_4809_328MODE -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP -IC:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino/api/deprecated -IC:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino -IC:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\variants\nona4809 -IC:\Users\paolo\Documents\Arduino\libraries\ServoEasing\src -IC:\Users\paolo\AppData\Local\Arduino15\libraries\Servo\src C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\sketch\sketch_nov12a.ino.cpp -o nul
Using cached library dependencies for file: C:\Users\paolo\AppData\Local\Arduino15\libraries\Servo\src\avr\Servo.cpp
Using cached library dependencies for file: C:\Users\paolo\AppData\Local\Arduino15\libraries\Servo\src\mbed\Servo.cpp
Using cached library dependencies for file: C:\Users\paolo\AppData\Local\Arduino15\libraries\Servo\src\megaavr\Servo.cpp
Using cached library dependencies for file: C:\Users\paolo\AppData\Local\Arduino15\libraries\Servo\src\nrf52\Servo.cpp
Using cached library dependencies for file: C:\Users\paolo\AppData\Local\Arduino15\libraries\Servo\src\renesas\Servo.cpp
Using cached library dependencies for file: C:\Users\paolo\AppData\Local\Arduino15\libraries\Servo\src\sam\Servo.cpp
Using cached library dependencies for file: C:\Users\paolo\AppData\Local\Arduino15\libraries\Servo\src\samd\Servo.cpp
Using cached library dependencies for file: C:\Users\paolo\AppData\Local\Arduino15\libraries\Servo\src\stm32f4\Servo.cpp
Using cached library dependencies for file: C:\Users\paolo\AppData\Local\Arduino15\libraries\Servo\src\xmc\Servo.cpp
Generating function prototypes...
C:\Users\paolo\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5/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=atmega4809 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DAVR_NANO_4809_328MODE -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP -IC:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino/api/deprecated -IC:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino -IC:\Users\paolo\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\variants\nona4809 -IC:\Users\paolo\Documents\Arduino\libraries\ServoEasing\src -IC:\Users\paolo\AppData\Local\Arduino15\libraries\Servo\src C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\sketch\sketch_nov12a.ino.cpp -o C:\Users\paolo\AppData\Local\Temp\536549386\sketch_merged.cpp
C:\Users\paolo\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\paolo\AppData\Local\Temp\536549386\sketch_merged.cpp
Compiling sketch...
"C:\\Users\\paolo\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DAVR_NANO_4809_328MODE -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\paolo\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\cores\\arduino/api/deprecated" "-IC:\\Users\\paolo\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\cores\\arduino" "-IC:\\Users\\paolo\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\variants\\nona4809" "-IC:\\Users\\paolo\\Documents\\Arduino\\libraries\\ServoEasing\\src" "-IC:\\Users\\paolo\\AppData\\Local\\Arduino15\\libraries\\Servo\\src" "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE\\sketch\\sketch_nov12a.ino.cpp" -o "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE\\sketch\\sketch_nov12a.ino.cpp.o"
In file included from C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a\sketch_nov12a.ino:1:0:
C:\Users\paolo\Documents\Arduino\libraries\ServoEasing\src/ServoEasing.h:939:2: warning: #warning You probably must change the line #include "ServoEasing.h" to #include "ServoEasing.hpp" in your ino file or define SUPPRESS_HPP_WARNING before the include to suppress this warning. [-Wcpp]
#warning You probably must change the line #include "ServoEasing.h" to #include "ServoEasing.hpp" in your ino file or define SUPPRESS_HPP_WARNING before the include to suppress this warning.
^~~~~~~
In file included from C:\Users\paolo\AppData\Local\Arduino15\libraries\Servo\src/Servo.h:73:0,
from C:\Users\paolo\Documents\Arduino\libraries\ServoEasing\src/ServoEasing.h:134,
from C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a\sketch_nov12a.ino:1:
C:\Users\paolo\AppData\Local\Arduino15\libraries\Servo\src/megaavr/ServoTimers.h:38:24: warning: '_timer' defined but not used [-Wunused-variable]
static volatile TCB_t* _timer =
^~~~~~
Compiling libraries...
Compiling library "ServoEasing"
Compiling library "Servo"
Using previously compiled file: C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\libraries\Servo\avr\Servo.cpp.o
Using previously compiled file: C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\libraries\Servo\mbed\Servo.cpp.o
Using previously compiled file: C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\libraries\Servo\stm32f4\Servo.cpp.o
Using previously compiled file: C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\libraries\Servo\sam\Servo.cpp.o
Using previously compiled file: C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\libraries\Servo\nrf52\Servo.cpp.o
Using previously compiled file: C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\libraries\Servo\samd\Servo.cpp.o
Using previously compiled file: C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\libraries\Servo\xmc\Servo.cpp.o
Using previously compiled file: C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\libraries\Servo\renesas\Servo.cpp.o
Using previously compiled file: C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\libraries\Servo\megaavr\Servo.cpp.o
Compiling core...
Using previously compiled file: C:\Users\paolo\AppData\Local\Temp\arduino\sketches\85F4446FD70000A1F96EBA183593BFFE\core\variant.c.o
Using precompiled core: C:\Users\paolo\AppData\Local\Temp\arduino\cores\arduino_megaavr_nona4809_mode_on_f6658976568d4c638aec09726ab15f15\core.a
Linking everything together...
"C:\\Users\\paolo\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-gcc" -Wall -Wextra -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -Wl,--section-start=.text=0x0 -mmcu=atmega4809 -o "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE/sketch_nov12a.ino.elf" "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE\\sketch\\sketch_nov12a.ino.cpp.o" "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE\\libraries\\Servo\\avr\\Servo.cpp.o" "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE\\libraries\\Servo\\mbed\\Servo.cpp.o" "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE\\libraries\\Servo\\megaavr\\Servo.cpp.o" "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE\\libraries\\Servo\\nrf52\\Servo.cpp.o" "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE\\libraries\\Servo\\renesas\\Servo.cpp.o" "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE\\libraries\\Servo\\sam\\Servo.cpp.o" "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE\\libraries\\Servo\\samd\\Servo.cpp.o" "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE\\libraries\\Servo\\stm32f4\\Servo.cpp.o" "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE\\libraries\\Servo\\xmc\\Servo.cpp.o" "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE\\core\\variant.c.o" "C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE/..\\..\\cores\\arduino_megaavr_nona4809_mode_on_f6658976568d4c638aec09726ab15f15\\core.a" "-LC:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE" -lm "-Wl,-Map,C:\\Users\\paolo\\AppData\\Local\\Temp\\arduino\\sketches\\85F4446FD70000A1F96EBA183593BFFE/sketch_nov12a.ino.map"
C:\Users\paolo\AppData\Local\Temp\ccOhsyug.ltrans0.ltrans.o: In function `setup':
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:16: undefined reference to `ServoEasing::attach(int)'
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:17: undefined reference to `ServoEasing::attach(int)'
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:18: undefined reference to `setSpeedForAllServos(unsigned int)'
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:19: undefined reference to `ServoEasing::setEasingType(unsigned char)'
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:20: undefined reference to `ServoEasing::setEasingType(unsigned char)'
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:21: undefined reference to `synchronizeAllServosStartAndWaitForAllServosToStop()'
C:\Users\paolo\AppData\Local\Temp\ccOhsyug.ltrans0.ltrans.o: In function `loop':
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:31: undefined reference to `ServoEasing::setEaseTo(int)'
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:32: undefined reference to `ServoEasing::setEaseTo(int)'
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:33: undefined reference to `synchronizeAllServosStartAndWaitForAllServosToStop()'
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:37: undefined reference to `ServoEasing::setEaseTo(int)'
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:38: undefined reference to `ServoEasing::setEaseTo(int)'
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:39: undefined reference to `synchronizeAllServosStartAndWaitForAllServosToStop()'
C:\Users\paolo\AppData\Local\Temp\ccOhsyug.ltrans0.ltrans.o: In function `_GLOBAL__sub_I_servoTop':
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:2: undefined reference to `ServoEasing::ServoEasing()'
C:\Users\paolo\AppData\Local\Temp\.arduinoIDE-unsaved20241012-30804-1cm61lk.nu2t\sketch_nov12a/sketch_nov12a.ino:3: undefined reference to `ServoEasing::ServoEasing()'
collect2.exe: error: ld returned 1 exit status
Using library ServoEasing at version 3.4.0 in folder: C:\Users\paolo\Documents\Arduino\libraries\ServoEasing
Using library Servo at version 1.2.2 in folder: C:\Users\paolo\AppData\Local\Arduino15\libraries\Servo
exit status 1
Compilation error: exit status 1
Please include the entire error message, in a <CODE/>
block.
Delta_G
November 14, 2024, 1:19pm
3
Did you catch this line in the error messages? I would start there.
xfpd
November 14, 2024, 1:52pm
4
Assuming your wiring is correct, and once you attend to the library reference (see post #3 ), your code works! Servos go to a start position. Push the button, servos move to a new position. Push the button again, servos move back to start. Repeat.