Why do I get these errors?

Hi,
I'm trying to set a new code for NANO Every board - starting by setting the board i/o pins for input and outputs but I keep getting the compiler errors all the time ...
Can you help ??

[code]
/*
  Dropper

  Set water drops for Macro photography.
  Set drops size and interval, display the time intervals on LCD ,set camera shutter interval .

  model, check the Technical Specs of your board at:
  https://www.arduino.cc/en/Main/Products

  Edit: Yossi Dror , 14 July 2021

  Modules:
  ARDUINO NANO EVERY board pinout:

  shutter_delay  D14 analog input pin
  drop2_delay    D15 analog input pin
  drop2_size     D16 analog input pin
  drop1_size     D17 analog input pin

  Start_drop_sw   D2  Digital input pin
  flash_fire_out  D7  Digital output pin
  shutter_out     D6  Digital output pin
  focus_output    D5  Digital output pin
  Solenoid        D4  Digital output pin

*/
// constants won't change. They're used here to set pin numbers:
const int Start_drop_sw  = D2;     // the number of the pushbutton pin
const int Selonoid       = D4;      // the number of the LED pin
const int Camera_Focus   = D5 ;   // pin D5 start focusing the camera
const int Camera_Shutter = D6 ;   // pin D6 fire the camera
const int Flash_Fire     = D7;   //  pin D7 fire the flash

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  // initialize digital pins as an output or OUTPUT.
  pinMode (Start_drop_sw, INPUT) ;
  pinMode (Selonoid, OUTPUT) ;
  pinMode (Camera_Focus, OUTPUT);
  pinMode (Camera_Shutter, OUTPUT);
  pinMode (Flash_Fire, OUTPUT );
}
/*
  // the loop function runs over and over again forever
  void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
  }
*/
[/code]

and the error list :

Arduino: 1.8.15 (Windows Store 1.8.49.0) (Windows 10), Board: "Arduino Nano Every, None (ATMEGA4809)"

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\hardware -hardware C:\Users\yossid\Documents\ArduinoData\packages -hardware C:\Users\yossid\Documents\Arduino\hardware -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\tools-builder -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\hardware\tools\avr -tools C:\Users\yossid\Documents\ArduinoData\packages -built-in-libraries C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries -libraries C:\Users\yossid\Documents\Arduino\libraries -fqbn=arduino:megaavr:nona4809:mode=off -ide-version=10815 -build-path C:\Users\yossid\AppData\Local\Temp\arduino_build_974696 -warnings=none -build-cache C:\Users\yossid\AppData\Local\Temp\arduino_cache_882210 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\yossid\Documents\ArduinoData\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\yossid\Documents\ArduinoData\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Users\yossid\Documents\ArduinoData\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=C:\Users\yossid\Documents\ArduinoData\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avrdude.path=C:\Users\yossid\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\yossid\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Users\yossid\Documents\Arduino\Projects\Dropper\Dropper.ino

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\arduino-builder -compile -logger=machine -hardware C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\hardware -hardware C:\Users\yossid\Documents\ArduinoData\packages -hardware C:\Users\yossid\Documents\Arduino\hardware -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\tools-builder -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\hardware\tools\avr -tools C:\Users\yossid\Documents\ArduinoData\packages -built-in-libraries C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\libraries -libraries C:\Users\yossid\Documents\Arduino\libraries -fqbn=arduino:megaavr:nona4809:mode=off -ide-version=10815 -build-path C:\Users\yossid\AppData\Local\Temp\arduino_build_974696 -warnings=none -build-cache C:\Users\yossid\AppData\Local\Temp\arduino_cache_882210 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Users\yossid\Documents\ArduinoData\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Users\yossid\Documents\ArduinoData\packages\arduino\tools\arduinoOTA\1.3.0 -prefs=runtime.tools.avr-gcc.path=C:\Users\yossid\Documents\ArduinoData\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=C:\Users\yossid\Documents\ArduinoData\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5 -prefs=runtime.tools.avrdude.path=C:\Users\yossid\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17 -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Users\yossid\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17 -verbose C:\Users\yossid\Documents\Arduino\Projects\Dropper\Dropper.ino

Using board 'nona4809' from platform in folder: C:\Users\yossid\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.7

Using core 'arduino' from platform in folder: C:\Users\yossid\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.7

Detecting libraries used...

