Pages: [1]   Go Down
Author Topic: Re: Serial.read() in HEX, XOR und andere Fragen  (Read 357 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ich habe auch ein wenig Probleme mit einem Code.. Obwohl ich NewSoftSerial.h im gleichen Ordner habe wie der Code.


Der Code

Code:
#include <NewSoftSerial.h>

#define ADD_TAG_CODE "210014DFE309"  //change this ID with your own card TAG
#define DEL_TAG_CODE "210014E2BD6A"

NewSoftSerial RFID(2, 3);
String msg;
String ID ;  //string to store allowed cards

void setup() 
{
  Serial.begin(9600);
  Serial.println("Serial Ready");

  RFID.begin(9600);
  Serial.println("RFID Ready");
}

char c;

void loop(){
 
  while(RFID.available()>0){
    c=RFID.read();
    msg += c;
    //Serial.println(msg);  //Uncomment to view your tag ID
    //Serial.println(msg.length());
  }
  msg=msg.substring(1,13);
  if(msg.indexOf(ADD_TAG_CODE)>=0) add();
  else if(msg.indexOf(DEL_TAG_CODE)>=0) del(); 
  else if(msg.length()>10) verifica();
  msg="";
 
}

void add(){
  Serial.print("What TAG do you wanna grant access?: ");
  msg="";
  while(msg.length()<13){
    while(RFID.available()>0){
      c=RFID.read();
      msg += c;
    }
  }
  if(ID.indexOf(msg)>=0) {
    Serial.println("\nAccess already granted for this card.");
    msg="";
  }
  else{
    Serial.print("Card: ");
    Serial.println(msg);
    ID += msg;
    ID += ",";
    //Serial.print("ID: ");
   // Serial.println(ID);
    msg="";
    Serial.println("Access granted for this card.");
  }

}

void del(){
  msg="";
  Serial.print("What TAG do you wanna deny access?: ");
  while(msg.length()<13){
    while(RFID.available()>0){
      c=RFID.read();
      msg += c;
    }
  }
  msg=msg.substring(1,13);
  if(ID.indexOf(msg)>=0){
    Serial.println(msg);
    Serial.println("TAG found. Access for this card denied.");
    //ID.replace(card,"");
    int pos=ID.indexOf(msg);
    msg="";
    msg += ID.substring(0,pos);
    msg += ID.substring(pos+15,ID.length());
    ID="";
    ID += msg;
    //Serial.print("ID: ");
    //Serial.println(ID);
  } else Serial.println("\nTAG not found or already denied");
  msg="";
}

void verifica(){
    msg=msg.substring(1,13);
    if(ID.indexOf(msg)>=0) Serial.println("Access granted.");
    else Serial.println("Access denied.");
}


Fehler

Quote
rfid:5: error: 'NewSoftSerial' does not name a type
rfid.cpp: In function 'void setup()':
rfid:14: error: 'RFID' was not declared in this scope
rfid.cpp: In function 'void loop()':
rfid:22: error: 'RFID' was not declared in this scope
rfid.cpp: In function 'void add()':
rfid:40: error: 'RFID' was not declared in this scope
rfid.cpp: In function 'void del()':
rfid:66: error: 'RFID' was not declared in this scope

Was mach ich den falsch?


lg
karabey
Logged

Germany
Offline Offline
Faraday Member
**
Karma: 49
Posts: 2749
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Das hat jetzt nicht viel mit dem Original-Problem zu tun. Du darfst gerne auch einen neuen Thread aufmachen ...

Quote
Obwohl ich NewSoftSerial.h im gleichen Ordner habe wie der Code
Am sichersten packst du Libraries dahin, wo auch die Standard - Libraries sind, zwischen EEPROM und Wire.
Dann funktioniert auch die "Import Library" Funktion

Ausserdem sollte
#include "myLibrary.h"
und
#include <myLibrary.h>
einen kleinen Unterschied machen, zumindest in der Reihenfolge der dursuchten Verzeichnisse.
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 96
Posts: 4739
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Am sichersten packst du Libraries dahin, wo auch die Standard - Libraries sind, zwischen EEPROM und Wire.

Der beste Ort wäre aber das "libraries"-Verzeichnis in Deinem sketchbook-Ordner, dann bleiben sie nämlich erhalten, auch wenn Du die IDE updatest.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ich habe schon das ganze erneut gepackt aber die Fehler sind weiters vorhanden.

Hab inzwischen ein neues Thread aufgemacht
http://arduino.cc/forum/index.php/topic,130364.msg980634.html#msg980634
Logged

Pages: [1]   Go Up
Jump to: