INFO: Dieses Forum nutzt Cookies...
Cookies sind für den Betrieb des Forums unverzichtbar. Mit der Nutzung des Forums erklärst Du dich damit einverstanden, dass wir Cookies verwenden.

Es wird in jedem Fall ein Cookie gesetzt um diesen Hinweis nicht mehr zu erhalten. Desweiteren setzen wir Google Adsense und Google Analytics ein.

Antwort schreiben 
 
Themabewertung:
  • 0 Bewertungen - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Projekt Füllstation
05.03.2014, 11:44
Beitrag #1
Projekt Füllstation
Hallo zusammen,
In einem anderem Eintrag von mir habe ich zwa auch schon Fragen über mein Projekt gestellt, aber ich denke jetzt gehört es eigentlich in diese Kathegorie
also Ich bin neuerdings stolzer Besitzer eines Arduino Uno R3 und einem RFID RC522 dieses habe ich auch zum laufen gebracht und meine Karten ID und PICC Type ausgelesen. Mein Ziel ist es jedoch zwei 12v motoren nach Signal einer RFID Karte anzuschalten und nach einer gewissenzeit sollen diese automatisch ausschalten

also kompletter ablauf:

Karte vorhalten
erster Motor soll 1 Sekunde an sein
nach dem der erste Motor ausgeht soll der zweite Motor 2 sekunden ansein und wieder ausgehen.


das wäre in etwa dieser code, die Zeiten in dem code sind jedoch andere:

void setup()
{
initBoard();

while(true)
{
while(DigitalRead(D4))
{
for(unsigned int _i=0; _i<(unsigned int)(1); _i++)
{
DigitalWrite(D7, true);
delay(700);
DigitalWrite(D7, false);
delay(2000);
DigitalWrite(D8, true);
delay(1000);
DigitalWrite(D8, false);
}
}
}
}

void loop()
{
}


Ich habe auch versucht unter den fertigen Beispielen in der softwaire (Arduino 1.0.5) RFID/ReadandWrite den code zu zuverändern das es klappt aber da werde ich auch nicht so ganz schlau draus

#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.

void setup() {
Serial.begin(115200); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
//Serial.println("Scan a MIFARE Classic PICC to demonstrate Value Blocks.");
}

void loop() {

// Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
MFRC522::MIFARE_Key key;
for (byte i = 0; i < 6; i++) {
key.keyByte[i] = 0xFF;
}
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}

// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
// Now a card is selected. The UID and SAK is in mfrc522.uid.

// Dump UID
Serial.print("F5 0E FA E5");
for (byte i = 0; i < mfrc522.uid.size; i++) {
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
Serial.println();

// Dump PICC type
byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
Serial.print("MIFARE 1KB");
Serial.println(mfrc522.PICC_GetTypeName(piccType));
if ( piccType != MFRC522::PICC_TYPE_MIFARE_MINI
&& piccType != MFRC522::PICC_TYPE_MIFARE_1K
&& piccType != MFRC522::PICC_TYPE_MIFARE_1K) {
//Serial.println("This sample only works with MIFARE Classic cards.");
return;
}

// In this sample we use the second sector (ie block 4-7). the first sector is = 0
// scegliere settore di lettura da 0 = primo settore
byte sector = 1;
// block sector 0-3(sector0) 4-7(sector1) 8-11(sector2)
// blocchi di scrittura da 0-3(sector0) 4-7(sector1) 8-11(sector2)
byte valueBlockA = 4;
byte valueBlockB = 5;
byte valueBlockC = 6;
byte trailerBlock = 7;
byte status;
// Authenticate using key A.
// avvio l'autentificazione A
//Serial.println("Authenticating using key A...");
status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &key, &(mfrc522.uid));
if (status != MFRC522::STATUS_OK) {
Serial.print("PCD_Authenticate() failed: ");
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}
// Authenticate using key B.
// avvio l'autentificazione B
//Serial.println("Authenticating again using key B...");
status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_B, trailerBlock, &key, &(mfrc522.uid));
if (status != MFRC522::STATUS_OK) {
Serial.print("PCD_Authenticate() failed: ");
Serial.println(mfrc522.GetStatusCodeName(status));
return;
}

