아두이노나 마이크로비트에서 go 를 쓰기위해서 윈도우에 tinygo 환경을 셋팅해보겠습니다.
1. 설치
scoop 를 이용하는게 가장 편합니다.
scoop 설치!
https://scoop.sh/
scoop.sh
윈도우 파워셀에서
> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser # Optional: Needed to run a remote script the first time
> irm get.scoop.sh | iex
끄읏
go 와 tiny go 를 설치 합니다.
https://tinygo.org/getting-started/install/windows/
Windows
Windows install guide
tinygo.org
> scoop install go
> scoop install tinygo
설치 확인!
나중을 위해 avr 환경 설치도 해둡니다.
> scoop install avr-gcc
> scoop install avrdude
추가로 vscode 를 쓸테니 tinygo 플러그인 을 설치합니다.
https://marketplace.visualstudio.com/items?itemName=tinygo.vscode-tinygo
TinyGo - Visual Studio Marketplace
Extension for Visual Studio Code - TinyGo support for Visual Studio Code
marketplace.visualstudio.com
혹시 마이크로 비트 컴파일 하는거면 참조 사항들
블링크 예제
https://github.com/tinygo-org/tinygo/blob/v0.24.0/src/examples/microbit-blink/microbit-blink.go
GitHub - tinygo-org/tinygo: Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Bas
Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM. - GitHub - tinygo-org/tinygo: Go compiler for small places. Microcontrollers, WebAsse...
github.com
vscode 에서 machine 패키지가 빨간줄 나오니 컨트롤+쉬프트+p 로 tiny go 환경의 타겟패키지를 지정해주면 사라집니다.
그리고 컴파일 및 플래싱
tinygo flash -target=microbit-v2 [프로그래밍명]
잘되면 마이크로 비트의 첫번째 LED 가 깜빡입니다.