2014年12月21日日曜日

Stellaris LaunchPad で Energia を使ってみる。Stellaris LaunchPad with Energia.

以前、Stellaris LaunchPadのLチカをしてみましたが、Macだと、IAR EWARMが使えません。
ネットで調べてみると、Energiaと言う物が使えるらしいので、早速試してみます。
なんか、Arduinoっぽく、簡単に書けるみたいです。
I programed Stellaris LaunchPad before. But, IAR EWARM can't be used in Mac.
I searched for a web and i found a Energia. It's like a Arduino.


1.Download the Energia
   http://energia.nu/Guide_StellarisLaunchPad.html  のDownloadを押します。
   Press the button "Downlord" of http://energia.nu/Guide_StellarisLaunchPad.html .
OS X用dmgファイルをクリックします。


ファイルを保存をクリック。
Click the button "Save files".

ええっ?失敗しました?
Oh, was this failed?


気を取り直して、もう一度。今度はうまく行きました。
Try again.It's OK this time.

2.Install the Energia
dmgファイルをダブルクリックして解凍し、出来上がったアプリケーションをApplicationsフォルダにドラッグします。
An application is made, when dmg file is double-clicked.And drag it icon to application folder.

アプリケーションを起動すると、以下のダイアログが出ますので、開く。を押します。
When application is started, the following dialogue is indicated.A open button is pressed.

3.Run the Energia
ありゃりゃ。Arduinoと同じ画面じゃないですか?しかも最初から日本語化されてます。
でも、CPUがmsp430になってます。
Wow. The same screen as Arduino! Moreover it's Japanese localization.
But,CPU is MSP430.

ツール -> マイコンボード -> Stellarisを選びます。
You select TOOLS , Microcomputer board, and Stellaris.

4.An allocation of IO of the Stellaris on the Energia
さて、IOの割当はどうなっているでしょうか?
の写真を見ると、
PF_1     RED LED
PF_2     BLUE LED
PF_3     GREEN LED
となっています。まずは、これをLチカしてみましょう。
I investigated allocation of IO.The picture existed http://energia.nu/Guide_StellarisLaunchPad.html.
The onboard LED'S allocation is,
PF_1     RED LED
PF_2     BLUE LED
PF_3     GREEN LED
I turned on these LEDs.

5.Programing and run of blinking the LEDs.
以下のスケッチを書き込み、LaunchPadをUSBに差し込んで、書き込みボタンを押します。
You write in the following program.After connecting launchPAD to Mac, a Write button is pressed.


int i; // counter
void setup()
{
   // put your setup code here, to run once:
   pinMode(PF_1, OUTPUT); // RED LED
   pinMode(PF_2, OUTPUT); // BLUE LED
   pinMode(PF_3, OUTPUT); // GREEN LED
   Serial.begin(115200);  // Setup serial port
   i=0;
}
void loop()
{
   // put your main code here, to run repeatedly:
   digitalWrite(PF_1,HIGH); // Red
   delay(10);
   digitalWrite(PF_1,LOW);
   delay(10);
   digitalWrite(PF_2,HIGH); // Blue
   delay(10);
   digitalWrite(PF_2,LOW);
   delay(10);
   digitalWrite(PF_3,HIGH); // Green
   delay(10);
   digitalWrite(PF_3,LOW);
   delay(10);
   i++;
   Serial.print( int (millis()));  // Print system time ms
   Serial.print( "," );            // ,
   Serial.println(i);            // Print counter.
}



うわっ。簡単に動きました。ここまで、マニュアルも見ないで1時間弱で完了です。
念願のシリアルモニタも使えます。
Oh,That moved easily.I didn't read a manual.I'm working for only about 1 hour.
A serial monitor can use it, too.


簡単でしょ。
It's easy, isn't it?
Evernote はあなたがすべてを記憶し、手間をかけずに整理できるようにお手伝いします。Evernote をダウンロードする

2014年12月14日日曜日

8pino(Trinket)でデバッグするには? How to debugging for 8pino(trinket)

8pinoでは、シリアルモニターが使えません。シリアルモニターはデバッグするのにとても
大事な機能です。
せめて、大昔のマイコンボードの様に7SEGで内部データを16進表示させる事が出来れば
何とかなります。
手元にあった、7SEG表示器1個とHC4040バイナリカウンタで内部データを表示できる様
にしてみました。
8pino(Trinket) does not have a Serial port connection for debugging. 
Serial port monitor is the function important to do debugging.
An 7SEG LED display attached to an old microcomputer board. 
It indicated the inner data. 
I have one 7SEG LED and HC4040 binary counter. 
I made an 7SEG display using those.

