⚲
Projet
Général
Profil
Connexion
Accueil
Projets
Aide
Recherche
:
Accueil
Tous les projets
Accueil
Aperçu
Activité
Annonces
Documents
Wiki
Fichiers
Télécharger (1,22 ko)
Izabela Grubicka
» nfc_test.ino
Izabela Grubicka
, 17/07/2026 15:46
//https://fr.38-3d.co.uk/blogs/blog-38-3d-3/comment-utiliser-le-lecteur-rfid-nfc-pn532-avec-arduino
#include
<Wire.h>
#include
<Adafruit_PN532.h>
#define SDA_PIN 21
#define SCL_PIN 22
Adafruit_PN532
nfc
(
SDA_PIN
,
SCL_PIN
);
void
setup
()
{
Serial
.
begin
(
115200
);
Serial
.
println
(
"PN532 RFID/NFC Reader Test"
);
nfc
.
begin
();
uint32_t
versiondata
=
nfc
.
getFirmwareVersion
();
if
(
!
versiondata
)
{
Serial
.
println
(
"Didn't find PN532 module. Check connections."
);
while
(
1
);
}
Serial
.
println
(
"Found PN532 module."
);
nfc
.
SAMConfig
();
// Configure the module in normal mode
Serial
.
println
(
"Waiting for an NFC card..."
);
}
void
loop
()
{
uint8_t
success
;
uint8_t
uid
[]
=
{
0
};
// Buffer to store UID
uint8_t
uidLength
;
// Length of the UID
// Check if an NFC card is present
success
=
nfc
.
readPassiveTargetID
(
PN532_MIFARE_ISO14443A
,
uid
,
&
uidLength
);
if
(
success
)
{
Serial
.
println
(
"Found an NFC card!"
);
Serial
.
print
(
"UID Length: "
);
Serial
.
print
(
uidLength
,
DEC
);
Serial
.
println
(
" bytes"
);
Serial
.
print
(
"UID Value: "
);
for
(
uint8_t
i
=
0
;
i
<
uidLength
;
i
++
)
{
Serial
.
print
(
" 0x"
);
Serial
.
print
(
uid
[
i
],
HEX
);
}
Serial
.
println
(
""
);
delay
(
1000
);
// Wait 1 second
}
}
« Précédent
1
…
32
33
34
35
36
…
44
Suivant »
(34-34/44)
Chargement...