// Writing new value block A
// Scrivo i valori per il settore A
Serial.println("Writing new value block A(4) : the first of the sector TWO ");
byte value1Block[] = { 1,2,3,4, 5,6,7,8, 9,10,255,12, 13,14,15,16, valueBlockA,~valueBlockA,valueBlockA,~valueBlockA };
status = mfrc522.MIFARE_Write(valueBlockA, value1Block, 16);
if (status != MFRC522::STATUS_OK) {
Serial.print("MIFARE_Write() failed: ");
Serial.println(mfrc522.GetStatusCodeName(status));
}
/*

// Writing new value block B
// Scrivo i valori per il settore B
Serial.println("Writing new value block B");
byte value2Block[] = { 255,255,255,255, 0,0,0,0, 0,0,0,0, 255,255,255,255, valueBlockB,~valueBlockB,valueBlockB,~valueBlockB };
status = mfrc522.MIFARE_Write(valueBlockB, value2Block, 16);
if (status != MFRC522::STATUS_OK) {
Serial.print("MIFARE_Write() failed: ");
Serial.println(mfrc522.GetStatusCodeName(status));
}

// Writing new value block D
// Scrivo i valori per il settore C
Serial.println("Writing new value block C");
byte value3Block[] = { 255,255,255,255, 0,0,0,0, 0,0,0,0, 255,255,255,255, valueBlockC,~valueBlockC,valueBlockC,~valueBlockC };
status = mfrc522.MIFARE_Write(valueBlockC, value3Block, 16);
if (status != MFRC522::STATUS_OK) {
Serial.print("MIFARE_Write() failed: ");
Serial.println(mfrc522.GetStatusCodeName(status));
}

*/


Serial.println("Read block A(4) : the first of the sector TWO");
byte buffer[18];
byte size = sizeof(buffer);
// change this: valueBlockA , for read anather block
// cambiate valueBlockA per leggere un altro blocco
status = mfrc522.MIFARE_Read(valueBlockA, buffer, &size);
Serial.print("Settore : 0 Valore :");
Serial.println(buffer[0]);
Serial.print("Settore : 1 Valore :");
Serial.println(buffer[1]);
Serial.print("Settore : 2 Valore :");
Serial.println(buffer[2]);
Serial.print("Settore : 3 Valore :");
Serial.println(buffer[3]);
Serial.print("Settore : 4 Valore :");
Serial.println(buffer[4]);
Serial.print("Settore : 5 Valore :");
Serial.println(buffer[5]);
Serial.print("Settore : 6 Valore :");
Serial.println(buffer[6]);
Serial.print("Settore : 7 Valore :");
Serial.println(buffer[7]);
Serial.print("Settore : 8 Valore :");
Serial.println(buffer[8]);
Serial.print("Settore : 9 Valore :");
Serial.println(buffer[9]);
Serial.print("Settore :10 Valore :");
Serial.println(buffer[10]);
Serial.print("Settore :11 Valore :");
Serial.println(buffer[11]);
Serial.print("Settore :12 Valore :");
Serial.println(buffer[12]);
Serial.print("Settore :13 Valore :");
Serial.println(buffer[13]);
Serial.print("Settore :14 Valore :");
Serial.println(buffer[14]);
Serial.print("Settore :15 Valore :");
Serial.println(buffer[15]);



//byte value1Block[] = { 1,2,3,4, 5,6,7,8, 9,10,255,12, 13,14,15,16, valueBlockA,~valueBlockA,valueBlockA,~valueBlockA };
if (
buffer[0] == 1 &&
buffer[1] == 2 &&
buffer[2] == 3 &&
buffer[3] == 4 &&
buffer[4] == 5 &&
buffer[5] == 6 &&
buffer[6] == 7 &&
buffer[7] == 8 &&
buffer[8] == 9 &&
buffer[9] == 10 &&
buffer[10] == 255 &&
buffer[11] == 12 &&
buffer[12] == 13 &&
buffer[13] == 14 &&
buffer[14] == 15 &&
buffer[15] == 16
){

// sel a scrittura è uguale alla lettura allora e stato un successo !!
Serial.println("Read block A(4) : the first of the sector TWO : success");
Serial.println(":-)");

}else{

// scrittura Fallita
Serial.println("Read block A(4) : the first of the sector TWO : no match - write don't work fine ");
Serial.println(":-( ");

}