HC4040はバイナリの12bitカウンタで、CLK入力の立ち下がりでカウント、RES入力の
立ち上がりでカウンタをリセットします。
これを使って7SEGLEDを点灯させるアイデアは大昔からあると思うので割愛します。例えば、
HC4040 is 12bit binary counter. It have CLK(clock) input and RESET input.
The idea that LED drive using it existed in that from the past. For example...

このプログラムは、アナログ入力1に取り付けた可変抵抗器の値(0〜3.3V、数値は0〜1023)
を16進にして、7SEGLEDに表示します。
但し一桁しか無いので、一桁ずつ、ゆっくりと表示させます。
例えば、可変抵抗器を最大にした時は1023=0x03FFとなりますので、
0 3 3 F - - - - 
と表示されます。- - - - と言うのは、データの区切りを示しています。
This program is display an analog input ch1 encoding hex data.  
It's indicated each one digit slowly.
For example in case of maximum voltage, it's indicate as follows,
0 3 3 F - - - - 
"- - - -" is data delimiter.

これを使えば、"少しは" デバッグが楽になります。
When this is used, debugging becomes easy. 
(Very little)



// 8pino 7segment drive test /w MC14040BCP
// Analogdata display
//
// [回路図 Circuit diagram]
// [8Pino]      [4040]         [LA-301VL]
// GPIO(1) ---> CLK
// GPIO(0) ---> CLR
//              Q0     -470R-> SEG a
//              Q1     -470R-> SEG b
//              Q2     -470R-> SEG c
//              Q3     -470R-> SEG d
//              Q4     -470R-> SEG e
//              Q5     -470R-> SEG f
//              Q6     -470R-> SEG g
// A/D(1)  ---> Triimer register
//
// バイナリカウンタを使った7セグメントLEDの駆動実験
// 指定のパルスを出す事により、各セグメントをスタティック点灯させる。
// 例えば、"1" を点灯させるには、SEG b と SEG c を点灯させる為に、2+4=6回パルス発生する。
// パルスを送る前に、CLRをHにしてカウンタをクリアしておく事。 
// A 7segment LED drive test with binaly counter.
// Drive on each segment at static state with several pulse signal.
// For example,When you'd like display a "1", you turn on SEG b and SEG c.
// Before sending a data pulse, you send a pulse to CLR.
// Define bacic binaly data
#define seg_A 1    //0000 0001
#define seg_B 2    //0000 0010
#define seg_C 4    //0000 0100
#define seg_D 8    //0000 1000
#define seg_E 16   //0001 0000
#define seg_F 32   //0010 0000
#define seg_G 64   //0100 0000
// Define 7 segment charactor
#define CHR_0 seg_A + seg_B + seg_C + seg_D + seg_E + seg_F + 0
#define CHR_1         seg_B + seg_C
#define CHR_2 seg_A + seg_B         + seg_D + seg_E         + seg_G
#define CHR_3 seg_A + seg_B + seg_C + seg_D                 + seg_G
#define CHR_4         seg_B + seg_C                 + seg_F + seg_G
#define CHR_5 seg_A         + seg_C + seg_D         + seg_F + seg_G
#define CHR_6 seg_A         + seg_C + seg_D + seg_E + seg_F + seg_G
#define CHR_7 seg_A + seg_B + seg_C
#define CHR_8 seg_A + seg_B + seg_C + seg_D + seg_E + seg_F + seg_G
#define CHR_9 seg_A + seg_B + seg_C                 + seg_F + seg_G
#define CHR_A seg_A + seg_B + seg_C         + seg_E + seg_F + seg_G
#define CHR_B                 seg_C + seg_D + seg_E + seg_F + seg_G
#define CHR_C seg_A                 + seg_D + seg_E + seg_F
#define CHR_D         seg_B + seg_C + seg_D + seg_E         + seg_G
#define CHR_E seg_A                 + seg_D + seg_E + seg_F + seg_G
#define CHR_F seg_A                         + seg_E + seg_F + seg_G
#define CHR_BAR seg_G
// Variable settings
int led = 1;  // On board LED (pin 1)
int vol = 1;  // Analog input 1(pin 2)
unsigned int vol_num;  // Analog value
int cnt;      // Counter
int res = 0;  // reset = #0
int value;    // output value
int max_value;
// Character dimensions
int CHR[] = {CHR_0,CHR_1,CHR_2,CHR_3,CHR_4,CHR_5,CHR_6,CHR_7,CHR_8,CHR_9,CHR_A,CHR_B,CHR_C,CHR_D,CHR_E,CHR_F,CHR_BAR};
int i;
// GPIO direction
void setup() {
   pinMode(led, OUTPUT); //4040 CLK pin(/w onboard LED)
   pinMode(res, OUTPUT); //4040 CLR pin
   //pinMode(vol, INPUT); // An analog input is default.
}
// 7segment drive
// 引数:キャラクタ配列の順番(0=0,1=1,2=2,....F=15,...)
// 戻り:なし
// 動作: 1)CLRパルスを出す。
//       2)キャラクタ配列の数値を取り出し、その回数のCLKパルスを出す。
//       3)500ms表示する。
// Arg:Number of character dimension.
// Ret:non
// Function:1)Send CLR pulse.
//          2)Read number of character dimension, and send pulse.
//          3)Display character between 500ms.
void disp_7seg( int disp_num){
   int max;                      //Quantity of the pulse
   max = CHR[disp_num];          //Set Q'ty of the pulse
   digitalWrite(res,HIGH);       //CLR on pulse
   delayMicroseconds(3);         //CLR on pulse time.
   digitalWrite(res,LOW);        //CLR off
   delayMicroseconds(3);         //CLR off time.
   delay(200);                   //Time of the turn off the light.
   for (cnt=0;cnt < max;cnt++){  //Loop on max times.
     digitalWrite(led,HIGH);     //Pulse on
     delayMicroseconds(3);       //Pulse on time.
     digitalWrite(led,LOW);      //Pulse off
     delayMicroseconds(3);       //Pulse off time.
   }
   delay(300);                   //Time of the display charactor.
}
// Divide data to 4 figure
// Arg:hex_data
// Ret:4th digit number
unsigned int dec2hex_4(unsigned int num){
   unsigned int result;
   result = num/0x1000;
   return result;
}
// Arg:hex_data
// Ret:3rd digit number
unsigned int dec2hex_3(unsigned int num){
   unsigned int result;
   result = (num-dec2hex_4(num)*0x1000)/0x100;
   return result;
}
// Arg:hex_data
// Ret:2nd digit number
unsigned int dec2hex_2(unsigned int num){
   unsigned int result;
   result = (num-dec2hex_4(num)*0x1000-dec2hex_3(num)*0x100)/0x10;
   return result;
}
// Arg:hex_data
// Ret:1st digit number
unsigned int dec2hex_1(unsigned int num){
   unsigned int result;
   result = num-dec2hex_4(num)*0x1000-dec2hex_3(num)*0x100-dec2hex_2(num)*0x10;
   return result;
}
// 7Segment Display 4 digit number.
// Arg:hex_data
// Ret:non
void seg_Display(unsigned int num){
   disp_7seg(dec2hex_4(num));        // Display 4th char.
   disp_7seg(dec2hex_3(num));        // Display 3rd char.
   disp_7seg(dec2hex_2(num));        // Display 2nd char.
   disp_7seg(dec2hex_1(num));        // Display 1st char.
   disp_7seg(16);       // Display ---
   disp_7seg(16);       // Display ---
   disp_7seg(16);       // Display ---
   disp_7seg(16);       // Display ---
}
void loop() {
// The 4 character display demonstration.
   vol_num = analogRead(1);    // Trrimer volume read.
   seg_Display(vol_num);        // Display 4 degit
   delay(1000);               // Wait
}

Evernote はあなたがすべてを記憶し、手間をかけずに整理できるようにお手伝いします。Evernote をダウンロードする

2014年12月7日日曜日

8pinoではtone()関数は使えない。The tone library does not work for the 8pino(Trinket).


8pino(Trinket)では、toneライブラリが使えません。
スケッチでtone()を使ってもコンパイルエラーは出ませんが、動作しません。
下記に、代替えのbeep()関数がありましたので、早速実験してみました。

The tone library does not work for the 8pino(Trinket).
If you compile the scketch in used tone library, it won't be an error.
A way of substitution existed in the following site.


このbeep()はdelayMicroseconds()を使って、かなり正確なbeepを実現していますが、deleyMicroseconds()の最大値が16383usなので、30Hz以下の周波数を出す事が出来ません。
そこで、60Hz以下の時はdelay()関数(ms単位)のタイマーを使う様に改造してみました。

This beep() used delayMicroseconds().This is correct timing.
But it's possible to use delayMicroseconds() only up to 16383us.
I edited a program to output less than 30 Hz of signal.

1Hzから1023Hzまで割と正確に出す事が出来ます。
It can output a correct signal from 1Hz to 1023Hz.

1Hz

1023Hz



// TONE TEST
// ボリュームに応じてTONE信号(1〜1023Hz)を出力 Make tone signal(1 to 1023Hz) with analog volume.
// 8pinoでは、TONE()が使えません。The tone library does not work for the 8pino(Trinket).

