Beginner question: cannot make Blink work on Arduino Nano

Hi!
I’m very new to this, so a very very basic question: I am trying to get the Blink scetch to work on an Arduino Nano.
I am following the Dronebot video in detail: Getting Started with PlatformIO - YouTube

I can compile and run the code with the Arduion IDE but when copying the code into Platform IO, it compiles, seems to upload, but no blink.

In Arduino IDE I set the board to ATmega328P (old bootloader) and in Platform IO to atmega328 (that comes up when I type arduino nano in the board chooser).

Any ideas what is wrong here? What am I missing?

Magnus

Please show full platformio.ini, code and output of the ‘Upload’ project task.

You also sure you that you have switched to the project you want if you’ve created multiple ones? (project environment switcher).

Hi!

Here’s the platform.ini code:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; ... (deleted to be able to reply)

[env:nanoatmega328]
platform = atmelavr
board = nanoatmega328
framework = arduino

Here’s the output from “Upload”:

> Executing task in folder blink: platformio run --target upload <

Processing nanoatmega328 (platform: atmelavr; board: nanoatmega328; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/nanoatmega328.html
PLATFORM: Atmel AVR (3.3.0) > Arduino Nano ATmega328
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 30KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES: 
 - framework-arduino-avr 5.1.0 
 - tool-avrdude 1.60300.200527 (6.3.0) 
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> ... (deleted to be able to reply)
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio/build/nanoatmega328/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.4% (used 9 bytes from 2048 bytes)
Flash: [          ]   1.4% (used 444 bytes from 30720 bytes)
Configuring upload protocol...
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port...

Warning! Please install `99-platformio-udev.rules`. 
More details: ... (deleted to be able to reply)

Auto-detected: /dev/ttyUSB0
Uploading .pio/build/nanoatmega328/firmware.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file ".pio/build/nanoatmega328/firmware.hex"
avrdude: writing flash (444 bytes):

Writing | ################################################## | 100% 0.15s

avrdude: 444 bytes of flash written
avrdude: verifying flash memory against .pio/build/nanoatmega328/firmware.hex:
avrdude: load data flash data from input file .pio/build/nanoatmega328/firmware.hex:
avrdude: input file .pio/build/nanoatmega328/firmware.hex contains 444 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.11s

avrdude: verifying ...
avrdude: 444 bytes of flash verified

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

As for switching: as I am totally new, I am not really sure what you mean. I have the code I want to upload in the window, and below that click the compile and upload icons. Did I miss something there?

Magnus

Ah… now it works. I found the Project Environment Switcher, however, upon chaning project environment, clikcing the “run” icon only brought up a chooser. So I closed the program and restarted, and now it works!

Thanks!

Magnus

1 Like

And what is the code?

And the file the code is in the src/main.cpp file of the project, yes? It can’t just be in a new unsaved file.

Also, you only need project environment switching if you have multiple projects open, aka. multiple workspace folders.

Here you can see in the upper left corner that I have a billion projects in my workspace, and to work on a specific project, I need to use the project environment switcher in the blue taskbar to select it (generic-lora-node). And of course the code I want to upload must be in a file in src/ of that project.

Thanks! Yes, src/main.cpp

It’s slowly getting clearer! Feels a bit steep learning curve, so thanks a lot for your help!!

Magnus