// risponde successo
//Serial.println(mfrc522.GetStatusCodeName(status));

// Dump the result
//mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector);

// Halt PICC
mfrc522.PICC_HaltA();

// Stop encryption on PCD
mfrc522.PCD_StopCrypto1();
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
06.03.2014, 20:54
Beitrag #2
RE: Projekt Füllstation
Hallo,

bitte mal nur den Code Posten der mit der Karte geht und bitte vor dem EInfügen und nach dem Einfügen oben das Rautesymbol im Chatfenster drücken.
Gruß
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
06.03.2014, 23:55
Beitrag #3
RE: Projekt Füllstation
Hey...
Ich habe leider nicht soviel erfahrung im Programmieren also habe ich zu erst im Programm DumpInfo geladen um meine Karten auszulesen, das hat auch soweit funktioniert.

AAAAA
Card UID: F5 0E FA E5
PICC type: MIFARE 1KB




BBBBB
Card UID: 2B 3C F7 84
PICC type: MIFARE 1KB


Danach habe ich Read and Write geladen und einwenig verändert...
Jetzt habe ich es geschaft 2 LED's in verschiedenen abständen zuschalten beim vorhalten einer Karte... es funktioniert allerdings bei JEDER Karte obwohl ich KEINE Karte dafür berechtigt habe... also nehme ich an das folgender Code fälliger Quatch ist, ich weiß leider auch nicht was ich alles aus diesem Code löschen muss... vieles Benötige ich ja auch garnet z.b. Anzeige im Serial Monitor.
Eigentlich nur 2 oder 3 verschiedene Karten für verschiedene Zeiten, aber Trotzdem sollen sie die selben Ausgängeschalten.

Code:
#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);        // Create MFRC522 instance.
int led = 8;              // motor 1
int led1 = 7;            // Motor 2


void setup() {
        Serial.begin(115200);        // Initialize serial communications with the PC
        SPI.begin();                // Init SPI bus
        mfrc522.PCD_Init();        // Init MFRC522 card
        //Serial.println("Scan a MIFARE Classic PICC to demonstrate Value Blocks.");
       pinMode(led, OUTPUT);    // motor1
       pinMode(led1, OUTPUT);     //motor 2
}