int led = 1;  // On board LED (pin 1)
int vol = 1;  // Analog input 1(pin 2)
int vol_num;  // Analog value

void setup() {
  pinMode(led, OUTPUT);
  //pinMode(vol, INPUT); //Default pin mode is analog input.
}

void loop() {
  vol_num = analogRead(vol);     //Read analog data (0 to 1024)
  if (vol_num == 0) {            // if f=0Hz then 
    vol_num = 1;                 //   f=1Hz
  };
  if(vol_num > 60){              //  if f>60Hz then
    beep(led,vol_num,1000);      //    use delayMicroseconds()
  }else{                         //  else
    beep_ms(led,vol_num,1000);   //    use delay()
  }
}

void beep (unsigned char speakerPin, int frequencyInHertz, long timeInMilliseconds)
  int x;    
  long delayAmount = (long)(500000/frequencyInHertz);   // Original is 1000000
  long loopTime = (long)((timeInMilliseconds*1000)/(delayAmount*2));
  for (x=0;x<loopTime;x++)    
  {    
  digitalWrite(speakerPin,HIGH);
  delayMicroseconds(delayAmount);
  digitalWrite(speakerPin,LOW);
  delayMicroseconds(delayAmount);
  }    
}

void beep_ms (unsigned char speakerPin, int frequencyInHertz, long timeInMilliseconds)
  int x;    
  long delayAmount = (long)(500/frequencyInHertz);   // Original is 1000000
  long loopTime = (long)((timeInMilliseconds)/(delayAmount*2));
  for (x=0;x<loopTime;x++)    
  {    
  digitalWrite(speakerPin,HIGH);
  delay(delayAmount);
  digitalWrite(speakerPin,LOW);
  delay(delayAmount);
  }    
}




Evernote はあなたがすべてを記憶し、手間をかけずに整理できるようにお手伝いします。Evernote をダウンロードする

2014年11月30日日曜日

20141123 Maker Faire Tokyo 2014

今年も行って参りました。メイカーフェアー。
去年は会場がとっても狭かったけど、今年はビッグサイトで開催です!
I went to Maker Faire Tokyo 2014.
It was very small space there last year. 
But it's held at a wide exhibition hall this year.


ちょっと早めに着いてしまいました。二時間前なのに、既に30人ほど並んでいます。でも、開場は12:00からなので、豆腐フェアで腹ごしらえをします。
I have arrived early. About 30 people were waiting already.
Opening is from 12:00. I went on a TOFU show to see first.

とうふマンがお出迎えです。
I greeted a TOFU man.

開場に戻ってみると、1時間前なのに凄い事になってるぞ。
あとで分かったのですが、Intelのエジソン目当ての人がかなり前から並んでいたそうです。
One hour before of opening,a lot of people visited.
Intel distributed Edison board without charge for a few people.

12:00に開場。まだ、人が歩けるスペースがありますが、これが午後になると、すし詰め状態になります。
I entered at 12:00.One after another, a visitor were increasing.

見る物がいっぱいあって、一日じゃ見きれません。しかも人がどんどん増えて来るので、説明を聞くのも、横に移動するのもどんどん大変になっていきます。
There was much one which takes an interest there.There are a lot of people,and it's difficult to hear the explanation.

これはフリーフォール体感マシン。この時は、マシン不調で動かず。
This is a virtual free fall machine. There was trouble in this machine.

これは、学生達の手作りパラレルリンクロボット。
パラレルリンクの動きはどこから流用したのではなく、自分たちで方程式を解いて作ったそうです。この先に半田ごてを付けて、氷を溶かして3D形状を作る予定との事。
This is parallel link robot made by students.
The formula of robot was solved by students.
They's plan is create of a ice 3D printer .

