2016年1月2日 星期六

[穿戴科技] Adafruit FLORA初接觸

Adafruit出一款大約美金20美元的穿戴科技模組,我們稱它為 FLORA,讓晶片相容於開放式硬體Adruino。
在網站https://www.adafruit.com/products/659有詳細的說明,FLORA體積很小和重量很輕,直徑1.75“,重量約4.4克。對FLORA系列而言,擁有配件包括:最好的不銹鋼線、感知器、GPS模塊和可鏈接的LED NeoPixels。2015年5月12日開賣的FLORA V2是採用micro-USB介面。




初學者的教材在https://learn.adafruit.com/getting-started-with-flora Arduino IDE版本至少要在 1.6
(含)以上。
軟體的安裝在https://learn.adafruit.com/adafruit-arduino-ide-setup/arduino-1-dot-6-x-ide。要在Arduino IDE中使用Adafruit FLORA,您必須在"檔案->偏好設定"功能選項,打開偏好設定的功能表,並在額外的板子管理員網址中輸入:https://adafruit.github.io/arduino-board-index/package_adafruit_index.json字串。
另外也要記得裝FLORA的驅動,可參考https://learn.adafruit.com/adafruit-arduino-ide-setup/windows-setup

接下來就可以打開Arduino IDE,選擇範例檔Blink。

其程式碼如下:

/*
  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://www.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(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

因為板子內建LED在D7,所以必須把上面範例中腳位13改成腳位7。

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(7, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(7, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(7, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

沒有留言:

張貼留言