Bonjour,
J'utilise ce programme fourni par seeed sur ce site : Grove - 125KHz RFID Reader | Seeed Studio Wiki
/*
link between the computer and the SoftSerial Shield
at 9600 bps 8-N-1
Computer is connected to Hardware UART
SoftSerial Shield is connected to the Software UART:D2&D3
*/
#include <SoftwareSerial.h>
SoftwareSerial SoftSerial(2, 3);
unsigned char buffer[64]; // buffer array for data receive over serial port
int count = 0; // counter for buffer array
void setup()
{
SoftSerial.begin(9600); // the SoftSerial baud rate
Serial.begin(9600); // the Serial port of Arduino baud rate.
}
void loop()
{
// if date is coming from software serial port ==> data is coming from SoftSerial shield
if (SoftSerial.available())
{
while(SoftSerial.available()) // reading data into char array
{
buffer[count++] = SoftSerial.read(); // writing data into array
if(count == 64)break;
}
Serial.write(buffer, count); // if no data transmission ends, write buffer to hardware serial port
clearBufferArray(); // call clearBufferArray function to clear the stored data from the array
count = 0; // set counter of while loop to zero
}
if (Serial.available()) // if data is available on hardware serial port ==> data is coming from PC or notebook
SoftSerial.write(Serial.read()); // write it to the SoftSerial shield
}
void clearBufferArray() // function to clear buffer array
{
// clear all index of array with command NULL
for (int i=0; i<count; i++)
{
buffer[i]=NULL;
}
}
Tout fonctionne bien, sauf que le numéro de la carte affiché sur le port série est en hexa comme indiqué sur la page du fournisseur :
Output: 0700952F229F ------------- Hex [[Start Bit(07h) + Card Number(8 numbers) + Checksum]
J'ai besoin pour le traitement suivant (comparaison avec une base de données stockée sur ordinateur d'obtenir le numéro de la carte (et seulement le numéro de la carte) en décimal.
Il y a t-il une solution simple pour "nettoyer" puis transformer l'information en valeur décimal avant de l'envoyer sur le port série ?