14:00からDale Dougherty氏の講演。
  • 僕たちは、自分のかゆい所を掻いているだけ。(それをシェアしてるだけ)
  • 実際に体を動かして勉強する。
  • 人生、それ自体が問題解決である。
  • これからの子供達がメーカーになる事を望む。
  • 作る事 イコール 教育。

Lecture of Mr. Dale Dougherty.
  • Scratch your own itch.
  • learn from real experience.
  • All life is problem solving.
  • Every child a maker.
  • Make = Learning


成層圏の風船から見た地球
The earth seen from stratosphere.

AgICによるインクジェット印刷の回路パターン。
これでハンダ付けできれば、最高なんだけど。
The circuit printed by Ag ink.
I hope that soldering with this ink.


ヘラクレス型テルミン。初めてテルミンを弾きました。
The Herakles type TERUMIN. I played TERUMIN for the first time.

ラズパイのビデオ出力をVHFに変換して昔のブラウン管テレビに昔の番組を映す。文章で表すと、ふーん。って感じなんだけど、なぜか実物を見ると感動する。
The old type Television showed old TV program by Raspbery Pi.

リレーによる計算機。
このブースでは、昔の計算機は本当にこんな音をしていた。と凄いコアな話で盛り上がっていた。私も十分におじさんなんだが、改めて驚き!
An electronics calculator made with magnet really.

ガルバノスキャナーによるレーザープロジェクター。米国製のスキャナなら意外と安く購入できるらしい。
An laser projector made with garbano scanner mirror.

クラウドファンディングによる、空飛ぶ自動車開発プロジェクト。
2020年の東京オリンピックの聖火台に火をつけたい。と開発中。頑張って!
project of the flying car.
It's expected to light Olympic cauldron of Tokyo Olympic Games in 2020. 

コアラのマーチを振り続けると丸くなると言う事らしい。
The shake machine of COARA's MARCH.

簡易型XYプロッタ。
Easy XY plotter.

R2D2おじさん
Homemade R2D2.

ピョコピョコ。
去年の物より格段にスムーズに動いてました。さすが。
The Pyoko Pyoko. This year's machine was working smoothly than last year's it.

観葉植物と水自体を静電センサとして、人が近づいた事を感知する。
かわゆいので、女の子にうけてました。
An Capacitive sensor using a plant.

ルンバロボット。
ルンバはAPIを公開しているので、無改造でハッキング出来るそうです。
A communication protocol of RUNBA isn't a secret.It's easy to hacking.

そして、閉場時間が過ぎても中々帰らない人達+自分。
When it was closure time, people have not returned yet. And i.

今年もとっても楽しい時間を過ごす事が出来ました。
I spent very fun time.

Evernote はあなたがすべてを記憶し、手間をかけずに整理できるようにお手伝いします。Evernote をダウンロードする

8pinoの詳細 Details of 8Pino.

8pinoの詳細について調べてみました。
Arduino超初心者なので、かなり的外れな解説になっている可能性大です。
I collected information on 8pino.
I use Arduino for the 1st time.
So, There is a possibility that this information is wrong.

1.Compatible with Adafruit Trinket
 Adafruitというのは、米国の電子部品通販業者で、日本では秋月みたいなとこなんでしょう。
 Trinketというのは、その会社が去年発売したとっても小さなArduino互換基板です。
 そして、この8pinoは、日本のVITROというユニットが作った、Trinketとほぼ同じ回路でありながらサイズを更に小さくしたものです。
 従って、ソフトウエアやつながる周辺回路はTrinketとコンパチブルになる訳です。
Adafruit is electronic component mail-order traders in US. 
It is a company like AKIZUKI-TSUSHO in Japan.
Trinket is sold from Adafruit from last year. It's a very small compatible Arduino board.  
And, This 8pino is made of VITRO in Japan.It's a more small compatible Trinket board.
Then, 8pino can use software and hardware of Trinket.


