Arduino - ์•„๋‘์ด๋…ธ

Intro ์‚ฌ์šฉํ•˜๊ธฐ ์‰ฌ์šด ํ•˜๋“œ์›จ์–ด์™€ ์†Œํ”„ํŠธ์›จ์–ด๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•œ ์˜คํ”ˆ์†Œ์Šค ์ „์ž ํ”Œ๋žซํผ ์ดํƒˆ๋ฆฌ์•„ ๋งˆ์‹œ๋ชจ ๋ฐ˜์ง€(Massimo Banzi,๋Œ€ํ•™๊ต์ˆ˜)๊ฐ€ ๊ฐœ๋ฐœ ๋ฐ ๊ณต๊ฐœ ๋น„์ „๊ณต์ž๋ฅผ ์œ„ํ•œ ๊ฐœ๋ฐœ ๋ณด๋“œ ํ•˜๋“œ์›จ์–ด ์ข…๋ฅ˜ $ arduino-cli board listall Board Name FQBN Adafruit Circuit Playground arduino:avr:circuitplay32u4cat Arduino BT arduino:avr:bt Arduino Duemilanove or Diecimila arduino:avr:diecimila Arduino Esplora arduino:avr:esplora Arduino Ethernet arduino:avr:ethernet Arduino Fio arduino:avr:fio Arduino Gemma arduino:avr:gemma Arduino Industrial 101 arduino:avr:chiwawa Arduino Leonardo arduino:avr:leonardo Arduino Leonardo ETH arduino:avr:leonardoeth Arduino Mega ADK arduino:avr:megaADK Arduino Mega or Mega 2560 arduino:avr:mega Arduino Micro arduino:avr:micro Arduino Mini arduino:avr:mini Arduino NG or older arduino:avr:atmegang Arduino Nano arduino:avr:nano Arduino Pro or Pro Mini arduino:avr:pro Arduino Robot Control arduino:avr:robotControl Arduino Robot Motor arduino:avr:robotMotor Arduino Uno arduino:avr:uno Arduino Uno Mini arduino:avr:unomini Arduino Uno WiFi arduino:avr:unowifi Arduino Yรบn arduino:avr:yun Arduino Yรบn Mini arduino:avr:yunmini LilyPad Arduino arduino:avr:lilypad LilyPad Arduino USB arduino:avr:LilyPadUSB Linino One arduino:avr:one ์†Œํ”„ํŠธ์›จ์–ด ์„ค์น˜ arduino-ide - ์•„๋‘์ด๋…ธ ํ™ˆํŽ˜์ด์ง€์— OS๋ณ„๋กœ ๋‹ค์šด๋กœ๋“œ ๋ฐ ์„ค์น˜ ๊ฐ€๋Šฅ arduino cli - Command Line Interface (Linux, Win์šฉ) REFERENCE ์•„๋‘์ด๋…ธ - https://www.arduino.cc

2023-10-30 ยท (updated 2023-10-31) ยท 154 words

Arduino-cli - ์•„๋‘์ด๋…ธ ๋ช…๋ น๋ผ์ธ ์‚ฌ์šฉ

