ทำตามลิงค์ www.youtube.com/watch?v=jVPf_JFUQdo ทุกอย่างครับ
โหลดไลบารีมาแล้วก็อบไปวางที่file adrduino /Library
จากนั้นก็ก๊อบโค๊ดที่ใช้งาน Arduino Data log ger Shield ดัดแปลงใช้กับ Arduino mega
แต่คอมไพล์ไม่ผ่าน
มันเตือนว่า
Arduino: 1.5.8 (Windows 7), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
sketch_jun03a.ino: In function 'void setup()':
sketch_jun03a.ino:28:31: error: no matching function for call to 'SDClass::begin(int, int, int, int)'
sketch_jun03a.ino:28:31: note: candidate is:
In file included from sketch_jun03a.ino:5:0:
C:\Users\Administrator\Documents\Arduino\libraries\SD\src/SD.h:68:11: note: boolean SDClass::begin(uint8_t)
boolean begin(uint8_t csPin = SD_CHIP_SELECT_PIN);
^
C:\Users\Administrator\Documents\Arduino\libraries\SD\src/SD.h:68:11: note: candidate expects 1 argument, 4 provided
Error compiling.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
มีวิธีแก้ไขได้อย่างไรบ้างครับ
ลองเช็คไลบารี sd card ครับ ตามตัวอย่างเป็นของ Arduino IDE เวอร์ชัน 1.0.5 ครับ เวอร์ชัน 1.5.8 อาจมีการเปลี่ยนแปลง
ผมลองโหลด Arduino IDE เวอร์ชัน 1.0.5 มาลองใช้ดุแล้วครับ แต่ก็ยังเป็นเหมือนเดิม
เตือนว่า
sketch_jun03a.ino: In function 'void setup()':
sketch_jun03a:28: error: no matching function for call to 'SDClass::begin(int, int, int, int)'
C:\Program Files (x86)\Arduino\libraries\SD/SD.h:69: note: candidates are: boolean SDClass::begin(uint8_t)
ยังคอมไพล์ไม่ผ่าน ติดไลบารี sd card ลองหาไลบารี sd card ตัวอื่นมาลองครับ
The circuit:
* SD card attached to SPI bus as follows:
** Mega: MOSI - pin 51, MISO - pin 50, CLK - pin 52, CS - pin 4 (CS pin can be changed)
and pin #52 (SS) must be an output
อยากทราบว่า MOSI - pin 51, MISO - pin 50, CLK - pin 52, ไปใส่ตรงไหนของโค๊ตครับ??
#include <SPI.h>
#include <SD.h>
// On the Ethernet Shield, CS is pin 4. Note that even if it's not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
const int chipSelect = 4;
File dataFile;
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...");
// make sure that the default chip select pin is set to
// output, even if you don't use it:
pinMode(SS, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
while (1) ;
}
Serial.println("card initialized.");
// Open up the file we're going to log to!
dataFile = SD.open("datalog.txt", FILE_WRITE);
if (! dataFile) {
Serial.println("error opening datalog.txt");
// Wait forever since we cant write data
while (1) ;
}
}
void loop()
{
// make a string for assembling the data to log:
String dataString = "";
// read three sensors and append to the string:
for (int analogPin = 0; analogPin < 3; analogPin++) {
int sensor = analogRead(analogPin);
dataString += String(sensor);
if (analogPin < 2) {
dataString += ",";
}
}
dataFile.println(dataString);
// print to the serial port too:
Serial.println(dataString);
// The following line will 'save' the file to the SD card after every
// line of data - this will use more power and slow down how much data
// you can read but it's safer!
// If you want to speed up the system, remove the call to flush() and it
// will save the file only every 512 bytes - every time a sector on the
// SD card is filled with data.
dataFile.flush();
// Take 1 measurement every 500 milliseconds
delay(500);
}
เปลี่ยนเป็น50,51,52,53แล้วยังerrorคับ
คอมไพล์ผ่านมั้ยครับ ผมลองโคดตาม #4 คอมไพล์ผ่าน
ถ้าคอมไพล์ไม่ผ่าน ลองเช็คไลบารี/เช็คว่าเลือกบอร์ดถูกแล้ว อีกครั้งครับ
ผมเปลี่ยนconst int chipSelect = 53;
คอมไพล์ผ่านคับ แต่SD Card ไม่บันทึก เป็นไฟล์ text.Text
ผมต้องเปลี่ยนโค๊ตตรงไหนคับ
ต่อตามนี้ http://www.arduinoall.com/b/16
Shield ขาจะฟิกตำแหน่งไว้แล้วนะครับ
คอมไพล์ผ่านแล้วครับ พอเปิดไฟล์ Text มา ดันไม่มีข้อมูลคับ
จะแก้ไขอย่างไรดีครับ