2.Function of Trinket
 Trinketの大まかな機能を見てみましょう。詳しい事は、Trinketのページを見てください。
  • 電源電圧は3.3V。8MHz。8KのフラッシュROM
  • I/Oは5ピン。2つはUSBポートとシェア。3ポートは独立。1アナログ入力と2PWM出力。2つのシェアポートもアナログ入力とPMW出力に使う事も出来る。
  • だけど、シリアルポートモニター機能は有していない。
  • USB3.0ポートでは動かないらしい。
  • 電源の赤LEDと#1ポートの緑LED(8pinoは白色)
  • リセットボタン付き(8pinoは未実装)
  • I2C/SPIにも対応。
  • 取り付け穴付き!イエー!(8pinoは無し)
  • ほんとに小ちゃい(8pinoはもっと小さい)

The function of Trinket is as follows. See Trinket's web site.
  • ATtiny85 on-board, 8K of flash, 512 byte of SRAM, 512 bytes of EEPROM
  • 5 GPIO - 2 shared with the USB interface. The 3 independent IO pins have 1 analog input and 2 PWM output as well. The 2 shared IO pins have 2 more analog inputs and one more PWM output.
  • Trinket does not have a Serial port connection for debugging so the serial port monitor will not be able to send/receive data.
  • Some computers' USB v3 ports don't recognize the Trinket's bootloader. Simply use a USB v2 port or a USB hub in between.
  • On-board green power LED and red pin #1 LED (8pino had two white LED.)
  • Reset button for entering the bootloader or restarting the program. No need to unplug/replug the board every time you want to reset or update!
  • Hardware I2C / SPI capability for breakout & sensor interfacing.
  • Mounting holes! Yeah! (8pino does not have it.)
  • Really really small(8pino is more small.)

3.Detail of Trinket (and 8pino)

さて、Trinket(8pino)の詳細を見ていきましょう。
あくまでArduino互換として動くので、ATTiny85のCPU機能を全て使えるわけではありません。例えば、#5リセットピンはアセンブラを使えば汎用ポートになるはずですが、Arduninoとして使う場合は、リセットピンとして固定されています。(と思います。)
The detail of Trinket(8pino) are as follows.
Trinket(8pino) is Arduino compatible. Therefore the function of ATTiny85 can't be used completely.
For example Port5 is fixed on RESET function ,probably.



