Arduino: Difference between revisions
Appearance
NickPGSmith (talk | contribs) |
NickPGSmith (talk | contribs) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 18: | Line 18: | ||
* [https://docs.arduino.cc/language-reference/ Arduino Language Reference] | * [https://docs.arduino.cc/language-reference/ Arduino Language Reference] | ||
* [https://docs.arduino.cc/learn/programming/memory-guide/ Arduino Memory Guide] | |||
== Useful Libraries == | == Useful Libraries == | ||
Line 47: | Line 48: | ||
* [https://docs.arduino.cc/hardware/nano/ Arduino Nano] | * [https://docs.arduino.cc/hardware/nano/ Arduino Nano] | ||
** ATmega328PB (Micro USB) (16 MHz) | ** ATmega328PB (Micro USB) (16 MHz) | ||
** [https://docs.platformio.org/en/latest/boards/atmelavr/nanoatmega328.html PlatformIO] | *** [https://docs.platformio.org/en/latest/boards/atmelavr/nanoatmega328.html PlatformIO] | ||
** ATmega328PB (USBC) (16 MHz) | ** ATmega328PB (USBC) (16 MHz) | ||
** [https://docs.platformio.org/en/latest/boards/atmelavr/nanoatmega328new.html PlatformIO] | *** [https://docs.platformio.org/en/latest/boards/atmelavr/nanoatmega328new.html PlatformIO] | ||
See: [https://wolles-elektronikkiste.de/en/atmega328pb-based-boards 328PB additions]. | See: [https://wolles-elektronikkiste.de/en/atmega328pb-based-boards 328PB additions]. | ||
Line 68: | Line 69: | ||
=== Platformio.ini === | === Platformio.ini === | ||
Common additions: | |||
lib_deps = fastled/FastLED@^3.10.3 | |||
monitor_speed = 115200 | |||
upload_port = COM3 |
Latest revision as of 08:15, 6 October 2025
General
Startup & Programming
On reset or powerup, ehe Optiboot or other bootloader code is run. If an external reset was the cause, listening mode is entered, and the LED is flashed. Programming commands in STK500 protocol are listened for, of the serial line at 115200 speed. If none are received in a small timeout window (~ 1s), the normal code is executed.
The DTR line if used to trigger a reset pulse in software IDE (see here).
millis()
- Useful for timing without using a blocking delay()
- Returns ms in an unsigned long
- Test for 1s (subtraction correctly handles truncation/rollover):
- millis() - lastCounter > 1000
- https://arduino.stackexchange.com/questions/12587/how-can-i-handle-the-millis-rollover/12588#12588
Documentation
Useful Libraries
- FastLED for WS2812B programmable LED strips
- FreeRTOS
- LibPrintf
- LiquidCrystal_PCF8574 derived from Liquid Crystal
- OneButton
- Pin Change Interrupt
- TinyGPS
Hardware
- Arduino Duemilanove
- ATmega328 (16 MHz)
- PlatformIO
- Arduino Uno R3
- ATmega328P (16 MHz)
- PlatformIO
- SparkFun Pro Micro
- ATMEGA32U4 (16 MHz)
- PlatformIO
- Direct USB -> can appear as mouse/keyboard
- Arduino Nano
- ATmega328PB (Micro USB) (16 MHz)
- ATmega328PB (USBC) (16 MHz)
See: 328PB additions.
Development Environment
- Visual Studio Code, install Platform.io IDE extension
- Extension icon -> New Project
- include - header files
- lib - libraries
- src - C++ source files
- platformio.ini
- See small icons at bottom for Home, Build, Upload, Serial Monitor
- SHIFT-ALT-F to format document
Platformio.ini
Common additions:
lib_deps = fastled/FastLED@^3.10.3 monitor_speed = 115200 upload_port = COM3