bonjour tt le monde
je me tourne vers vous car j'ai un petit problème avec mon code sachant que je suis une brèle en programmation voila je possède un arduino méga et un pn532 v3 le code fonctionnent trés bien mais le truck c'est que j'ai envie de faire en sorte que dès que j'approche mon tag j'active une led et que quand je repasse se même tag j'éteint ma led mais je n'arrive pas car sur le moniteur serie j'ai "permission granted, door unlocked" mais impossible de faire en sorte que dés que je repasse mon tag accéder "permission granted, systems trigger" voila mon code merci d'avance
#include <eeprom.h>
/**************************************************************************/
/*!
example attempt connect iso14443a
card or tag , retrieve basic information it
can used determine type of card is.
note need baud rate 115200 because need print
out data , read card @ same time!
*/
/**************************************************************************/
int triggerpin1 = 2;
int triggerpin2 = 3;
int triggerpin3 = 4;
// choose spi or i2c or hsu
#if 0
#include <spi.h>
#include <pn532_spi.h>
#include "pn532.h"
pn532spi pn532spi(spi, 10);
pn532 nfc(pn532spi);
#elif 1
#include <pn532_hsu.h>
#include <pn532.h>
pn532_hsu pn532hsu(serial1);
pn532 nfc(pn532hsu);
#else
#include <wire.h>
#include <pn532_i2c.h>
#include <pn532.h>
pn532_i2c pn532i2c(wire);
pn532 nfc(pn532i2c);
#endif
void setup(void) {
pinmode(triggerpin1, output);
pinmode(triggerpin2, output);
pinmode(triggerpin3, output);
pinmode(12, output);
serial.begin(115200);
serial.println("hello!");
nfc.begin();
uint32_t versiondata = nfc.getfirmwareversion();
if (! versiondata) {
serial.print(versiondata);
serial.print("pn53x key scanner board not online");
while (1); // halt
}
// got ok data, print out!
serial.print("found key scanner board pn5"); serial.println((versiondata>>24) & 0xff, hex);
serial.print("firmware ver. "); serial.print((versiondata>>16) & 0xff, dec);
serial.print('.'); serial.println((versiondata>> & 0xff, dec);
// set max number of retry attempts read card
// prevents waiting forever card, is
// default behaviour of pn532.
nfc.setpassiveactivationretries(0xff);
// configure board read rfid tags
nfc.samconfig();
serial.println("waiting valid card");
}
//***************************************************fonction lecture de tag
void loop(void) {
string ringuid;
boolean success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // buffer store returned uid
uint8_t uidlength; // length of uid (4 or 7 bytes depending on iso14443a card type)
// wait iso14443a type cards (mifare, etc.). when 1 found
// 'uid' populated uid, , uidlength indicate
// if uid 4 bytes (mifare classic) or 7 bytes (mifare ultralight)
success = nfc.readpassivetargetid(pn532_mifare_iso14443a, &uid[0], &uidlength);
if (success) {
// display basic information card
serial.println("found iso14443a card");
serial.print(" uid length: "); serial.print(uidlength, dec); serial.println(" bytes");
serial.print(" uid value: ");
(uint8_t = 0; < uidlength; i++)
{
//serial.print("..");
serial.print(uid, hex);
ringuid += string(uid, hex);
}
serial.println(ringuid + "\n");
if (ringuid == "e6f37465" || ringuid == "xxxxxxxxxxxx"){ // put authorised uid in here
serial.println("permission granted, door unlocked");
digitalwrite(12, high); // turn led on (high voltage level)
//delay(1000); // wait second
//digitalwrite(13, low); // turn led off making voltage low
//delay(500); // wait second
//digitalwrite(13, high); // turn led on (high voltage level)
//delay(250); // wait second
//digitalwrite(13, low); // turn led off making voltage low
//delay(500); // wait second
//digitalwrite(13, high); // turn led on (high voltage level)
//delay(250); // wait second
//digitalwrite(13, low); // turn led off making voltage low
//digitalwrite(triggerpin1, high); // triggers unlock output central locking
//digitalwrite(triggerpin1, low); // removes triggered output
//digitalwrite(triggerpin3, low); // removes triggered alarm output
//delay(1000);
}
else if (ringuid == "e6f37465" || ringuid == "xxxxxxxxxxxx"){ // put authorised uid in here
serial.println("permission granted, systems trigger");
digitalwrite(12, low);
//digitalwrite(triggerpin2, high); // sets latching relay trigger on ie ignition mode in car allow button start - button start must disable reads until button turns engine off again
//digitalwrite(triggerpin2, low); // removes latching relay trigger
//digitalwrite(triggerpin3, low); // removes triggered alarm output
}
else {
serial.println("i'm afraid can't allow dave");
digitalwrite(triggerpin3, high); // trigger latching relay alarm system
delay(1000); // waits second
}
}
}
je me tourne vers vous car j'ai un petit problème avec mon code sachant que je suis une brèle en programmation voila je possède un arduino méga et un pn532 v3 le code fonctionnent trés bien mais le truck c'est que j'ai envie de faire en sorte que dès que j'approche mon tag j'active une led et que quand je repasse se même tag j'éteint ma led mais je n'arrive pas car sur le moniteur serie j'ai "permission granted, door unlocked" mais impossible de faire en sorte que dés que je repasse mon tag accéder "permission granted, systems trigger" voila mon code merci d'avance
#include <eeprom.h>
/**************************************************************************/
/*!
example attempt connect iso14443a
card or tag , retrieve basic information it
can used determine type of card is.
note need baud rate 115200 because need print
out data , read card @ same time!
*/
/**************************************************************************/
int triggerpin1 = 2;
int triggerpin2 = 3;
int triggerpin3 = 4;
// choose spi or i2c or hsu
#if 0
#include <spi.h>
#include <pn532_spi.h>
#include "pn532.h"
pn532spi pn532spi(spi, 10);
pn532 nfc(pn532spi);
#elif 1
#include <pn532_hsu.h>
#include <pn532.h>
pn532_hsu pn532hsu(serial1);
pn532 nfc(pn532hsu);
#else
#include <wire.h>
#include <pn532_i2c.h>
#include <pn532.h>
pn532_i2c pn532i2c(wire);
pn532 nfc(pn532i2c);
#endif
void setup(void) {
pinmode(triggerpin1, output);
pinmode(triggerpin2, output);
pinmode(triggerpin3, output);
pinmode(12, output);
serial.begin(115200);
serial.println("hello!");
nfc.begin();
uint32_t versiondata = nfc.getfirmwareversion();
if (! versiondata) {
serial.print(versiondata);
serial.print("pn53x key scanner board not online");
while (1); // halt
}
// got ok data, print out!
serial.print("found key scanner board pn5"); serial.println((versiondata>>24) & 0xff, hex);
serial.print("firmware ver. "); serial.print((versiondata>>16) & 0xff, dec);
serial.print('.'); serial.println((versiondata>> & 0xff, dec);
// set max number of retry attempts read card
// prevents waiting forever card, is
// default behaviour of pn532.
nfc.setpassiveactivationretries(0xff);
// configure board read rfid tags
nfc.samconfig();
serial.println("waiting valid card");
}
//***************************************************fonction lecture de tag
void loop(void) {
string ringuid;
boolean success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // buffer store returned uid
uint8_t uidlength; // length of uid (4 or 7 bytes depending on iso14443a card type)
// wait iso14443a type cards (mifare, etc.). when 1 found
// 'uid' populated uid, , uidlength indicate
// if uid 4 bytes (mifare classic) or 7 bytes (mifare ultralight)
success = nfc.readpassivetargetid(pn532_mifare_iso14443a, &uid[0], &uidlength);
if (success) {
// display basic information card
serial.println("found iso14443a card");
serial.print(" uid length: "); serial.print(uidlength, dec); serial.println(" bytes");
serial.print(" uid value: ");
(uint8_t = 0; < uidlength; i++)
{
//serial.print("..");
serial.print(uid, hex);
ringuid += string(uid, hex);
}
serial.println(ringuid + "\n");
if (ringuid == "e6f37465" || ringuid == "xxxxxxxxxxxx"){ // put authorised uid in here
serial.println("permission granted, door unlocked");
digitalwrite(12, high); // turn led on (high voltage level)
//delay(1000); // wait second
//digitalwrite(13, low); // turn led off making voltage low
//delay(500); // wait second
//digitalwrite(13, high); // turn led on (high voltage level)
//delay(250); // wait second
//digitalwrite(13, low); // turn led off making voltage low
//delay(500); // wait second
//digitalwrite(13, high); // turn led on (high voltage level)
//delay(250); // wait second
//digitalwrite(13, low); // turn led off making voltage low
//digitalwrite(triggerpin1, high); // triggers unlock output central locking
//digitalwrite(triggerpin1, low); // removes triggered output
//digitalwrite(triggerpin3, low); // removes triggered alarm output
//delay(1000);
}
else if (ringuid == "e6f37465" || ringuid == "xxxxxxxxxxxx"){ // put authorised uid in here
serial.println("permission granted, systems trigger");
digitalwrite(12, low);
//digitalwrite(triggerpin2, high); // sets latching relay trigger on ie ignition mode in car allow button start - button start must disable reads until button turns engine off again
//digitalwrite(triggerpin2, low); // removes latching relay trigger
//digitalwrite(triggerpin3, low); // removes triggered alarm output
}
else {
serial.println("i'm afraid can't allow dave");
digitalwrite(triggerpin3, high); // trigger latching relay alarm system
delay(1000); // waits second
}
}
}
code dans la balise ! sinon personne ne voudra t'aider
Arduino Forum > International > Français (Moderators: jfs, Snootlab) > Petit aide s'il vous plait en Code Programmation
arduino
Comments
Post a Comment