ENIB 2023 : Nedex : Différence entre versions
(→photo de l'équipe) |
|||
| (2 révisions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 4 : | Ligne 4 : | ||
==photo de l'équipe== | ==photo de l'équipe== | ||
| − | [[Fichier: | + | [[Fichier:bombe_nedex.jpg|600px]] |
==Que fait ce projet ? == | ==Que fait ce projet ? == | ||
| Ligne 25 : | Ligne 25 : | ||
==Code== | ==Code== | ||
<pre> | <pre> | ||
| − | + | #include <Wire.h> | |
| + | #include <LiquidCrystal_I2C.h> | ||
| + | |||
| + | |||
| + | #define PIN_START_BTN 13 | ||
| + | #define PIN_LED_EXPLO 26 | ||
| + | #define PIN_VIBRATION 12 | ||
| + | #define PIN_POTENTIO 15 | ||
| + | #define PIN_MORSE_BTN_DOT 14 | ||
| + | #define PIN_MORSE_BTN_HYP 27 | ||
| + | |||
| + | #define PIN_CABLE_ORANGE 4 | ||
| + | #define PIN_CABLE_YELLOW 5 | ||
| + | #define PIN_CABLE_GREEN 18 | ||
| + | #define PIN_CABLE_BLUE 19 | ||
| + | |||
| + | int state = 0; | ||
| + | int bombTimer = 300; | ||
| + | long unsigned ms_time = 0; | ||
| + | int potenCode[] = {0, 0, 0}; | ||
| + | int potenCount = 3; | ||
| + | |||
| + | String morseResult = "...---..."; | ||
| + | String morseInput = ""; | ||
| + | |||
| + | LiquidCrystal_I2C lcd(0x27, 16, 2); | ||
| + | |||
| + | void setup() { | ||
| + | pinMode(PIN_START_BTN, INPUT_PULLUP); | ||
| + | pinMode(PIN_LED_EXPLO, OUTPUT); | ||
| + | pinMode(PIN_VIBRATION, OUTPUT); | ||
| + | pinMode(PIN_POTENTIO, INPUT); | ||
| + | pinMode(PIN_MORSE_BTN_DOT, INPUT_PULLUP); | ||
| + | pinMode(PIN_MORSE_BTN_HYP, INPUT_PULLUP); | ||
| + | |||
| + | pinMode(PIN_CABLE_ORANGE, INPUT_PULLUP); | ||
| + | pinMode(PIN_CABLE_YELLOW, INPUT_PULLUP); | ||
| + | pinMode(PIN_CABLE_GREEN, INPUT_PULLUP); | ||
| + | pinMode(PIN_CABLE_BLUE, INPUT_PULLUP); | ||
| + | |||
| + | Serial.begin(9600); | ||
| + | |||
| + | lcd.init(); | ||
| + | lcd.backlight(); | ||
| + | |||
| + | bombTimer++; | ||
| + | |||
| + | |||
| + | Serial.println("----------- INIT SYSTEM -----------"); | ||
| + | |||
| + | //Serial.println("-----------------------------------"); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | //Serial.println(map(analogRead(PIN_POTENTIO), 0, 4095, 0, 255)); | ||
| + | |||
| + | /* | ||
| + | Serial.print(digitalRead(PIN_CABLE_ORANGE)); | ||
| + | Serial.print(" - "); | ||
| + | Serial.print(digitalRead(PIN_CABLE_YELLOW)); | ||
| + | Serial.print(" - "); | ||
| + | Serial.print(digitalRead(PIN_CABLE_GREEN)); | ||
| + | Serial.print(" - "); | ||
| + | Serial.print(digitalRead(PIN_CABLE_BLUE)); | ||
| + | Serial.println(" "); | ||
| + | */ | ||
| + | switch(state){ | ||
| + | case 0: // waiting start button | ||
| + | lcd.setCursor(0, 0); | ||
| + | lcd.print("Press to start !"); | ||
| + | if(!digitalRead(PIN_START_BTN)){ | ||
| + | lcd.clear(); | ||
| + | potenCode[0] = random(10, 245); | ||
| + | potenCode[1] = random(10, 245); | ||
| + | potenCode[2] = random(10, 245); | ||
| + | Serial.println("potenCode[0]: "+String(potenCode[0])); | ||
| + | Serial.println("potenCode[1]: "+String(potenCode[1])); | ||
| + | Serial.println("potenCode[2]: "+String(potenCode[2])); | ||
| + | |||
| + | state = 4; // Poten test | ||
| + | } | ||
| + | break; | ||
| + | case 1: // Bomb explosion | ||
| + | lcd.setCursor(0, 0); | ||
| + | lcd.print("BOOOOOOM !"); | ||
| + | //digitalWrite(PIN_LED_EXPLO, HIGH); | ||
| + | |||
| + | digitalWrite(PIN_VIBRATION, HIGH); | ||
| + | digitalWrite(PIN_LED_EXPLO, HIGH); | ||
| + | delay(200); | ||
| + | digitalWrite(PIN_VIBRATION, LOW); | ||
| + | digitalWrite(PIN_LED_EXPLO, LOW); | ||
| + | delay(200); | ||
| + | |||
| + | break; | ||
| + | case 2: // Potentiometer test | ||
| + | lcd.setCursor(0, 1); | ||
| + | lcd.print("Find value "+String(map(analogRead(PIN_POTENTIO), 0, 4095, 0, 255))+" "); | ||
| + | lcd.setCursor(13, 0); | ||
| + | lcd.print(String(3-potenCount)+"/3"); | ||
| + | |||
| + | Serial.println(potenCode[potenCount-1]); | ||
| + | if(map(analogRead(PIN_POTENTIO), 0, 4095, 0, 255) >= potenCode[potenCount-1]-30 && map(analogRead(PIN_POTENTIO), 0, 4095, 0, 255) <= potenCode[potenCount-1]+30){ | ||
| + | digitalWrite(PIN_VIBRATION, HIGH); | ||
| + | }else{ | ||
| + | digitalWrite(PIN_VIBRATION, LOW); | ||
| + | } | ||
| + | |||
| + | if(potenCount <= 3 && map(analogRead(PIN_POTENTIO), 0, 4095, 0, 255) == potenCode[potenCount-1]){ | ||
| + | potenCount--; | ||
| + | |||
| + | if(potenCount == 0){ | ||
| + | lcd.setCursor(0, 1); | ||
| + | lcd.print("Blue wire "); | ||
| + | digitalWrite(PIN_VIBRATION, LOW); | ||
| + | state = 5; | ||
| + | } | ||
| + | } | ||
| + | break; | ||
| + | case 3: // Bomb Difused | ||
| + | lcd.setCursor(0, 0); | ||
| + | lcd.print("Bomb difused"); | ||
| + | break; | ||
| + | case 4: // Morse code | ||
| + | if(!digitalRead(PIN_MORSE_BTN_DOT) && morseResult.charAt(morseInput.length()) == '.'){ | ||
| + | morseInput.concat("."); | ||
| + | }else if(!digitalRead(PIN_MORSE_BTN_HYP) && morseResult.charAt(morseInput.length()) == '-'){ | ||
| + | morseInput.concat("-"); | ||
| + | } | ||
| + | delay(150); | ||
| + | |||
| + | lcd.setCursor(0, 1); | ||
| + | lcd.print("Morse "+morseInput); | ||
| + | |||
| + | // End of code | ||
| + | if(morseInput.length() == morseResult.length()){ | ||
| + | lcd.setCursor(0, 1); | ||
| + | lcd.print("Green wire "); | ||
| + | state = 2; // potentio | ||
| + | } | ||
| + | break; | ||
| + | case 5: // nothing | ||
| + | // | ||
| + | break; | ||
| + | } | ||
| + | |||
| + | if(state > 0 && state != 3 && millis() >= ms_time + 1000){ // every seconds | ||
| + | ms_time = millis(); | ||
| + | bombTimer--; | ||
| + | lcd.clear(); | ||
| + | lcd.setCursor(0, 0); | ||
| + | lcd.print(bombTimer); | ||
| + | } | ||
| + | |||
| + | if(bombTimer <= 0 || digitalRead(PIN_CABLE_YELLOW) || digitalRead(PIN_CABLE_GREEN) || digitalRead(PIN_CABLE_BLUE)){ | ||
| + | lcd.clear(); | ||
| + | state = 1; // explosion | ||
| + | }else if(state != 3 && digitalRead(PIN_CABLE_ORANGE)){ | ||
| + | lcd.clear(); | ||
| + | state = 3; // difused | ||
| + | } | ||
| + | } | ||
| + | |||
</pre> | </pre> | ||
| Ligne 60 : | Ligne 222 : | ||
==Enigme 3== | ==Enigme 3== | ||
| − | Il ne reste plus que 2 câbles. Vous n'avez pas le droit à l'erreur. Ouvrez le coffre et trouvez le dernier câble que vous ne devez pas couper. Tournez le bouton et soyez attentif aux vibrations, cela signifie que vous approchez de la valeur à entrer. | + | Il ne reste plus que 2 câbles. Vous n'avez pas le droit à l'erreur. Ouvrez le coffre et trouvez le dernier câble que vous ne devez pas couper. Tournez le bouton et soyez attentif aux vibrations, cela signifie que vous approchez de la valeur à entrer. Vous devrez trouver 3 valeurs pour compléter cette étape. |
==Conclusion== | ==Conclusion== | ||
Félicitations, vous avez trouvé le bon câble dans le temps imparti. Vous avez sauvé le président. | Félicitations, vous avez trouvé le bon câble dans le temps imparti. Vous avez sauvé le président. | ||
Version actuelle datée du 4 février 2023 à 13:12
Nous sommes pendant la guerre froide, un espion russe a posé une bombe dans l’hôtel où se trouve le président Kennedy pour tenter de l’assassiner. Heureusement, nous l’avons repéré juste avant son apparition lors du meeting de Cuba. Il n'y a qu'un seul câble à couper ! Les énigmes vont pouvoir vous aidez à déterminer quels fils vous ne devez pas toucher. Il vous faut maintenant la désamorcer. Suivez les instructions à la lettre, bon courage !
Sommaire
photo de l'équipe
Que fait ce projet ?
Dans ce projet, les joueurs vont devoir désamorcer une bombe via une série d'énigmes afin de découvrir quel câble ils doivent couper et donc réussir leur mission.
Liste des composants
- Pièce de puzzle en bois
- carte ESP 32
- Vibreur
- Ecran LCD
- Potentiomètre
- Câbles
- Breadboard
- Boutons
- LED orange
- Câble micro-usb
- Résistances
Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define PIN_START_BTN 13
#define PIN_LED_EXPLO 26
#define PIN_VIBRATION 12
#define PIN_POTENTIO 15
#define PIN_MORSE_BTN_DOT 14
#define PIN_MORSE_BTN_HYP 27
#define PIN_CABLE_ORANGE 4
#define PIN_CABLE_YELLOW 5
#define PIN_CABLE_GREEN 18
#define PIN_CABLE_BLUE 19
int state = 0;
int bombTimer = 300;
long unsigned ms_time = 0;
int potenCode[] = {0, 0, 0};
int potenCount = 3;
String morseResult = "...---...";
String morseInput = "";
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
pinMode(PIN_START_BTN, INPUT_PULLUP);
pinMode(PIN_LED_EXPLO, OUTPUT);
pinMode(PIN_VIBRATION, OUTPUT);
pinMode(PIN_POTENTIO, INPUT);
pinMode(PIN_MORSE_BTN_DOT, INPUT_PULLUP);
pinMode(PIN_MORSE_BTN_HYP, INPUT_PULLUP);
pinMode(PIN_CABLE_ORANGE, INPUT_PULLUP);
pinMode(PIN_CABLE_YELLOW, INPUT_PULLUP);
pinMode(PIN_CABLE_GREEN, INPUT_PULLUP);
pinMode(PIN_CABLE_BLUE, INPUT_PULLUP);
Serial.begin(9600);
lcd.init();
lcd.backlight();
bombTimer++;
Serial.println("----------- INIT SYSTEM -----------");
//Serial.println("-----------------------------------");
}
void loop() {
//Serial.println(map(analogRead(PIN_POTENTIO), 0, 4095, 0, 255));
/*
Serial.print(digitalRead(PIN_CABLE_ORANGE));
Serial.print(" - ");
Serial.print(digitalRead(PIN_CABLE_YELLOW));
Serial.print(" - ");
Serial.print(digitalRead(PIN_CABLE_GREEN));
Serial.print(" - ");
Serial.print(digitalRead(PIN_CABLE_BLUE));
Serial.println(" ");
*/
switch(state){
case 0: // waiting start button
lcd.setCursor(0, 0);
lcd.print("Press to start !");
if(!digitalRead(PIN_START_BTN)){
lcd.clear();
potenCode[0] = random(10, 245);
potenCode[1] = random(10, 245);
potenCode[2] = random(10, 245);
Serial.println("potenCode[0]: "+String(potenCode[0]));
Serial.println("potenCode[1]: "+String(potenCode[1]));
Serial.println("potenCode[2]: "+String(potenCode[2]));
state = 4; // Poten test
}
break;
case 1: // Bomb explosion
lcd.setCursor(0, 0);
lcd.print("BOOOOOOM !");
//digitalWrite(PIN_LED_EXPLO, HIGH);
digitalWrite(PIN_VIBRATION, HIGH);
digitalWrite(PIN_LED_EXPLO, HIGH);
delay(200);
digitalWrite(PIN_VIBRATION, LOW);
digitalWrite(PIN_LED_EXPLO, LOW);
delay(200);
break;
case 2: // Potentiometer test
lcd.setCursor(0, 1);
lcd.print("Find value "+String(map(analogRead(PIN_POTENTIO), 0, 4095, 0, 255))+" ");
lcd.setCursor(13, 0);
lcd.print(String(3-potenCount)+"/3");
Serial.println(potenCode[potenCount-1]);
if(map(analogRead(PIN_POTENTIO), 0, 4095, 0, 255) >= potenCode[potenCount-1]-30 && map(analogRead(PIN_POTENTIO), 0, 4095, 0, 255) <= potenCode[potenCount-1]+30){
digitalWrite(PIN_VIBRATION, HIGH);
}else{
digitalWrite(PIN_VIBRATION, LOW);
}
if(potenCount <= 3 && map(analogRead(PIN_POTENTIO), 0, 4095, 0, 255) == potenCode[potenCount-1]){
potenCount--;
if(potenCount == 0){
lcd.setCursor(0, 1);
lcd.print("Blue wire ");
digitalWrite(PIN_VIBRATION, LOW);
state = 5;
}
}
break;
case 3: // Bomb Difused
lcd.setCursor(0, 0);
lcd.print("Bomb difused");
break;
case 4: // Morse code
if(!digitalRead(PIN_MORSE_BTN_DOT) && morseResult.charAt(morseInput.length()) == '.'){
morseInput.concat(".");
}else if(!digitalRead(PIN_MORSE_BTN_HYP) && morseResult.charAt(morseInput.length()) == '-'){
morseInput.concat("-");
}
delay(150);
lcd.setCursor(0, 1);
lcd.print("Morse "+morseInput);
// End of code
if(morseInput.length() == morseResult.length()){
lcd.setCursor(0, 1);
lcd.print("Green wire ");
state = 2; // potentio
}
break;
case 5: // nothing
//
break;
}
if(state > 0 && state != 3 && millis() >= ms_time + 1000){ // every seconds
ms_time = millis();
bombTimer--;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(bombTimer);
}
if(bombTimer <= 0 || digitalRead(PIN_CABLE_YELLOW) || digitalRead(PIN_CABLE_GREEN) || digitalRead(PIN_CABLE_BLUE)){
lcd.clear();
state = 1; // explosion
}else if(state != 3 && digitalRead(PIN_CABLE_ORANGE)){
lcd.clear();
state = 3; // difused
}
}
Enigme 1
Vous vous retrouvez face à la bombe. Vous n'avez aucune information et vous ne savez pas par où commencer. Appelez à l'aide le central, ils devraient pouvoir vous aider à commencer.
Enigme 2
Nous avons retrouvé la position de 6 espions. Leurs positions vont nous permettre de déterminer la couleur du fil à couper ensuite grace à un code hexadécimal en additionnant les coordonnées. Voici leurs positions:
1er Anastassia : Anastassia a été vu dans un bateau à quai dans l’ouest de la Lettonie.
2eme Bogdan : Bogdan a été retrouvé mort, assassiné dans sa chambre d’hôtel dans l’est de la Crimée
3eme Chris : Chris a été vu dans un restaurant à Gomel, juste a la frontière entre la Biélorussie et Ukraine, par un de nos agents.
4eme Dimitri : Dimitri a été aperçu a la frontière entre la Lituanie et la Biélorussie en voiture.
5eme Eva : Le radar d’un de nos navires à repérer une embarcation ennemie au large du Maroc. Elle approche maintenant le sud-est du Portugal. Eva est à bord de ce bateau.
6eme Fedor : Fedor a été aperçu avec son équipe sur les docks de Lagos. Il semble attendre l’arrivée d’Eva.
Vous obtenez à la fin de cette énigme un code de six caractères. Que peut-il signifier ?
Enigme 3
Il ne reste plus que 2 câbles. Vous n'avez pas le droit à l'erreur. Ouvrez le coffre et trouvez le dernier câble que vous ne devez pas couper. Tournez le bouton et soyez attentif aux vibrations, cela signifie que vous approchez de la valeur à entrer. Vous devrez trouver 3 valeurs pour compléter cette étape.
Conclusion
Félicitations, vous avez trouvé le bon câble dans le temps imparti. Vous avez sauvé le président.