Item/port
機能
Function
Power LED
電源(VCC=3.3V)に接続されています。
Connected to VCC(3.3V)
LED
ポート1(#1)に接続されています。
Connected to #1
#0 PWM0/MOSI/SDA
GPIO 0
PWMポート0 
MOSI(マスターアウト,スレーブイン) 
SDA(シリアルデータ)
GPIO 0
PWM port 0 
MOSI(Master out Slave in) 
SDA(Serial Data)
#1 PWM1/MISO/LED
GPIO 1
PWMポート1
MISO(マスターイン、スレーブアウト)
白色LED
GPIO 1
PWM port 2
MISO(Master in Slave out)
White LED
#2 A1/SCK/SCL
GPIO 2
アナログ入力1
SCK(シリアルクロック)
SCL(シリアルクロック)
GPIO 2
Analog input 1
SCK(Serial Clock)
SCL(Serial Clock)
#3 USB/A3
GPIO 3
アナログ入力3
GPIO 3
Analog input 3
#4 PWM4/USB/A2
GPIO 4
PWMポート4
USBポート
アナログ入力2
GPIO 4
PWM port 4
USB port
Analog input 2
#5 Reset
リセット
Reset

4.Relation with Arduino functions.
各機能と主なArduino命令との対応を見てみます。
まだ実機で確認したわけではありませんので,多分間違いがあります。
特に、PWM、toneなどタイマーを使う物は併用ができなかったり、使用するポートが限られているはずです。
Each function and the relation with the Arduino functions are as follows.
But, I'm not testing it's functions. Therefore there is a possibility thet the following information is wrong.
For example the function using the timer shouldn't function at the same time. 

関数 Functions
機能
Action
pinMode(pin,mode)
GPIO(#0〜4)の入出力、プルアップ抵抗のモードを決定します。
Select for input/output in GPIO port.

digitalWrite(pin,value)
GPIO(#0〜4)に出力
Output a value to the GPIO port.
digitalRead(pin)
GPIO(#0〜4)から入力
Input a value for the GPIO port.
analogRead(pin)
A1〜A3からアナログ電圧を入力
Input a analog voltage for the Analog port.
analogWrite(pin,value)
PWM0,1,4からPWM波形を出力
Output PWM wave to PWM port.
tone(pin,frequency)
トーン信号(矩形波)を出力
Output square wave output GPIO port.
pulseIn(pin,value,timeout)
パルス幅を計測します。
Measurement of pulse width.
SPI.xxx
SPI(シリアルペリフェラルインターフェース)関係の関数郡です。
SPI's functions.
Wire.xxx
I2C(アイスクエアシーバス)関係の関数群です。
I2C's functions.



Evernote はあなたがすべてを記憶し、手間をかけずに整理できるようにお手伝いします。Evernote をダウンロードする

2014年11月24日月曜日

初めての8pino. My first 8PINO with Mac

Maker Faire TOKYO 20148pinoを買ってきました。
8pinoはもちろん、Arduinoも初めてです。
今から動かしてみます。うまく動いてくれるかな?
I bought "8pino" in Maker Faire TOKYO 2014.
I do the test run it.

1.About 8pino
 8pinoは小ちゃなArduino互換品です。
 CPUはアトメルのATTiny85です。
   そればっかじゃありませんでした。この製品グッドデザイン賞を受賞しているじゃないですか!凄い!
 8pino is small Arduino compatible CPU board.
 CPU is ATMEL ATTiny .
 And,This product was awarded the Good Design Award 2014.
  It's amazing. 
 
 大きさはこのくらいです。:)
 The size is very small like the following photograph. 
 マイクロUSBにはこんな感じで差し込みます。
 It connect with a micro USB cable like the following photograph. 

2.Download IDE.
 以下のサイトからTrinket用のIDEをダウンロードし、ダブルクリックして解凍します。
 解凍されたアプリケーションをアプリケーションフォルダに移動します。
 Downlord IDE from the following sites and unzipped.
 Move unzipped application to application folder.

3.Install Java SE 6 runtime.
アプリケションフォルダーに移動したAdafruit Arduino 1.0.5 をクリックして起動すると、以下のダイアログが表示されますのでインストールを押します。
When launching IDE ,this dialog displayed.
Then, please push INSTALL button.
OKを押します。
And, push OK button.
4.Release of security
 Adafruit Arduino 1.0.5を起動すると、セキュリティの関係で開けない事があります。
 When launching IDE ,this dialog displayed. 
 システム環境設定 -> セキュリティとプライバシー で設定をします。
 Please choose System -> Security and Privacy.
 
 鍵のロックを外し、全てのアプリケーションを許可にチェックを入れます。
 Unlock the key icon ,then check "All application permission" button.

 全てのアプリケーションを許可を押します。
 Click "All application permission".



5.Run the IDE
 再び、IDEを起動します。新しいスケッチが立ち上がります。
 このスケッチというのは、要するにプログラムの事です。
 Run the IDE.The new sketch window are opened.
 The SKETCH meaning program code.


プログラム(スケッチ)を書く前に設定をします。
ツール -> マイコンボード -> Adafruit Trinket 8MHzを選択します。
Before you write program code you must be setting the tools.
Choose menu bar from Tools,CPU board,and Adafruit Trinket 8MHz.

 続いて、
 ツール -> 書込装置 -> USBtinyISPを選択します。
 Next,choose menu bar from tools,Writer,and USBtinyISP.

Lチカをするにはプログラム(スケッチと言うのがまだなじめない)が必要です。
http://8pino.cc/ にLチカプログラムがありました。
このプログラムをコピーして、IDEのスケッチエリアに貼付けます。
When you want to blink LED you must write the sketch.
Copy the program from this site. http://8pino.cc/
Paste the program to sketch's area.

6.Blinking the LED
 いよいよLチカです。
 USBケーブルをMacに繋いで、"マイコンボードに書き込む"ボタンを押します。
 Connect the USB cable to MAC.
 Next,click the "Write the CPU board".
  
  あれ?エラーだ。
 The error occured.Could not find USBTiny device.

 USBケーブルを刺し直しても、別のエラーが発生。初期不良か?
 when I reconnect the cable,other errer occured.

エラーの原因はUSBケーブルの差し込むタイミングでした。

USBケーブルを差し込んだ直後に、書き込みを行えば正常に動作しました。
Cause of the error is a timing to connect the cable.
Please press the upload button immediately after inserting the cable.

Lチカ
Blinking LED.

うーん。これはいい。10個ぐらい買って、何か作りたくなってきた。
Arduinoは開発が手軽でいいですね。 
This is very good product.I would like to make something using this.
And, Arduino is easy for programing.

Evernote はあなたがすべてを記憶し、手間をかけずに整理できるようにお手伝いします。Evernote をダウンロードする