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 1 year has passed since last update.

MacとArduinoでC言語プログラミングするための準備

Last updated at Posted at 2020-09-22

「Arduino UNOをC言語で動かしたい!でもMACでどうやるのか分からない!」って悩んでたので、ネットで調べてみたら見つけました。

Homebrewをインストール後にターミナル上で、コマンドを順序よく実行すればいいです。

準備すること

Homebrewを正しくインストールする必要があります。

インストール方法

Homebrewを使って、avr-gccとavrdudeのインストール。これだけです。

$brew tap osx-cross/avr
$brew update
$brew install avr-gcc
$brew install avrdude

ビルドと書き込み方法

ここではmain.cというCのソースコードをtest.hexにビルドし、Arduinoが接続されたポート/dev/cu.usbmodem14101に書き込んでおります。コマンド内のファイル名は、適宜書き換えてください。

$avr-gcc -Os -Wall -mmcu=atmega328P main.c -o test.elf
$avr-objcopy -I elf32-avr -O ihex test.elf test.hex
$avrdude -c arduino -P /dev/cu.usbmodem14101 -b 115200 -p m328p -U flash:w:test.hex

参考

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?