Genuino 101 を弄ってみた

2016.07.27

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

genuino101_000

車輪開発大好きおたいがです。こんにちは。( 挨拶 )

スイッチサイエンスさんで発売直後に購入したものの、4 ヶ月間ほど埃をかぶせていた Genuino 101 ( 以下 Genuino ) を開封して弄ってみました。

genuino101_001

外観・スペックなどは商品ページをご確認ください。

Genuino 101
https://www.switch-science.com/catalog/2670/

動作環境・道具など

  • Genuino 101
  • USB ケーブル
  • 3mm LED ( 2 本足 )
  • Windows 7 Pro (64bit)
  • Arduino IDE 1.6.9

Arduino IDE セットアップ

本記事執筆時点 ( 2016 年 7 月 26 日 ) では Arduino IDE 1.6.9 が最新版なので、こちらをダウンロードして利用しました。

Download the Arduino Software
https://www.arduino.cc/en/Main/Software

Arduino IDE 1.6.9 には Genuino 101 の設定ファイルが含まれていないため、手動で設定ファイル、および、デバイスのドライバを導入します。( ドライバの導入が必要なのは Windows のみ? )

Arduino IDE の [ツール] → [ボード:"***…"] → [ボードマネージャ] を選択して…

genuino101_002

[ボードマネージャ] 内 [タイプ] から [Arduino Certifide] を選択すると表示項目がフィルタリングされるので、[Arduino/Genuino 101] と書かれた項目にて、任意のバージョンを選択してインストールします。( 当記事では 1.0.6 を選択しました )

genuino101_003

Windows の場合、インストール中にドライバのインストール許可を求められるので、許可してインストールします。

Genuino と PC を USB ケーブルで接続すると、Genuino が認識されて COM ポート番号が割り振られる ( デバイスマネージャで確認できる ) ので、Arduino IDE の [ツール] → [シリアルボード] から、割り振られたポート番号を選択します。

genuino101_004

genuino101_005

以上でセットアップ完了です。

サンプルスケッチ ( プログラム ) の動作確認

Arduino IDE の [ファイル] → [スケッチの例] を選択すると、たくさんのサンプルスケッチを確認することができます。

特に [01.Basics] にあるサンプルは非常にシンプルなので、LED がひとつあれば、すぐに動作確認ができます。( [Blink] や [Fade] など )

サンプルスケッチを開いたら、Arduino IDE 左上にある [マイコンボードに書き込む] ボタンを押下すると、Genuino にスケッチが書き込まれ動作します。

genuino101_007

genuino101_006

Blink ( 単純な L チカ )

/*
  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
}

Fade ( フェードする L チカ )

/*
 Fade

 This example shows how to fade an LED on pin 9
 using the analogWrite() function.

 The analogWrite() function uses PWM, so if
 you want to change the pin you're using, be
 sure to use another PWM capable pin. On most
 Arduino, the PWM pins are identified with 
 a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.

 This example code is in the public domain.
 */

int led = 9;           // the PWM pin the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
  // declare pin 9 to be an output:
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // set the brightness of pin 9:
  analogWrite(led, brightness);

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ;
  }
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
}

参考

Curie搭載の開発ボード「Genuino 101」を試す - Arduino UnoやGalileoとの比較から性能を検証する
http://news.mynavi.jp/articles/2016/04/26/genuino/

第4回 Arduinoのスケッチ0プログラムを触ってみよう
http://deviceplus.jp/hobby/entry_004/

Arduino とスマホアプリ連携 #1 まずは Arduino で遊んでみる
https://dev.classmethod.jp/smartphone/arduino-1/

JavaScriptエンジニアへのIoTのすすめ:Node.jsとArduinoでスマートデバイスのプロトタイプをしてみよう
https://html5experts.jp/girlie_mac/17684/