Intro arduino-cli๋Š” ์•„๋‘์ด๋…ธ IDE์˜ ๋ช…๋ น๋ผ์ธ ํˆด์ด๋‹ค. (์†Œํ”„ํŠธ์›จ์–ด ํˆด) Shell Script๋กœ ์—ฌ๋Ÿฌ ๋ฒˆ๊ฑฐ๋กœ์šด ์ž‘์—…์„ ์ž๋™ํ™” ํ•  ์ˆ˜ ์žˆ๋‹ค. nvim ์ด๋‚˜ vim์—์„œ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ๋Š” ํ™˜๊ฒฝ์— ์ ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. nvim์„ ์ค‘์‹ฌ์œผ๋กœ ์ฝ”๋“œ ์ž‘์„ฑ, ์ปดํŒŒ์ผ, ๋””๋ฒ„๊น…์„ ๋ชจ๋‘ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค. ์„ค์น˜ ๋ฐ ์‚ฌ์šฉํ™˜๊ฒฝ: windows, windows-wsl2-alpine, linux-ubuntu Intall: Windows reference: https://dumblebots.com/2020/08/02/arduino-cli-getting-started-windows/ ์œˆ๋„์šฐ์ฆˆ์šฉ arduino-cli.exe๋ฅผ ๋‹ค์šด๋ฐ›์•„ ์„ค์น˜, dos-shell ๋˜๋Š” powershell์—์„œ ๊ฒฝ๋กœ ์ถ”๊ฐ€ํ•˜๊ณ  ์‚ฌ์šฉ ์ด๋ฅผ ์œˆ๋„์šฐ์ฆˆ wsl2 ๊ธฐ๋ฐ˜์˜ ๋ฆฌ๋ˆ…์Šค์—์„œ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ /mnt/c/<์ดํ•˜๊ฒฝ๋กœ>๋กœ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•˜๋‹ค. PATH์— ์ถ”๊ฐ€. Install: Linux ์ผ๋ฐ˜์‚ฌ์šฉ์ž์˜ ๊ฒฝ์šฐ ~/bin์— ์„ค์น˜: PATH์— ์ถ”๊ฐ€ curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh Install: windows-wsl2-alpine reference: https://github.com/dorssel/usbipd-win/wiki/WSL-support ์•„๋‘์ด๋…ธ ์žฅ์น˜๋ฅผ USB์— ์—ฐ๊ฒฐํ•œ๋‹ค. wsl2-alpine - gcompat, usbip, hwdata ์„ค์น˜ gcompat์€ ardunino-cli๋กœ ์ปดํŒŒ์ผํ•  ๋•Œ ld-linux-x86-64.so.2 ์‚ฌ์šฉํ•˜๋Š”๋ฐ alpine์€ musl ๊ธฐ๋ฐ˜์ด๋ฏ€๋กœ ํ˜ธํ™˜ ์ง€์› ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ด์•ผ ํ•œ๋‹ค. usbip๋Š” usbipd์˜ ํด๋ผ์ด์–ธํŠธ ํŒจํ‚ค์ง€ hwdata๋Š” USB๋“ฑ์˜ ์žฅ์น˜ํŒŒ์ผ ardunino-cli ์‚ฌ์šฉ์ž ์„ค์น˜์‹œ์— USB์žฅ์น˜ ์†Œ์œ ๊ถŒ ๋ฌธ์ œ๊ฐ€ ์žˆ๋‹ค. ์žฅ์น˜ ์†Œ์œ ๊ถŒ์„ ํ•ด๋‹น ์‚ฌ์šฉ์ž๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค. windows - usbipd-win ์„ค์น˜ ๋ฐ ์„ค์ • usbipd๋Š” ์œˆ๋„์šฐ์ฆˆ์—์„œ wsl2 ๋“ฑ์— USB ์žฅ์น˜๋ฅผ ๊ณต์œ ํ•ด์ฃผ๋Š” ๋ฐ๋ชฌ ํ”„๋กœ๊ทธ๋žจ ๋ฐ˜๋“œ์‹œ ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์œผ๋กœ ์‹คํ–‰ํ•ด ์ฃผ์–ด์•ผํ•œ๋‹ค. ์•„๋‘์ด๋…ธ ์žฅ์น˜๋ฅผ wsl2์— ๋ถ™์—ฌ ์ฃผ์—ˆ์„ ๊ฒฝ์šฐ ์œˆ๋„์šฐ์—์„œ๋Š” ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค. ์ด ๋ฐ๋ชฌ์€ usbip ํด๋ผ์ด์–ธํŠธ์˜ ์š”์ฒญ์„ ํ†ตํ•ด USB์žฅ์น˜(์—ฌ๊ธฐ์—์„œ๋Š” ์•„๋‘์ด๋…ธ)๋ฅผ ๊ณต์œ  # WSL2-Alpine Linux: Pre-Package Install doas apk update doas apk add gcompat linux-tools-usbip hwdata # Windows-Powershell # ๊ด€๋ฆฌ์ž๊ถŒํ•œ์œผ๋กœ ์‹คํ–‰, ์œˆ๋„์šฐ์ฆˆ ์žฌ๋ถ€ํŒ…์‹œ ๋‹ค์‹œ ์„ค์ •ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค. # ์—ฐ๊ฒฐ์‹œ ์ž๋™ attach ๋ฐฉ๋ฒ•์„ ๋ชจ์ƒ‰ํ•  ํ•„์š”๊ฐ€ ์žˆ๋‹ค. # usbipd๋ฅผ ์„ค์น˜ํ•˜๊ณ  wsl list๋ฅผ ํ†ตํ•ด ์•„๋‘์ด๋…ธ์˜ busid๋ฅผ ํ™•์ธํ•˜๊ณ  ์ด๋ฅผ ์—ฐ๊ฒฐํ•˜๊ณ  ํ™•์ธ. winget usbipd usbipd wsl list usbipd wsl attach --busid=2-2 usbipd wsl list # WSL2-Alpine Linux: arduino-cli Install # usb ์ง€์›์—ฌ๋ถ€ ํ™•์ธ # ardunino-cli ์„ค์น˜ ๋ฐ ํŒจ์Šค ์„ค์ • # ์žฅ์น˜ ์†Œ์œ ๊ถŒ ํ˜„ ์‚ฌ์šฉ์ž๋กœ ๋ณ€๊ฒฝ lsusb curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh export PATH=$PATH:$HOME/bin arduino-cli board list doas chown -R <user_id>:<user_id> /dev/ttyACM0 arduino-cli --help Install: debian, ubuntu lsusb curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh export PATH=$PATH:$HOME/bin arduino-cli board list sudo chown -R <user_id>:<user_id> /dev/ttyACM0 arduino-cli --help ์‹œ์ž‘ํ•˜๊ธฐ reference: https://arduino.github.io/arduino-cli/0.35/getting-started/ ์•„๋ž˜๋Š” Ardunino UNO์˜ ๊ฒฝ์šฐ # ๋„์›€๋ง arduino-cli help arduino-cli help core # ์„ค์ • ํŒŒ์ผ ์ดˆ๊ธฐํ™” (~/.arduino15/arduino-cli.yaml) arduino-cli config init # ์žฅ์น˜์™€ ์—ฐ๊ฒฐํ•˜๊ธฐ (Arduino UNO) arduino-cli board list arduino-cli core update-index arduino-cli core install arduino:avr arduino-cli board listall mkr # list์˜ ๋ณด๋“œ๊ฐ€ Unknown์œผ๋กœ ๋‚˜์˜ฌ ๊ฒฝ์šฐ arduino-cli board list # ์†Œ์Šค ์ž‘์„ฑ (๋™์ผํ•œ ์Šค์ผ€์น˜ ์ด๋ฆ„์˜ ํด๋”์™€ ํŒŒ์ผ์ด ํ•„์š”) # ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•: arduino-cli sketch new myfirst && vim myfirst/myfirst.ino mkdir myfirst cat<<EOF > myfirst/myfirst.ino void setup() { pinMode(LED_BUILTIN, OUTPUT); } void loop() { digitalWrite(LED_BUILTIN, HIGH); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1000); } # ์ปดํŒŒ์ผ๊ณผ ์—…๋กœ๋“œํ•˜๊ธฐ (upload์‹œ ์ž๋™ ์ปดํŒŒ์ผ) # ์žฅ์น˜๋ช… ํ™•์ธ: ardunino-cli board list # ์ปดํŒŒ์ผ(-b) arduino-cli compile --fqbn arduino:avr:uno myfirst # ์—…๋กœ๋“œ (-u) arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:avr:uno myfirst # ์ปดํŒŒ์ผ(-b) & ์—…๋กœ๋“œ(-u) arduino-cli compile -p /dev/ttyACM0 -u arduino:avr:uno myfirst REFERENCE ardunino-cli ์„ค์น˜ ๋ฐ ์‹œ์ž‘ - https://arduino.github.io/arduino-cli/0.35/getting-started/ ์œˆ๋„์šฐ์ฆˆ ์„ค์น˜ ๋ฐ ์•ˆ๋‚ด - https://dumblebots.com/2020/08/02/arduino-cli-getting-started-windows/ wsl2์—์„œ usb์žฅ์น˜ ์—ฐ๊ฒฐ - https://github.com/dorssel/usbipd-win ardunino-cli linux install - https://m.blog.naver.com/roboholic84/221815428642

2023-10-30 ยท (updated 2023-10-31) ยท 437 words