Documente Academic
Documente Profesional
Documente Cultură
* ----------------------------------------------------------------------------
* This is NOT a MFRC522 library example; see https://github.com/miguelbalboa/rfid
* for (further?) details and other examples.
*
* NOTE: The library file MFRC522.h has a lot of useful info. Please read it.
*
* ----------------------------------------------------------------------------
*
* BEWARE: Data will be written to the PICC, in sector #1 (blocks #4 to #7). // number sector can be
changed from 1 to 15
* // WARNING: Sector #0 is
reserved for READ ONLY purposes
*
* Typical pin layout used:
* ---------------------------------------------------------------------------------------------------------
----------
* MFRC522 Arduino Arduino Arduino Arduino Arduino Arduino
* Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro Due
* Signal Pin Pin Pin Pin Pin Pin Pin
* ---------------------------------------------------------------------------------------------------------
----------
* RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 12
* SPI SS SDA(SS) 10 53 D10 10 10 13
* SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 MOSI (SPI)
* SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 MISO (SPI)
* SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 SCK (SPI)
*
* All modifications to example program (included in 'rfid-master' library)
* "C:\Program Files (x86)\Arduino\libraries\rfid-master\examples\ReadAndWrite\ReadAndWrite.ino"
* were done by Eduardo Alanis Vzquez (juecito_@hotmail.com)
* November 20, 2017
*
*/
#include <SPI.h> // Download from Github: https://github.com/PaulStoffregen/SPI/blob/master/SPI.h
#include <MFRC522.h> // Download from Github: https://github.com/miguelbalboa/rfid
constexpr uint8_t RST_PIN = 48; // Configurable, see typical pin layout above
constexpr uint8_t SS_PIN = 53; // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
MFRC522::MIFARE_Key key;
byte sector = 1;
byte blockAddr = 5;
byte writeBlock[16] = {0x00}; // aqu se lleva el control de reset de puntos
byte N[10][7] = {
{1,1,1,1,1,1,0}, // Display 7 segmentos {a,b,c,d,e,f,g}
{0,1,1,0,0,0,0},
{1,1,0,1,1,0,1},
{1,1,1,1,0,0,1},
{0,1,1,0,0,1,1},
{1,0,1,1,0,1,1},
{0,0,1,1,1,1,1},
{1,1,1,0,0,0,0},
{1,1,1,1,1,1,1},
{1,1,1,0,0,1,1},
};
byte E[7]={0,0,0,0,0,0,1}; // guin central del display de 7 segmentos. nicamente para sealizacin. Puede
cambiarse
int valido=0;
int tiempo1=2;
int boton=0;
int puntos=0;
int b;
int i;
int j;
int d=0;
int k=0; //
int p=0; //
int q=0; //
int r=0; //
int s=0; //
void setup()
{
Serial.begin(9600);
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
delay(500);
void loop()
{
boton=digitalRead(40);
while(boton==1)
{
for(i=8; i<=11; i++)
{
digitalWrite(i,HIGH);
}
for(i=0; i<=6; i++)
{
j=(2*i)+22;
digitalWrite(j,E[i]);
}
delay(4000);
for(i=8; i<=11; i++)
{
digitalWrite(i,LOW);
}
byte trailerBlock = 7;
MFRC522::StatusCode status;
if (status != MFRC522::STATUS_OK)
return;
status = (MFRC522::StatusCode) mfrc522.MIFARE_Write(blockAddr, writeBlock, 16); // Escritura de
datos
if (status != MFRC522::STATUS_OK)
{
// Halt PICC
mfrc522.PICC_HaltA();
// Stop encryption on PCD
mfrc522.PCD_StopCrypto1();
return;
}
// Halt PICC
mfrc522.PICC_HaltA();
// Stop encryption on PCD
mfrc522.PCD_StopCrypto1();
boton=0;
}
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
return;
byte trailerBlock = 7;
MFRC522::StatusCode status;
byte buffer[18];
byte size = sizeof(buffer);
if (status != MFRC522::STATUS_OK)
return;
while(puntos>=1000)
{
p++;
puntos-=1000;
Serial.println("Miles: ");
Serial.println(p,DEC);
}
while(puntos>=100)
{
q++;
puntos-=100;
Serial.println("Centenas: ");
Serial.println(q,DEC);
}
while(puntos>=10)
{
r++;
puntos-=10;
Serial.println("Decenas: ");
Serial.println(r,DEC);
}
s=puntos;
Serial.println("Unidades: ");
Serial.println(s,DEC);
puntos=0;
Serial.println();
Serial.println(puntos,DEC);
p=0;
q=0;
r=0;
s=0;
// Halt PICC
mfrc522.PICC_HaltA();
// Stop encryption on PCD
mfrc522.PCD_StopCrypto1();
}