0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

コマンドラインから Arduino のプロジェクト作成とアップロードを行う ( Arduino-cli )

Last updated at Posted at 2021-02-13

コマンドラインから Arduino のプロジェクト作成とアップロードを行います。

うまくすれば、github に上がっているものをそのまま流し込むとかできるようになるかと思います。

動作環境

項目 設定値
ボード Arudino nano
ブートローダ old bootloader

Arudino nano ( old bootloader ) 向けのコマンドラインでのスケッチアップロードです。

ターミナルにコピペでいけるかと思います。

install-arduino-cli.sh
#!/usr/bin/bash

# bash install-arduino-cli.sh ;

# arduino-cli install
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh ;
echo export PATH='$HOME/bin:$PATH' >> ~/.bashrc ; # 環境変数の追加
source .bashrc ; # 環境変数の有効化
arduino-cli ; # 動作確認

# board update
arduino-cli core update-index ;
arduino-cli core install arduino:avr ;
arduino-cli board listall ;
arduino-cli board list ;

# create project
arduino-cli sketch new MyFirstSketch ;
HOGE=$(cat<<TEXT
void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(100);
    digitalWrite(LED_BUILTIN, LOW);
    delay(100);
}
TEXT
) ;
echo "$HOGE" > MyFirstSketch/MyFirstSketch.ino ;

# compile and update
arduino-cli compile --fqbn arduino:avr:nano MyFirstSketch/MyFirstSketch.ino ;
arduino-cli upload -p /dev/ttyUSB0 -b arduino:avr:nano:cpu=atmega328old MyFirstSketch ; # sudo chmod 777 /dev/ttyUSB0 :-)
# arduino-cli upload -p /dev/ttyUSB0 -b arduino:avr:uno MyFirstSketch ; # sudo chmod 777 /dev/ttyUSB0 :-)

###参考リンク

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?