我們的最終目標是想要拿 android 跟 arduino 溝通,今天簡單介紹如何建立 arduino 的開發環境
我們需要準備:
sudo apt-get update && sudo apt-get install arduino arduino-core
7. 開啟 IDE , 到上方 Tools> Board > 選擇你的板子名稱
8. 到 Tools > Serial Port 中選擇COM port , 現在主機板多數沒有 com port , 所以你應該會看到唯一的一個 port , 如果有2個以上,就試著選號碼比較大的,因為是新安裝的,系統會指派比較後面的號碼。
9. 到這邊大致上是完成了,要怎測試到底能不能動呢?
10. 可以選 File > Example > 1.Basic > Blink , 他會開啟一個簡單的範例
11. 我們稍微修改一下如下:
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
Most Arduinos have an on-board LED you can control. On the Uno and
Leonardo, it is attached to digital pin 13. If you're unsure what
pin the on-board LED is connected to on your Arduino model, check
the documentation at http://arduino.cc
This example code is in the public domain.
modified 8 May 2014
by Scott Fitzgerald
*/
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5000); // wait for 5 second , 我改了這邊的數值為 5 秒鐘
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(5000); // wait for 5 second ,
}
我們明天見