void loop() {
        
        // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
        MFRC522::MIFARE_Key key;
        for (byte i = 0; i < 6; i++) {
                key.keyByte[i] = 0xFF;
        }
        // Look for new cards
        if ( ! mfrc522.PICC_IsNewCardPresent()) {
                return;
        }

        // Select one of the cards
        if ( ! mfrc522.PICC_ReadCardSerial()) {
                return;
        }
        // Now a card is selected. The UID and SAK is in mfrc522.uid.
        
        // Dump UID
        Serial.print("Card UID:");
        for (byte i = 0; i < mfrc522.uid.size; i++) {
                Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
                Serial.print(mfrc522.uid.uidByte[i], HEX);
        }
        Serial.println();

        // Dump PICC type
        byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
        Serial.print("PICC type: ");
        Serial.println(mfrc522.PICC_GetTypeName(piccType));
        if (        piccType != MFRC522::PICC_TYPE_MIFARE_MINI
                &&        piccType != MFRC522::PICC_TYPE_MIFARE_1K
                &&        piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
                //Serial.println("This sample only works with MIFARE Classic cards.");
                return;
        }
              
        // In this sample we use the second sector (ie block 4-7). the first sector is = 0
        // scegliere settore di lettura da 0 = primo settore
        byte sector         = 1;
        // block sector 0-3(sector0) 4-7(sector1) 8-11(sector2)
        // blocchi di scrittura da 0-3(sector0) 4-7(sector1) 8-11(sector2)
        byte valueBlockA    = 4;
        byte valueBlockB    = 5;
        byte valueBlockC    = 6;
        byte trailerBlock   = 7;
        byte status;
        // Authenticate using key A.
        // avvio l'autentificazione A
        //Serial.println("Authenticating using key A...");
        status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &key, &(mfrc522.uid));
        if (status != MFRC522::STATUS_OK) {
                Serial.print("PCD_Authenticate() failed: ");
                Serial.println(mfrc522.GetStatusCodeName(status));
                return;
        }
        // Authenticate using key B.
        // avvio l'autentificazione B
        //Serial.println("Authenticating again using key B...");
        status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_B, trailerBlock, &key, &(mfrc522.uid));
        if (status != MFRC522::STATUS_OK) {
                Serial.print("PCD_Authenticate() failed: ");
                Serial.println(mfrc522.GetStatusCodeName(status));
                return;
        }
        
        // Writing new value block A
        // Scrivo i valori per il settore A
        Serial.println("Writing new value block A(4) : the first of the sector TWO ");
                byte value1Block[] = { 1,2,3,4,  5,6,7,8, 9,10,255,12,  13,14,15,16,   valueBlockA,~valueBlockA,valueBlockA,~valueBlockA };
                status = mfrc522.MIFARE_Write(valueBlockA, value1Block, 16);
                if (status != MFRC522::STATUS_OK) {
                        Serial.print("MIFARE_Write() failed: ");
                        Serial.println(mfrc522.GetStatusCodeName(status));
                }
        /*
        
        // Writing new value block B
        // Scrivo i valori per il settore B
        Serial.println("Writing new value block B");
                byte value2Block[] = { 255,255,255,255,  0,0,0,0, 0,0,0,0,  255,255,255,255,   valueBlockB,~valueBlockB,valueBlockB,~valueBlockB };
                status = mfrc522.MIFARE_Write(valueBlockB, value2Block, 16);
                if (status != MFRC522::STATUS_OK) {
                        Serial.print("MIFARE_Write() failed: ");
                        Serial.println(mfrc522.GetStatusCodeName(status));
                }
        
        // Writing new value block D
        // Scrivo i valori per il settore C
        Serial.println("Writing new value block C");
                byte value3Block[] = { 255,255,255,255,  0,0,0,0, 0,0,0,0,  255,255,255,255,   valueBlockC,~valueBlockC,valueBlockC,~valueBlockC };
                status = mfrc522.MIFARE_Write(valueBlockC, value3Block, 16);
                if (status != MFRC522::STATUS_OK) {
                        Serial.print("MIFARE_Write() failed: ");
                        Serial.println(mfrc522.GetStatusCodeName(status));
                }
                
        */
        
        
        Serial.println("Read block A(4) : the first of the sector TWO");        
        byte buffer[18];
        byte size = sizeof(buffer);
        // change this: valueBlockA , for read anather block
        // cambiate valueBlockA per leggere un altro blocco
        status = mfrc522.MIFARE_Read(valueBlockA, buffer, &size);
        Serial.print("Settore : 0 Valore :");
        Serial.println(buffer[0]);
        Serial.print("Settore : 1 Valore :");
        Serial.println(buffer[1]);
        Serial.print("Settore : 2 Valore :");
        Serial.println(buffer[2]);
        Serial.print("Settore : 3 Valore :");
        Serial.println(buffer[3]);
        Serial.print("Settore : 4 Valore :");
        Serial.println(buffer[4]);
        Serial.print("Settore : 5 Valore :");
        Serial.println(buffer[5]);
        Serial.print("Settore : 6 Valore :");
        Serial.println(buffer[6]);
        Serial.print("Settore : 7 Valore :");
        Serial.println(buffer[7]);
        Serial.print("Settore : 8 Valore :");
        Serial.println(buffer[8]);
        Serial.print("Settore : 9 Valore :");
        Serial.println(buffer[9]);
        Serial.print("Settore :10 Valore :");
        Serial.println(buffer[10]);
        Serial.print("Settore :11 Valore :");
        Serial.println(buffer[11]);
        Serial.print("Settore :12 Valore :");
        Serial.println(buffer[12]);
        Serial.print("Settore :13 Valore :");
        Serial.println(buffer[13]);
        Serial.print("Settore :14 Valore :");
        Serial.println(buffer[14]);
        Serial.print("Settore :15 Valore :");
        Serial.println(buffer[15]);
        
        
        
        //byte value1Block[] = { 1,2,3,4,  5,6,7,8, 9,10,255,12,  13,14,15,16,   valueBlockA,~valueBlockA,valueBlockA,~valueBlockA };
        if (
        buffer[0]  == 1   &&
        buffer[1]  == 2   &&
        buffer[2]  == 3   &&
        buffer[3]  == 4   &&
        buffer[4]  == 5   &&
        buffer[5]  == 6   &&
        buffer[6]  == 7   &&
        buffer[7]  == 8   &&
        buffer[8]  == 9   &&
        buffer[9]  == 10  &&
        buffer[10] == 255 &&
        buffer[11] == 12  &&
        buffer[12] == 13  &&
        buffer[13] == 14  &&
        buffer[14] == 15  &&
        buffer[15] == 16
        ){
        
        // sel a scrittura è uguale alla lettura allora e stato un successo !!  
        Serial.println("Read block A(4) : the first of the sector TWO : success");  
        Serial.println(":-)");  
        digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
        delay(1000);               // wait for a second
        digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
        delay(1000);  
        digitalWrite(led1, HIGH);   // turn the LED on (HIGH is the voltage level)
        delay(1000);               // wait for a second
        digitalWrite(led1, LOW);    // turn the LED off by making the voltage LOW
        delay(1000);  
        }else{
        
         //  scrittura Fallita
        Serial.println("Read block A(4) : the first of the sector TWO : no match - write don't work fine ");
        Serial.println(":-( ");  
        
        }
        
        
        // risponde successo
        //Serial.println(mfrc522.GetStatusCodeName(status));
        
        // Dump the result
        //mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector);
        
        // Halt PICC
        mfrc522.PICC_HaltA();

        // Stop encryption on PCD
        mfrc522.PCD_StopCrypto1();
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
Antwort schreiben 


