Go Down

Topic: Error when include TFT library Arduino Uno (Read 973 times) previous topic - next topic

kriptonhaz

Hello,

I'm trying to display the result (some text) after I tap rfid card into my rfid module. I'm using Arduino Uno and IDE 1.6.4, and the 177 TFT Sensor Shield v3.

Before I include the TFT Library the code didn't shown any error, but when I just try to include and compile the TFT library (before using it in the actual program) it shown an error.


Code: [Select]

  //library rfid
  #include <Wire.h>
  #include <PN532_I2C.h>
  #include <PN532.h>
  #include <NfcAdapter.h>
 
  //library microsd
  #include <SPI.h>
  #include <SD.h>
  #include <TFT.h>  // Arduino LCD library and the problem start here

  // pin definition for the Uno
  #define sd_cs  4
  #define lcd_cs 10
  #define dc     9
  #define rst    8

  PN532_I2C pn532i2c(Wire);
  PN532 nfc(pn532i2c);
 
  File myFile;
  char buf[10];
  char aa[10]; 
 
  int ledHijau = 16;
  int ledMerah = 15;
  int buzzer = 17;
  int buzzervol = 50;
 
void setup(void) {
  //setup buzzer
  pinMode(buzzer, OUTPUT);
 
  //setup microsd
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
 
  //inisiasi led
  pinMode(ledHijau, OUTPUT);
  pinMode(ledMerah, OUTPUT);
 
  //inisiasi rfid
  Serial.begin(9600);
  Serial.println("Hello!");
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }
 
  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
 
  // Set the max number of retry attempts to read from a card
  // This prevents us from waiting forever for a card, which is
  // the default behaviour of the PN532.
  nfc.setPassiveActivationRetries(0xFF);
 
  // configure board to read RFID tags
  nfc.SAMConfig();
   
  Serial.println("Waiting for an ISO14443A card");
}

void loop(void) {
  boolean success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
  uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
 
  // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found
  // 'uid' will be populated with the UID, and uidLength will indicate
  // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
 
  if (success) {
    Serial.println("Found a card!");
    Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
    String uidString = "";
    for(byte i=0; i < 4; i++) {
      uidString += String(uid[i], HEX);
    }
    if(uidString.length() == 7)
    uidString += "0";
    uidString.toUpperCase();
    Serial.print(F("UID string: "));
    Serial.println(uidString);
   
    //cek di microsd
    myFile = SD.open("RFID.txt");
    if (myFile) {
      Serial.println("RFID.txt:");

      // read from the file until there's nothing else in it:
      while (myFile.available()) {
        //Serial.write(myFile.read());
     
        myFile.read(buf,10);       
        String rfid = uidString;
        rfid.toCharArray(aa, 10);
        if(strncmp(buf, aa, 8) == 0){
            Serial.println("Match!");
            analogWrite(buzzer, buzzervol);
            delay(100);
            analogWrite(buzzer, 0);
            digitalWrite(ledHijau, HIGH);
        } else{
            Serial.println("Didn't Match");
            analogWrite(buzzer, buzzervol);
            delay(100);
            analogWrite(buzzer, 0);
            delay(100);
            analogWrite(buzzer, buzzervol);
            delay(100);
            analogWrite(buzzer, 0);
            digitalWrite(ledMerah, HIGH);
        }
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening rfid.txt");
  }
   
    Serial.println("");
    // Wait 1 second before continuing
    delay(1000);
    digitalWrite(ledHijau, LOW);
    digitalWrite(ledMerah, LOW);
  }
  else
  {
    // PN532 probably timed out waiting for a card
    Serial.println("Timed out waiting for a card");
  }
}



here is the error that shown after compile

Code: [Select]

Arduino: 1.6.4 (Windows 8.1), Board: "Arduino Uno"

Using library Wire in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire

Using library PN532_I2C in folder: C:\Program Files (x86)\Arduino\libraries\PN532_I2C (legacy)

Using library PN532 in folder: C:\Program Files (x86)\Arduino\libraries\PN532 (legacy)

Using library NDEF in folder: C:\Program Files (x86)\Arduino\libraries\NDEF (legacy)

Using library SPI in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI

Using library SD in folder: C:\Program Files (x86)\Arduino\libraries\SD

Using library TFT in folder: C:\Program Files (x86)\Arduino\libraries\TFT



C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire -IC:\Program Files (x86)\Arduino\libraries\PN532_I2C -IC:\Program Files (x86)\Arduino\libraries\PN532 -IC:\Program Files (x86)\Arduino\libraries\NDEF -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI -IC:\Program Files (x86)\Arduino\libraries\SD\src -IC:\Program Files (x86)\Arduino\libraries\TFT\src C:\Users\haz\AppData\Local\Temp\build8117325719581809854.tmp\rfid_tftsd.cpp -o C:\Users\haz\AppData\Local\Temp\build8117325719581809854.tmp\rfid_tftsd.cpp.o

In file included from C:\Program Files (x86)\Arduino\libraries\TFT\src/TFT.h:6:0,
                 from rfid_tftsd.ino:23:
C:\Program Files (x86)\Arduino\libraries\TFT\src/utility/Adafruit_GFX.h: In static member function 'static PImage PImage::loadImage(const char*)':
C:\Program Files (x86)\Arduino\libraries\TFT\src/utility/Adafruit_GFX.h:318:37: error: no match for 'operator==' (operand types are 'File' and 'void*')
   if ((bmpFile = SD.open(fileName)) == NULL) {
                                     ^
Error compiling.


note:
The shield it self has a micro sd slot, and when I tried to use an example from TFT library called TFTBitmapLogo (using tft and sd at the same sketch), it work. But when using the code above it didn't work.

I appreciate any kind of help.
Thank you very much.

PaulS

Quote
I appreciate any kind of help.
Use two line of code. Really, you can, and it doesn't cost any more.

Code: [Select]
   bmpFile = SD.open(fileName);
   if (bmpFile == NULL)
  {

This way, you'll know EXACTLY which line is causing problems, and why.
The art of getting good answers lies in asking good questions.

kriptonhaz

thanks man I just realized that, and remove that part in the library and it do the work.
sorry for being silly, you are great help.
thanks  :)

Go Up