"C:\Users\yossid\Documents\ArduinoData\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=10815 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\Users\yossid\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/deprecated" "-IC:\Users\yossid\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.7\cores\arduino" "-IC:\Users\yossid\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.7\variants\nona4809" "C:\Users\yossid\AppData\Local\Temp\arduino_build_974696\sketch\Dropper.ino.cpp" -o nul

Generating function prototypes...

"C:\Users\yossid\Documents\ArduinoData\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=10815 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\Users\yossid\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/deprecated" "-IC:\Users\yossid\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.7\cores\arduino" "-IC:\Users\yossid\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.7\variants\nona4809" "C:\Users\yossid\AppData\Local\Temp\arduino_build_974696\sketch\Dropper.ino.cpp" -o "C:\Users\yossid\AppData\Local\Temp\arduino_build_974696\preproc\ctags_target_for_gcc_minus_e.cpp"

"C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.49.0_x86__mdqgnx93n4wtt\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\yossid\AppData\Local\Temp\arduino_build_974696\preproc\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\Users\yossid\Documents\ArduinoData\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 -MMD -flto -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10815 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\Users\yossid\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.7\cores\arduino/api/deprecated" "-IC:\Users\yossid\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.7\cores\arduino" "-IC:\Users\yossid\Documents\ArduinoData\packages\arduino\hardware\megaavr\1.8.7\variants\nona4809" "C:\Users\yossid\AppData\Local\Temp\arduino_build_974696\sketch\Dropper.ino.cpp" -o "C:\Users\yossid\AppData\Local\Temp\arduino_build_974696\sketch\Dropper.ino.cpp.o"

Dropper:28:28: error: 'D2' was not declared in this scope

const int Start_drop_sw = D2; // the number of the pushbutton pin

                        ^~

C:\Users\yossid\Documents\Arduino\Projects\Dropper\Dropper.ino:28:28: note: suggested alternative: 'A2'

const int Start_drop_sw = D2; // the number of the pushbutton pin

                        ^~

                        A2

Dropper:29:28: error: 'D4' was not declared in this scope

const int Selonoid = D4; // the number of the LED pin

                        ^~

C:\Users\yossid\Documents\Arduino\Projects\Dropper\Dropper.ino:29:28: note: suggested alternative: 'A4'

const int Selonoid = D4; // the number of the LED pin

                        ^~

                        A4

Dropper:30:28: error: 'D5' was not declared in this scope

const int Camera_Focus = D5 ; // pin D5 start focusing the camera

                        ^~

C:\Users\yossid\Documents\Arduino\Projects\Dropper\Dropper.ino:30:28: note: suggested alternative: 'A5'

const int Camera_Focus = D5 ; // pin D5 start focusing the camera

                        ^~

                        A5

Dropper:31:28: error: 'D6' was not declared in this scope

const int Camera_Shutter = D6 ; // pin D6 fire the camera

                        ^~

C:\Users\yossid\Documents\Arduino\Projects\Dropper\Dropper.ino:31:28: note: suggested alternative: 'A6'

const int Camera_Shutter = D6 ; // pin D6 fire the camera

                        ^~

                        A6

Dropper:32:28: error: 'D7' was not declared in this scope

const int Flash_Fire = D7; // pin D7 fire the flash

                        ^~

C:\Users\yossid\Documents\Arduino\Projects\Dropper\Dropper.ino:32:28: note: suggested alternative: 'A7'

const int Flash_Fire = D7; // pin D7 fire the flash

                        ^~

                        A7

exit status 1

'D2' was not declared in this scope

Why are the digital pins prefixed with D ?
Only needed for Analog (A) pins.

Hello
Yes, I can :nerd_face:
change

const int Start_drop_sw  = D2;     // the number of the pushbutton pin
const int Selonoid       = D4;      // the number of the LED pin
const int Camera_Focus   = D5 ;   // pin D5 start focusing the camera
const int Camera_Shutter = D6 ;   // pin D6 fire the camera
const int Flash_Fire     = D7;   //  pin D7 fire the flash

to

const int Start_drop_sw  = 2;     // the number of the pushbutton pin
const int Selonoid       = 4;      // the number of the LED pin
const int Camera_Focus   = 5 ;   // pin D5 start focusing the camera
const int Camera_Shutter = 6 ;   // pin D6 fire the camera
const int Flash_Fire     = 7;   //  pin D7 fire the flash

and have a nice day.

1 Like

I will try!!
thanks a lot

Why 'void loop()' is in commented? No 'void loop()', no compilling code.

Hi, @yossi_dror
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

Is this your first Arduino code that you have ever written?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

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