My code won't run on a nano every

Hello,

I've written some code that reads a couple of inputs from push button and make a couple of neopixel flashes with the fastled library.

My code run fine on a regular nano. I've upload it to a nano every and it does literraly nothing. the every can run Blink or whatever example just fine. I'm at a bit of a loss here.

Here is my setup function:

void setup() {
  currentMillis = millis();
  prevMillis = currentMillis; 

  //Ding();
  pinMode(LEDS_R, OUTPUT);
  pinMode(LEDS_G, OUTPUT);
  pinMode(BTN_LED_R, OUTPUT);
  pinMode(BTN_LED_G, OUTPUT);
  pinMode(BTN_R, INPUT);
  pinMode(BTN_G, INPUT);
  //pinMode(TRIG_1, OUTPUT);
  pinMode(TRIG_2, OUTPUT);

  Serial.begin(9600);
  Serial.println("Initializing...");

  EEPROM.get(ADDR_G, nbG);
  EEPROM.get(ADDR_R, nbR);

  Serial.print("Value stored ");
  Serial.print(round(nbR));
  Serial.print(": ");
  Serial.println(round(nbG));

  FastLED.addLeds<WS2812, LEDS_R, RGB>(leds_R, NUM_LEDS);
  FastLED.addLeds<WS2812, LEDS_G, RGB>(leds_G, NUM_LEDS);

  
  attachInterrupt(digitalPinToInterrupt(BTN_R), PressedR, FALLING);
  digitalWrite(BTN_LED_R, HIGH);
  attachInterrupt(digitalPinToInterrupt(BTN_G), PressedG, FALLING);
  digitalWrite(BTN_LED_G, HIGH);

  //digitalWrite(TRIG_1, HIGH); 
  digitalWrite(TRIG_2, LOW);


  for (int i =0; i < NUM_LEDS; i++ )
    {
      leds_R[9-i] = CRGB::Red;
      leds_G[i] = CRGB::Green;      
    }
    FastLED.show();
    delay(1000);
    for (int i =0; i < NUM_LEDS; i++ )
    {
      leds_R[9-i] = CRGB::Black;
      leds_G[i] = CRGB::Black;      
    }
    FastLED.show();
}

Here is my loop function:

void loop() {
 Idle(); 
}

void Idle() { //pulse both btn with PWN signal 
  
  float in, out;
  
  for (in = 0; in < 6.283; in = in + 0.00314)
  {
    out = sin(in) * 127.5 + 127.5;
    analogWrite(BTN_LED_R,out);
    analogWrite(BTN_LED_G,out);
    delay(3);
  }
}

My buttons don't pulse and the serial monitor is completly quiet on the every and everything works fine a on a regular nano. I've tested on three separate every and four different nano.

What could cause this?

I would suggest starting with an investigation of this specific problem. Serial Monitor is a very important tool for troubleshooting, so making sure you can get serial communication from your Nano Every will be essential.

When I'm having trouble with serial output, I like to do a quick check with the most simple possible sketch. If this works, then I know the problem has something to do with my real sketch. If it doesn't work, then I know the problem is not related to my sketch code. It seems maybe a little silly, but it allows me to be sure I'm focusing my troubleshooting efforts in the right direction.

Try uploading this sketch to your Arduino board:

  1. Copy and paste this code as a new sketch in Arduino IDE:
    void setup() {
      Serial.begin(9600);
    }
    
    void loop() {
      Serial.println("hello");
      delay(1000);
    }
    
  2. Upload the sketch to your Arduino board.
  3. Select Tools > Serial Monitor from the Arduino IDE menus to open the Serial Monitor view if it is not already open.
  4. Make sure the baud rate menu at the top right corner of the Serial Monitor panel is set to "9600".

Do you now see the word "hello" being printed in the Serial Monitor's output field once a second?

Yeah, I can read from the Serial port just fine

Here is the verbose from the upload:

FQBN: arduino:megaavr:nona4809:mode=off
Using board 'nona4809' from platform in folder: C:\Users\Xavier\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8
Using core 'arduino' from platform in folder: C:\Users\Xavier\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8

Detecting libraries used...
"C:\\Users\\Xavier\\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 -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\cores\\arduino/api/deprecated" "-IC:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\cores\\arduino" "-IC:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\variants\\nona4809" "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848\\sketch\\sketch_apr20b.ino.cpp" -o nul
Generating function prototypes...
"C:\\Users\\Xavier\\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 -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\cores\\arduino/api/deprecated" "-IC:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\cores\\arduino" "-IC:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\variants\\nona4809" "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848\\sketch\\sketch_apr20b.ino.cpp" -o "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Users\\Xavier\\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\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Users\\Xavier\\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 -MMD -flto -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\cores\\arduino/api/deprecated" "-IC:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\cores\\arduino" "-IC:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\variants\\nona4809" "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848\\sketch\\sketch_apr20b.ino.cpp" -o "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848\\sketch\\sketch_apr20b.ino.cpp.o"
Compiling libraries...
Compiling core...
"C:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO_EVERY -DARDUINO_ARCH_MEGAAVR -DMILLIS_USE_TIMERB3 -DNO_EXTERNAL_I2C_PULLUP "-IC:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\cores\\arduino/api/deprecated" "-IC:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\cores\\arduino" "-IC:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\variants\\nona4809" "C:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.8\\variants\\nona4809\\variant.c" -o "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848\\core\\variant.c.o"
Using precompiled core: C:\Users\Xavier\AppData\Local\Temp\arduino\cores\arduino_megaavr_nona4809_mode_off_afcf78e4a086cb07dea967c6e617ec18\core.a
Linking everything together...
"C:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -Wl,--section-start=.text=0x0 -mmcu=atmega4809 -o "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848/sketch_apr20b.ino.elf" "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848\\sketch\\sketch_apr20b.ino.cpp.o" "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848\\core\\variant.c.o" "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848/..\\..\\cores\\arduino_megaavr_nona4809_mode_off_afcf78e4a086cb07dea967c6e617ec18\\core.a" "-LC:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848" -lm "-Wl,-Map,C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848/sketch_apr20b.ino.map"
"C:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-objcopy" -O binary -R .eeprom "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848/sketch_apr20b.ino.elf" "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848/sketch_apr20b.ino.bin"
"C:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848/sketch_apr20b.ino.elf" "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848/sketch_apr20b.ino.eep"
"C:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848/sketch_apr20b.ino.elf" "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848/sketch_apr20b.ino.hex"

