Petit aide s'il vous plait en Code Programmation

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 :sob: en programmation voila je possède un Arduino Méga et un PN532 V3 le code fonctionnent trés bien :smiley: 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 :wink:

#include <EEPROM.h>

/**************************************************************************/
/*!
This example will attempt to connect to an ISO14443A
card or tag and retrieve some basic information about it
that can be used to determine what type of card it is.

Note that you need the baud rate to be 115200 because we need to print
out the data and read from the card at the same time!

*/
/**************************************************************************/

int triggerPin1 = 2;
int triggerPin2 = 3;
int triggerPin3 = 4;

// choose to 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 it 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>>8) & 0xFF, DEC);

// Set the max number of retry attempts to read from a card
// This prevents us from waiting forever for a card, which is
// the default behaviour of the PN532.
nfc.setPassiveActivationRetries(0xFF);

// configure board to read RFID tags
nfc.SAMConfig();

Serial.println(“Waiting for a valid card”);
}

//***************************************************fonction lecture de tag
void loop(void) {
String ringUid;
boolean success;
uint8_t uid = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

// Wait for an ISO14443A type cards (Mifare, etc.). When one is found
// ‘uid’ will be populated with the UID, and uidLength will indicate
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);

if (success) {
// Display some basic information about the card
Serial.println(“Found an ISO14443A 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("…");
Serial.print(uid*, HEX);*
_ ringUid += String(uid*, HEX);_
_
}_
_
Serial.println(ringUid + “\n”);*_

* if (ringUid == “e6f37465” || ringUid == “xxxxxxxxxxxx”){ // put your authorised UID in here*
* Serial.println(“PERMISSION GRANTED, DOOR UNLOCKED”);*
* digitalWrite(12, HIGH); // turn the LED on (HIGH is the voltage level)*
* //delay(1000); // wait for a second*
* //digitalWrite(13, LOW); // turn the LED off by making the voltage LOW*
* //delay(500); // wait for a second*
* //digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)*
* //delay(250); // wait for a second*
* //digitalWrite(13, LOW); // turn the LED off by making the voltage LOW*
* //delay(500); // wait for a second*
* //digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)*
* //delay(250); // wait for a second*
* //digitalWrite(13, LOW); // turn the LED off by making the voltage LOW*
* //digitalWrite(triggerPin1, HIGH); // triggers unlock output for central locking*
* //digitalWrite(triggerPin1, LOW); // removes triggered output*
* //digitalWrite(triggerPin3, LOW); // Removes triggered alarm output*
* //delay(1000);*
* }*

* else if (ringUid == “e6f37465” || ringUid == “xxxxxxxxxxxx”){ // put your authorised UID in here*
* Serial.println(“PERMISSION GRANTED, SYSTEMS TRIGGER”);*
* digitalWrite(12, LOW);*
* //digitalWrite(triggerPin2, HIGH); // sets latching relay trigger on ie for ignition mode in car to 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 I CAN’T ALLOW THAT DAVE”);*
* digitalWrite(triggerPin3, HIGH); // Trigger latching relay to alarm system*
* delay(1000); // waits for a second *
* }*
* }*
}

Code dans la balise ! Sinon personne ne voudra t'aider

Ayoub2698:
je me tourne vers vous car j'ai un petit problème avec mon code sachant que je suis une brèle en programmation

OK, on peut être une brêle en programmation et utiliser sous cerveau.
Si tu fais 2 tests exclusifs l'un de l'autre (if ... else if...) en mettant la même condition dans les 2 tests tu tombera toujours dans le premier.
Un exemple que tu devrais comprendre:

si je suis blond
    j'écris un programme débile
sinon si je suis blond
    je code comme un dieu

Avec un test comme ça tu écriras toujours des programme débile.

Donc cela veut dire qu'il te manque un paramètre pour faire la distinction entre les 2 cas.
Donc réfléchit un peu.....

En effet, j'avais pas regardé son code !