までできたのに。。
Web Compilerでまったくビルドが進まないことがあることが判明
(他の方も利用されていて動作おそくなるのか?)
20分経てもビルドできないことがある(笑)
つらい。。
----
----
IDE for GR E0.4.1 どうしても使いたくて、いろいろやっていたら動くようになった。
(むしろInitialzing Faledが再現できなくなった(原因不明))
とりあえず使えるようになった!!
さっそく、Lチカ(HelloKurumi)やって、、OK
SDカードのファイル作成, 読み書きもできた。
「HelloKurumi」 , SDの「ReadWrite」は、[ ファイル ] → [ スケッチの例] とすると
例文のテンプレートが表示される。あとは、それを自分の目的に合わせて
変更するだけでOK!
「ReadWrite」をアレンジして「my_ReadWrite」としてスケッチ(ソースのこと)を
作成した(ほぼ、例と変わらない)。
---
/*
SD card read/write
This example shows how to read and write data to and from an SD card file
The circuit:
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4
created Nov 2010
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
*/
#include <SD.h>
File myFile;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// or the SD library functions will not work.
pinMode(10, OUTPUT);
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
Serial.print("open...... my_test.txt");
myFile = SD.open("my_test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to my_test.txt...");
myFile.println("testing.....abc abc");
// close the file:
myFile.close();
Serial.println("close_okay");
} else {
// if the file didn't open, print an error:
Serial.println("error opening & writing my_test.txt");
}
// re-open the file for reading:
myFile = SD.open("my_test.txt");
if (myFile) {
Serial.println("my_test.txt open \r\n");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening my_test.txt");
}
}
void loop()
{
// nothing happens after setup
}
---
動作確認もOKでした。
動作概要は、
ファイルオープンでmy_test.txt というファイルが無ければ作り、あれば追記する(ここは、自動みたい)。
myFile.println(" ")で書き込みたい文字を記入しておく。
ファイルクローズ
また、ファイルオープン
Serial.write(myFile.read()); でmy_test.txtの内容を全てシリアル(COM 1とか)に出力する。
ファイルクローズ
です(ほぼ、例文に「my_」を記入したのみですが....! )。
-――
ピンの接続
<KURUMI> <SDカード>
MOSI pin 11 --- DI pin 2
MISO pin 12 --- DO pin 7
CLK pin 13 --- SCLK pin 5
CS pin 4 --- CS pin 1
+3.3V --- 3.3V pin 4
GND --- GND1 pin 3
GND --- GND2 pin 6
SDカードは、一番でかいサイズ(端子が全9ピン)のものを使った場合のピン番号。
(miniSD や uSDとはピンの順番が異なる)
SD(SDHC)カードは、VCCの電圧範囲が2.7~3.6Vなので、KURUMIが3.3Vだと
線をつなぐのみでOK!
-――
Arduinoをするために今までに体験したものでは、
1 :e2studio + kurumi_sketch_v104_e2studio.zip いろいろ設定しないといけないようで、結局書きこみまでできなかった。
2 :Web compiler 重いときがある....
3 :IDE for GR E0.4.1 いい感じ。