Möglicherweise verwandte Themen...
Thema: Verfasser Antworten: Ansichten: Letzter Beitrag
  Roboter (Projekt) Beginner linux248 1 346 30.11.2016 12:06
Letzter Beitrag: Thie
  Arduino Projekt (Einkauf/Beratung) pekinese 2 221 21.11.2016 13:44
Letzter Beitrag: pekinese
Rainbow WB2812B Projekt CrazyHawk 18 1.496 22.07.2016 17:45
Letzter Beitrag: CrazyHawk
  Cam Slider Projekt, die ersten Schritte T8T 3 1.154 30.04.2016 16:26
Letzter Beitrag: SkobyMobil
  Projekt: Türsensor _Aviciii_ 9 2.437 05.04.2016 18:50
Letzter Beitrag: hotsystems
  Erstes Projekt Claus_M 8 1.971 08.01.2016 07:36
Letzter Beitrag: Claus_M
  NwT-Projekt Kursstufe1 Jonas Halbgewachs 6 2.294 26.10.2015 10:47
Letzter Beitrag: Binatone
  [Projekt] Reifeschrank Klimasteuerung sleipneer 116 17.767 18.10.2015 20:21
Letzter Beitrag: sleipneer
  Anfänger mit großem Bau Projekt (Useless Box 3.0) Wambo 7 4.144 02.10.2015 16:36
Letzter Beitrag: Klaus(i)
  Ardunio Anfänger mit vielen Fragen zu einem Design Projekt (mit Bildern) farbexot 0 1.534 01.08.2015 13:03
Letzter Beitrag: farbexot

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste