Arduino
Jump to navigation
Jump to search
Install arduino-cli
from https://arduino.github.io/arduino-cli/0.35/installation/
and https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Linux_64bit.tar.gz
arduino-cli config init
Board setup
this example is for an arduino mega board
arduino-cli core update-index arduino-cli board list arduino-cli core install arduino:avr
Create a test project
arduino-cli sketch new ArduinoTest cat > ArduinoTest/ArduinoTest.ino << EOF void setup() { pinMode(LED_BUILTIN, OUTPUT); } void loop() { digitalWrite(LED_BUILTIN, HIGH); delay(100); digitalWrite(LED_BUILTIN, LOW); delay(100); EOF
Build and deploy
Note, you need to belong to the dialout group (or have raw access to /dev/ttyACM0)
arduino-cli compile --fqbn arduino:avr:mega ArduinoTest arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:avr:mega ArduinoTest
Use a makefile
PROJECT_NAME := ArduinoTest ARDUINO_BOARD := arduino:avr:mega ARDUINO_DEVICE := /dev/ttyACM0 SERIAL_RATE := 9600 .PHONY: all all: build .PHONY: check_group check_group: @id -G -n | grep -qw dialout || (echo "ERROR: You need to belong to dialout group (use 'usermod -aG dialout <USERNAME>')" && exit 1) .PHONY: build build: arduino-cli compile --fqbn $(ARDUINO_BOARD) $(PROJECT_NAME) .PHONY: deploy deploy: check_group arduino-cli upload -p $(ARDUINO_DEVICE) --fqbn $(ARDUINO_BOARD) $(PROJECT_NAME) .PHONY: logs logs: stty -F $(ARDUINO_DEVICE) raw 9600 cat $(ARDUINO_DEVICE)