"C:\\Users\\Xavier\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-size" -A "C:\\Users\\Xavier\\AppData\\Local\\Temp\\arduino\\sketches\\547CF1CBA0B9FF6D26E42B173DE5E848/sketch_apr20b.ino.elf"
Sketch uses 2831 bytes (5%) of program storage space. Maximum is 49152 bytes.
Global variables use 177 bytes (2%) of dynamic memory, leaving 5967 bytes for local variables. Maximum is 6144 bytes.
Performing 1200-bps touch reset on serial port COM24
"C:\Users\Xavier\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Xavier\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega4809 -cjtag2updi -PCOM24  -b115200 -e -D "-Uflash:w:C:\Users\Xavier\AppData\Local\Temp\arduino\sketches\547CF1CBA0B9FF6D26E42B173DE5E848/sketch_apr20b.ino.hex:i" "-Ufuse2:w:0x01:m" "-Ufuse5:w:0xC9:m" "-Ufuse8:w:0x00:m" {upload.extra_files}

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Xavier\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM24
         Using Programmer              : jtag2updi
         Overriding Baud Rate          : 115200
JTAG ICE mkII sign-on message:
Communications protocol version: 1
M_MCU:
  boot-loader FW version:        1
  firmware version:              1.07
  hardware version:              1
S_MCU:
  boot-loader FW version:        1
  firmware version:              6.07
  hardware version:              1
Serial number:                   00:00:00:00:00:00
Device ID:                       JTAGICE mkII
         AVR Part                      : ATmega4809
         Chip Erase delay              : 0 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 0
         StabDelay                     : 0
         CmdexeDelay                   : 0
         SyncLoops                     : 0
         ByteDelay                     : 0
         PollIndex                     : 0
         PollValue                     : 0x00
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           prodsig        0     0     0    0 no         61   61      0     0     0 0x00 0x00
           fuses          0     0     0    0 no          9    0      0     0     0 0x00 0x00
           fuse0          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse1          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse2          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse4          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse5          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse6          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse7          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse8          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0     0     0 0x00 0x00
           data           0     0     0    0 no          0    0      0     0     0 0x00 0x00
           usersig        0     0     0    0 no         64   64      0     0     0 0x00 0x00
           flash          0     0     0    0 no      49152  128      0     0     0 0x00 0x00
           eeprom         0     0     0    0 no        256   64      0     0     0 0x00 0x00

         Programmer Type : JTAGMKII_PDI
         Description     : JTAGv2 to UPDI bridge
         M_MCU hardware version: 1
         M_MCU firmware version: 1.07
         S_MCU hardware version: 1
         S_MCU firmware version: 6.07
         Serial number:          00:00:00:00:00:00
         Vtarget         : 5.0 V

avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.27s

avrdude: Device signature = 0x1e9651 (probably m4809)
avrdude: erasing chip
avrdude: reading input file "C:\Users\Xavier\AppData\Local\Temp\arduino\sketches\547CF1CBA0B9FF6D26E42B173DE5E848/sketch_apr20b.ino.hex"
avrdude: writing flash (2832 bytes):

Writing | ################################################## | 100% 2.16s

avrdude: 2832 bytes of flash written
avrdude: reading input file "0x01"
avrdude: writing fuse2 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse2 written
avrdude: reading input file "0xC9"
avrdude: writing fuse5 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse5 written
avrdude: reading input file "0x00"
avrdude: writing fuse8 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse8 written

avrdude done.  Thank you.


FastLED isn't supported on the every (I think).

I have 2 every's waiting for a possible application, can't use these now because the Dallas temperature library isn't supported.......

I didn't test it, but the changelog says support for the Nano Every was added in the FastLED 3.4.0 release:

https://github.com/FastLED/FastLED/blob/master/release_notes.md#fastled-340

  • Merged in contributed support for Arduino Nano Every / Arduino Uno Wifi Rev. 2

I believe this is the relevant PR:

There is also some related discussion here:

FastLED isn't supported on the every (I think).

I was afraid that might be the case.

I actually fixed my problem in the worst possible way. I went away from my desk for lunch and an our later I uploaded the exact same code without changing anything and now it kinda works.

The fastled parts is still buggy so I'm not taking any chances and just changing all the every for regular nano

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