-25-
v7.0
Code examples and extended information
11. Code examples and extended information
In the Waspmote Development section you can find complete examples:
http://www.libelium.com/development/waspmote/examples
/*
* ------ [RFID1356_03] RFID Bus Example --------
*
* Explanation: This sketch shows how Libelium’s RFID/NFC 13.56 can be
* used for ticketing solutions, in this case we use the RFID/NFC to
* simulate a RFID access control inside a bus.
* First, we assignate a quantity of money to the card (with a secret
* password of course). After that, each trip will substract the fare.
* This can be also used for a gym or a parking, for example.
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version: 0.1
* Design: David Gascon
* Implementation: Ahmad Saad, Javier Solobera
*/
#include <WaspRFID13.h>
// stores the status of the executed command:
uint8_t state;
// auxiliar buffer:
uint8_t aux[16];
// stores the UID (unique identifier) of a card:
uint8_t UID[4];
// stores the key or password:
uint8_t keyAccess[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
// EDIT: initial credit to put in the card (in cents!)
// it is also possible to put “credits”
int initialCredit = 800; // this is 8 euros (8*100 = 800)
//int initialCredit = 32000; // this is 320 euros (8*100 = 800)
// EDIT: the price per trip (in cents !)
// it is also possible to put 1 (if they are credits)
int tripFare = 105; // this is 1.05 euros (no problems with floats now)
boolean firstDone = false; // signal if the first credit write was done
int credit = 0; // stores the money inside the card
char text[16]; // for changing from one format to the other
boolean completed = false; // signals if all the process was successfuly completed