ENIB 2023 : Salade d'Enigmes : Différence entre versions
(→Catégories) |
|||
(6 révisions intermédiaires par 2 utilisateurs non affichées) | |||
Ligne 1 : | Ligne 1 : | ||
==photo de l'équipe== | ==photo de l'équipe== | ||
− | + | ||
− | [[Fichier:PhotoDeMoi.jpg| | + | [[Fichier:PhotoDeMoi.jpg|600px]] |
==Que fait ce projet ? == | ==Que fait ce projet ? == | ||
Ligne 10 : | Ligne 10 : | ||
* Partie 1 Tableau périodique : | * Partie 1 Tableau périodique : | ||
+ | Le but était de sélectionner 2 valeurs grâce à un potentiomètre. Ces valeurs se devinaient grâce à deux matériaux coller sur la plaque et leur nombre atomique trouvé sur le tableau périodique | ||
[[Fichier:EnigmeTableauPeriodiqueV2.jpg|vignette]] | [[Fichier:EnigmeTableauPeriodiqueV2.jpg|vignette]] | ||
+ | * Partie 2 Corde César | ||
− | + | [[Fichier:CodeCesarV2.jpg|vignette]] | |
* Partie 3 Code Morse | * Partie 3 Code Morse | ||
+ | |||
+ | [[Fichier:MorseEtSelectionReponseV2.jpg|vignette]] | ||
*Partie 4 labyrinthe | *Partie 4 labyrinthe | ||
+ | |||
+ | [[Fichier:LabyrintheV2.jpg|vignette]] | ||
==Code== | ==Code== | ||
Ligne 121 : | Ligne 127 : | ||
return 0; | return 0; | ||
} | } | ||
+ | } | ||
+ | |||
+ | /////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
+ | |||
+ | Code pour sélection de la réponse (Rouge ou Vert ou Bleu) : | ||
+ | |||
+ | #define r1_pin 13 | ||
+ | #define b1_pin 12 | ||
+ | #define g1_pin 11 | ||
+ | #define bp0 4 | ||
+ | |||
+ | #define r2_pin 10 | ||
+ | #define b2_pin 9 | ||
+ | #define g2_pin 8 | ||
+ | #define bp2 3 | ||
+ | |||
+ | #define r3_pin 7 | ||
+ | #define b3_pin 6 | ||
+ | #define g3_pin 5 | ||
+ | #define bp3 2 | ||
+ | |||
+ | #define validation A0 | ||
+ | |||
+ | unsigned long previousMillis = 0; | ||
+ | unsigned long previousMillis2 = 0; | ||
+ | int i =0; | ||
+ | |||
+ | int val1 =0; | ||
+ | int val2 =0; | ||
+ | int val3 =0; | ||
+ | |||
+ | const byte COLOR_BLACK = 0b000; | ||
+ | const byte COLOR_RED = 0b100; | ||
+ | const byte COLOR_GREEN = 0b010; | ||
+ | const byte COLOR_BLUE = 0b001; | ||
+ | const byte COLOR_MAGENTA = 0b101; | ||
+ | const byte COLOR_CYAN = 0b011; | ||
+ | const byte COLOR_YELLOW = 0b110; | ||
+ | const byte COLOR_WHITE = 0b111; | ||
+ | byte table[7] = {COLOR_RED,COLOR_GREEN,COLOR_BLUE,COLOR_MAGENTA,COLOR_CYAN,COLOR_YELLOW,COLOR_WHITE}; | ||
+ | void setup() { | ||
+ | // put your setup code here, to run once: | ||
+ | Serial.begin(9600); | ||
+ | pinMode(b1_pin, OUTPUT); | ||
+ | pinMode(g1_pin, OUTPUT); | ||
+ | pinMode(r1_pin, OUTPUT); | ||
+ | pinMode(bp0, INPUT); | ||
+ | |||
+ | pinMode(b2_pin, OUTPUT); | ||
+ | pinMode(g2_pin, OUTPUT); | ||
+ | pinMode(r2_pin, OUTPUT); | ||
+ | pinMode(bp2, INPUT); | ||
+ | |||
+ | |||
+ | pinMode(b3_pin, OUTPUT); | ||
+ | pinMode(g3_pin, OUTPUT); | ||
+ | pinMode(r3_pin, OUTPUT); | ||
+ | pinMode(bp3, INPUT); | ||
+ | pinMode(validation, INPUT); | ||
+ | } | ||
+ | |||
+ | void displayColor1(byte color) { | ||
+ | |||
+ | // Version anode commune | ||
+ | digitalWrite(r1_pin, !bitRead(color, 2)); | ||
+ | digitalWrite(g1_pin, !bitRead(color, 1)); | ||
+ | digitalWrite(b1_pin, !bitRead(color, 0)); | ||
+ | |||
+ | } | ||
+ | |||
+ | void displayColor2(byte color) { | ||
+ | |||
+ | // Version anode commune | ||
+ | digitalWrite(r2_pin, !bitRead(color, 2)); | ||
+ | digitalWrite(g2_pin, !bitRead(color, 1)); | ||
+ | digitalWrite(b2_pin, !bitRead(color, 0)); | ||
+ | |||
+ | } | ||
+ | |||
+ | void displayColor3(byte color) { | ||
+ | |||
+ | // Version anode commune | ||
+ | digitalWrite(r3_pin, !bitRead(color, 2)); | ||
+ | digitalWrite(g3_pin, !bitRead(color, 1)); | ||
+ | digitalWrite(b3_pin, !bitRead(color, 0)); | ||
+ | |||
+ | } | ||
+ | void loop() { | ||
+ | // put your main code here, to run repeatedly: | ||
+ | // displayColor1(table[1]); | ||
+ | if( digitalRead(bp0) && millis() - previousMillis2 > 1000 ) | ||
+ | { | ||
+ | |||
+ | displayColor1(table[i]); | ||
+ | i=i+1; | ||
+ | previousMillis2 = millis(); | ||
+ | if (table[i] == COLOR_BLUE) | ||
+ | { | ||
+ | Serial.println("labyrinthe ok"); | ||
+ | val1 = 1; | ||
+ | } | ||
+ | |||
+ | if( i >= 7) | ||
+ | { | ||
+ | i= 0; | ||
+ | } | ||
+ | |||
+ | |||
+ | } | ||
+ | |||
+ | if( digitalRead(bp2) && millis() - previousMillis2 > 1000 ) | ||
+ | { | ||
+ | |||
+ | displayColor2(table[i]); | ||
+ | i=i+1; | ||
+ | previousMillis2 = millis(); | ||
+ | |||
+ | if (table[i]== COLOR_GREEN) | ||
+ | { | ||
+ | Serial.println("cesar ok"); | ||
+ | val2=1; | ||
+ | } | ||
+ | if( i >= 7) | ||
+ | { | ||
+ | i= 0; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | if( digitalRead(bp3) && millis() - previousMillis2 > 1000 ) | ||
+ | { | ||
+ | |||
+ | displayColor3(table[i]); | ||
+ | i=i+1; | ||
+ | previousMillis2 = millis(); | ||
+ | |||
+ | if (table[i]== COLOR_CYAN) | ||
+ | { | ||
+ | Serial.println("periodique ok"); | ||
+ | val3 = 1; | ||
+ | } | ||
+ | |||
+ | if( i >= 7) | ||
+ | { | ||
+ | i= 0; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if( val1 && val2 && val3) | ||
+ | { | ||
+ | displayColor1(COLOR_BLUE); | ||
+ | displayColor2(COLOR_BLUE); | ||
+ | displayColor3(COLOR_BLUE); | ||
+ | } | ||
+ | |||
+ | if(val1 && val2 && val3 && (bp0 || bp2 || bp3)) | ||
+ | { | ||
+ | |||
+ | val1 = 0; | ||
+ | val2 = 0; | ||
+ | val3 = 0; | ||
+ | } | ||
+ | |||
+ | if (analogRead(validation) == 1) | ||
+ | { | ||
+ | Serial.println("morse ok"); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | ///////////////////////////////////////////////////////////////////////////////////// | ||
+ | |||
+ | Code pour le Morse : | ||
+ | |||
+ | #define green D2 | ||
+ | #define b D1 | ||
+ | #define g D3 | ||
+ | #define r D4 | ||
+ | |||
+ | void setup() { | ||
+ | // put your setup code here, to run once: | ||
+ | pinMode(LED_BUILTIN, OUTPUT); | ||
+ | Serial.begin(9600); | ||
+ | pinMode(green, OUTPUT); | ||
+ | pinMode(b, OUTPUT); | ||
+ | pinMode(g, OUTPUT); | ||
+ | pinMode(r, OUTPUT); | ||
+ | } | ||
+ | |||
+ | /* | ||
+ | |||
+ | }/ | ||
+ | |||
+ | void loop() { | ||
+ | |||
+ | digitalWrite(LED_BUILTIN, LOW); // Arduino: turn the LED on (HIGH) | ||
+ | digitalWrite(green, LOW); | ||
+ | |||
+ | digitalWrite(b, HIGH); | ||
+ | digitalWrite(r, LOW); | ||
+ | digitalWrite(g, LOW); | ||
+ | |||
+ | Serial.println("low"); | ||
+ | delay(1000); | ||
+ | digitalWrite(LED_BUILTIN, HIGH); // Arduino: turn the LED on (HIGH) | ||
+ | digitalWrite(green, HIGH); | ||
+ | |||
+ | digitalWrite(b, HIGH); | ||
+ | digitalWrite(r, HIGH); | ||
+ | digitalWrite(g, HIGH); | ||
+ | |||
+ | Serial.println("high"); | ||
+ | delay(1000); | ||
+ | //digitalWrite(D4, LOW); | ||
+ | //digitalWrite(BLU, HIGH); | ||
+ | |||
+ | //delay(1000); | ||
+ | //digitalWrite(green, LOW); | ||
+ | |||
+ | / digitalWrite(GND, LOW); | ||
+ | //digitalWrite(RED, LOW); | ||
+ | //digitalWrite(GRN, HIGH); | ||
+ | //digitalWrite(BLU, LOW); | ||
+ | |||
+ | delay(1000); | ||
+ | Serial.println("test"); | ||
+ | digitalWrite(GND, HIGH); | ||
+ | // digitalWrite(RED, LOW); | ||
+ | //// digitalWrite(GRN, LOW); | ||
+ | // digitalWrite(BLU, HIGH); | ||
+ | |||
+ | delay(1000);*/ | ||
+ | |||
+ | |||
+ | } | ||
+ | #define r1_pin 13 | ||
+ | #define b1_pin 12 | ||
+ | #define g1_pin 11 | ||
+ | #define bp0 4 | ||
+ | |||
+ | #define r2_pin 10 | ||
+ | #define b2_pin 9 | ||
+ | #define g2_pin 8 | ||
+ | #define bp2 3 | ||
+ | |||
+ | #define r3_pin 7 | ||
+ | #define b3_pin 6 | ||
+ | #define g3_pin 5 | ||
+ | #define bp3 2 | ||
+ | |||
+ | #define validation A0 | ||
+ | |||
+ | unsigned long previousMillis = 0; | ||
+ | unsigned long previousMillis2 = 0; | ||
+ | int i =0; | ||
+ | |||
+ | int val1 =0; | ||
+ | int val2 =0; | ||
+ | int val3 =0; | ||
+ | |||
+ | const byte COLOR_BLACK = 0b000; | ||
+ | const byte COLOR_RED = 0b100; | ||
+ | const byte COLOR_GREEN = 0b010; | ||
+ | const byte COLOR_BLUE = 0b001; | ||
+ | const byte COLOR_MAGENTA = 0b101; | ||
+ | const byte COLOR_CYAN = 0b011; | ||
+ | const byte COLOR_YELLOW = 0b110; | ||
+ | const byte COLOR_WHITE = 0b111; | ||
+ | byte table[7] = {COLOR_RED,COLOR_GREEN,COLOR_BLUE,COLOR_MAGENTA,COLOR_CYAN,COLOR_YELLOW,COLOR_WHITE}; | ||
+ | void setup() { | ||
+ | // put your setup code here, to run once: | ||
+ | Serial.begin(9600); | ||
+ | pinMode(b1_pin, OUTPUT); | ||
+ | pinMode(g1_pin, OUTPUT); | ||
+ | pinMode(r1_pin, OUTPUT); | ||
+ | pinMode(bp0, INPUT); | ||
+ | |||
+ | pinMode(b2_pin, OUTPUT); | ||
+ | pinMode(g2_pin, OUTPUT); | ||
+ | pinMode(r2_pin, OUTPUT); | ||
+ | pinMode(bp2, INPUT); | ||
+ | |||
+ | |||
+ | pinMode(b3_pin, OUTPUT); | ||
+ | pinMode(g3_pin, OUTPUT); | ||
+ | pinMode(r3_pin, OUTPUT); | ||
+ | pinMode(bp3, INPUT); | ||
+ | pinMode(validation, INPUT); | ||
+ | } | ||
+ | |||
+ | void displayColor1(byte color) { | ||
+ | |||
+ | // Version anode commune | ||
+ | digitalWrite(r1_pin, !bitRead(color, 2)); | ||
+ | digitalWrite(g1_pin, !bitRead(color, 1)); | ||
+ | digitalWrite(b1_pin, !bitRead(color, 0)); | ||
+ | |||
+ | } | ||
+ | |||
+ | void displayColor2(byte color) { | ||
+ | |||
+ | // Version anode commune | ||
+ | digitalWrite(r2_pin, !bitRead(color, 2)); | ||
+ | digitalWrite(g2_pin, !bitRead(color, 1)); | ||
+ | digitalWrite(b2_pin, !bitRead(color, 0)); | ||
+ | |||
+ | } | ||
+ | |||
+ | void displayColor3(byte color) { | ||
+ | |||
+ | // Version anode commune | ||
+ | digitalWrite(r3_pin, !bitRead(color, 2)); | ||
+ | digitalWrite(g3_pin, !bitRead(color, 1)); | ||
+ | digitalWrite(b3_pin, !bitRead(color, 0)); | ||
+ | |||
+ | } | ||
+ | void loop() { | ||
+ | // put your main code here, to run repeatedly: | ||
+ | // displayColor1(table[1]); | ||
+ | if( digitalRead(bp0) && millis() - previousMillis2 > 1000 ) | ||
+ | { | ||
+ | |||
+ | displayColor1(table[i]); | ||
+ | i=i+1; | ||
+ | previousMillis2 = millis(); | ||
+ | if (table[i] == COLOR_BLUE) | ||
+ | { | ||
+ | Serial.println("labyrinthe ok"); | ||
+ | val1 = 1; | ||
+ | } | ||
+ | |||
+ | if( i >= 7) | ||
+ | { | ||
+ | i= 0; | ||
+ | } | ||
+ | ... (63 lignes restantes) | ||
+ | Réduire | ||
+ | message.txt | ||
+ | 3 Ko | ||
+ | code 1 | ||
+ | #define morse_pin D2 | ||
+ | #define b_pin D1 | ||
+ | #define g_pin D3 | ||
+ | #define r_pin D4 | ||
+ | #define bp1 D5 | ||
+ | #define val A0 | ||
+ | | ||
+ | #define morse_pin D2 | ||
+ | #define b_pin D1 | ||
+ | #define g_pin D3 | ||
+ | #define r_pin D4 | ||
+ | #define bp1 D5 | ||
+ | #define val A0 | ||
+ | |||
+ | unsigned long previousMillis = 0; | ||
+ | unsigned long previousMillis2 = 0; | ||
+ | int i =0; | ||
+ | |||
+ | /* Couleurs (format RGB) */ | ||
+ | const byte COLOR_BLACK = 0b000; | ||
+ | const byte COLOR_RED = 0b100; | ||
+ | const byte COLOR_GREEN = 0b010; | ||
+ | const byte COLOR_BLUE = 0b001; | ||
+ | const byte COLOR_MAGENTA = 0b101; | ||
+ | const byte COLOR_CYAN = 0b011; | ||
+ | const byte COLOR_YELLOW = 0b110; | ||
+ | const byte COLOR_WHITE = 0b111; | ||
+ | |||
+ | byte table[7] = {COLOR_RED,COLOR_GREEN,COLOR_BLUE,COLOR_MAGENTA,COLOR_CYAN,COLOR_YELLOW,COLOR_WHITE}; | ||
+ | |||
+ | void setup() { | ||
+ | // put your setup code here, to run once: | ||
+ | |||
+ | |||
+ | |||
+ | Serial.begin(9600); | ||
+ | pinMode(morse_pin, OUTPUT); | ||
+ | pinMode(b_pin, OUTPUT); | ||
+ | pinMode(g_pin, OUTPUT); | ||
+ | pinMode(r_pin, OUTPUT); | ||
+ | pinMode(bp1, INPUT); | ||
+ | pinMode(val, OUTPUT); | ||
+ | } | ||
+ | |||
+ | // ##########################################################################Switch Color) | ||
+ | void displayColor(byte color) { | ||
+ | |||
+ | // Version anode commune | ||
+ | digitalWrite(r_pin, !bitRead(color, 2)); | ||
+ | digitalWrite(g_pin, !bitRead(color, 1)); | ||
+ | digitalWrite(b_pin, !bitRead(color, 0)); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // ##########################################################################blue victory (Morse Switch) | ||
+ | |||
+ | if ( (0 < millis()-previousMillis) && (millis()-previousMillis< 3000) ){ | ||
+ | digitalWrite(morse_pin, HIGH); | ||
+ | |||
+ | } | ||
+ | if ( ( 3000 < millis()-previousMillis) && (millis()-previousMillis< 3500) ){ | ||
+ | digitalWrite(morse_pin, LOW); | ||
+ | } | ||
+ | if ( (3500 < millis()-previousMillis) && (millis()-previousMillis<4000) ){ | ||
+ | digitalWrite(morse_pin, HIGH); | ||
+ | |||
+ | } | ||
+ | if ( (4000 < millis()-previousMillis) && (millis()-previousMillis< 4500) ){ | ||
+ | digitalWrite(morse_pin, LOW); | ||
+ | |||
+ | } | ||
+ | if ( (4500 < millis()-previousMillis) && (millis()-previousMillis< 5000) ){ | ||
+ | digitalWrite(morse_pin, HIGH); | ||
+ | } | ||
+ | if ( (5000 < millis()-previousMillis) && (millis()-previousMillis< 5500) ){ | ||
+ | digitalWrite(morse_pin, LOW); | ||
+ | } | ||
+ | if ( (5500 < millis()-previousMillis) && (millis()-previousMillis< 6000) ){ | ||
+ | digitalWrite(morse_pin, HIGH); | ||
+ | } | ||
+ | if ( (6000 < millis()-previousMillis) && (millis()-previousMillis< 6500)){ | ||
+ | digitalWrite(morse_pin, LOW); | ||
+ | } | ||
+ | |||
+ | if (millis()-previousMillis > 8000){ | ||
+ | |||
+ | previousMillis = millis(); | ||
+ | } | ||
+ | |||
+ | |||
+ | // ##########################################################################blue victory (button Color) | ||
+ | if( digitalRead(bp1) && millis() - previousMillis2 > 1000 ) | ||
+ | { | ||
+ | |||
+ | displayColor(table[i]); | ||
+ | i=i+1; | ||
+ | previousMillis2 = millis(); | ||
+ | |||
+ | if (table[i]== COLOR_GREEN) | ||
+ | { | ||
+ | Serial.println("morse okkkkkkk"); | ||
+ | analogWrite(val, HIGH); | ||
+ | |||
+ | } | ||
+ | |||
+ | if( i >= 7) | ||
+ | { | ||
+ | i= 0; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
} | } | ||
Ligne 128 : | Ligne 587 : | ||
[[Catégorie:Enib2023]] | [[Catégorie:Enib2023]] | ||
+ | |||
+ | [[Catégorie:Arduino]] |
Version actuelle datée du 15 janvier 2024 à 15:59
photo de l'équipe
Que fait ce projet ?
Ce projet est une combinaison de 4 énigmes.
Liste des parties
- Partie 1 Tableau périodique :
Le but était de sélectionner 2 valeurs grâce à un potentiomètre. Ces valeurs se devinaient grâce à deux matériaux coller sur la plaque et leur nombre atomique trouvé sur le tableau périodique
- Partie 2 Corde César
- Partie 3 Code Morse
- Partie 4 labyrinthe
Code
Code pour la partie Tableau périodique (Il y a une librairie à télécharger) : #include <SPI.h> #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels #define valPotReader A0 #define buttonPer D8 #define Win D7 #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) #define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); int valPot; int pos=0; int resultPer[2]={0,0}; int solPer[2] = {29,13}; bool buttonPerState=0; bool prevButtonPerState=0; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(valPotReader,INPUT); pinMode(buttonPer,INPUT); pinMode(Win,OUTPUT); // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1306 allocation failed")); for(;;); // Don't proceed, loop forever } // Show initial display buffer contents on the screen -- // the library initializes this with an Adafruit splash screen. display.display(); delay(2000); // Pause for 2 seconds // Clear the buffer display.clearDisplay(); } void loop() { // put your main code here, to run repeatedly: valPot=round((float(analogRead(valPotReader))/1024)*118); show(); if(isPressed()){ Serial.println("oui"); int i = pos%2; pos=pos+1; resultPer[i]=valPot; show(); }; Serial.println((resultPer[0]==solPer[0] && resultPer[1]==solPer[1])); if(resultPer[0]==solPer[0] && resultPer[1]==solPer[1]) { Serial.print("Win"); digitalWrite(Win,HIGH); }else{digitalWrite(Win,LOW);} } void show(){ display.clearDisplay(); display.setTextSize(4); display.setTextColor(SSD1306_WHITE); display.setCursor(16,16); display.print(valPot); display.setTextSize(1); display.setCursor(80,53); display.print(resultPer[0]); display.print('|'); display.print(resultPer[1]); display.display(); } bool isPressed(){ buttonPerState=digitalRead(buttonPer); if(prevButtonPerState==0 && buttonPerState==1){ prevButtonPerState=buttonPerState; return 1; } else{ prevButtonPerState=buttonPerState; return 0; } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// Code pour sélection de la réponse (Rouge ou Vert ou Bleu) : #define r1_pin 13 #define b1_pin 12 #define g1_pin 11 #define bp0 4 #define r2_pin 10 #define b2_pin 9 #define g2_pin 8 #define bp2 3 #define r3_pin 7 #define b3_pin 6 #define g3_pin 5 #define bp3 2 #define validation A0 unsigned long previousMillis = 0; unsigned long previousMillis2 = 0; int i =0; int val1 =0; int val2 =0; int val3 =0; const byte COLOR_BLACK = 0b000; const byte COLOR_RED = 0b100; const byte COLOR_GREEN = 0b010; const byte COLOR_BLUE = 0b001; const byte COLOR_MAGENTA = 0b101; const byte COLOR_CYAN = 0b011; const byte COLOR_YELLOW = 0b110; const byte COLOR_WHITE = 0b111; byte table[7] = {COLOR_RED,COLOR_GREEN,COLOR_BLUE,COLOR_MAGENTA,COLOR_CYAN,COLOR_YELLOW,COLOR_WHITE}; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(b1_pin, OUTPUT); pinMode(g1_pin, OUTPUT); pinMode(r1_pin, OUTPUT); pinMode(bp0, INPUT); pinMode(b2_pin, OUTPUT); pinMode(g2_pin, OUTPUT); pinMode(r2_pin, OUTPUT); pinMode(bp2, INPUT); pinMode(b3_pin, OUTPUT); pinMode(g3_pin, OUTPUT); pinMode(r3_pin, OUTPUT); pinMode(bp3, INPUT); pinMode(validation, INPUT); } void displayColor1(byte color) { // Version anode commune digitalWrite(r1_pin, !bitRead(color, 2)); digitalWrite(g1_pin, !bitRead(color, 1)); digitalWrite(b1_pin, !bitRead(color, 0)); } void displayColor2(byte color) { // Version anode commune digitalWrite(r2_pin, !bitRead(color, 2)); digitalWrite(g2_pin, !bitRead(color, 1)); digitalWrite(b2_pin, !bitRead(color, 0)); } void displayColor3(byte color) { // Version anode commune digitalWrite(r3_pin, !bitRead(color, 2)); digitalWrite(g3_pin, !bitRead(color, 1)); digitalWrite(b3_pin, !bitRead(color, 0)); } void loop() { // put your main code here, to run repeatedly: // displayColor1(table[1]); if( digitalRead(bp0) && millis() - previousMillis2 > 1000 ) { displayColor1(table[i]); i=i+1; previousMillis2 = millis(); if (table[i] == COLOR_BLUE) { Serial.println("labyrinthe ok"); val1 = 1; } if( i >= 7) { i= 0; } } if( digitalRead(bp2) && millis() - previousMillis2 > 1000 ) { displayColor2(table[i]); i=i+1; previousMillis2 = millis(); if (table[i]== COLOR_GREEN) { Serial.println("cesar ok"); val2=1; } if( i >= 7) { i= 0; } } if( digitalRead(bp3) && millis() - previousMillis2 > 1000 ) { displayColor3(table[i]); i=i+1; previousMillis2 = millis(); if (table[i]== COLOR_CYAN) { Serial.println("periodique ok"); val3 = 1; } if( i >= 7) { i= 0; } } if( val1 && val2 && val3) { displayColor1(COLOR_BLUE); displayColor2(COLOR_BLUE); displayColor3(COLOR_BLUE); } if(val1 && val2 && val3 && (bp0 || bp2 || bp3)) { val1 = 0; val2 = 0; val3 = 0; } if (analogRead(validation) == 1) { Serial.println("morse ok"); } } ///////////////////////////////////////////////////////////////////////////////////// Code pour le Morse : #define green D2 #define b D1 #define g D3 #define r D4 void setup() { // put your setup code here, to run once: pinMode(LED_BUILTIN, OUTPUT); Serial.begin(9600); pinMode(green, OUTPUT); pinMode(b, OUTPUT); pinMode(g, OUTPUT); pinMode(r, OUTPUT); } /* }/ void loop() { digitalWrite(LED_BUILTIN, LOW); // Arduino: turn the LED on (HIGH) digitalWrite(green, LOW); digitalWrite(b, HIGH); digitalWrite(r, LOW); digitalWrite(g, LOW); Serial.println("low"); delay(1000); digitalWrite(LED_BUILTIN, HIGH); // Arduino: turn the LED on (HIGH) digitalWrite(green, HIGH); digitalWrite(b, HIGH); digitalWrite(r, HIGH); digitalWrite(g, HIGH); Serial.println("high"); delay(1000); //digitalWrite(D4, LOW); //digitalWrite(BLU, HIGH); //delay(1000); //digitalWrite(green, LOW); / digitalWrite(GND, LOW); //digitalWrite(RED, LOW); //digitalWrite(GRN, HIGH); //digitalWrite(BLU, LOW); delay(1000); Serial.println("test"); digitalWrite(GND, HIGH); // digitalWrite(RED, LOW); //// digitalWrite(GRN, LOW); // digitalWrite(BLU, HIGH); delay(1000);*/ } #define r1_pin 13 #define b1_pin 12 #define g1_pin 11 #define bp0 4 #define r2_pin 10 #define b2_pin 9 #define g2_pin 8 #define bp2 3 #define r3_pin 7 #define b3_pin 6 #define g3_pin 5 #define bp3 2 #define validation A0 unsigned long previousMillis = 0; unsigned long previousMillis2 = 0; int i =0; int val1 =0; int val2 =0; int val3 =0; const byte COLOR_BLACK = 0b000; const byte COLOR_RED = 0b100; const byte COLOR_GREEN = 0b010; const byte COLOR_BLUE = 0b001; const byte COLOR_MAGENTA = 0b101; const byte COLOR_CYAN = 0b011; const byte COLOR_YELLOW = 0b110; const byte COLOR_WHITE = 0b111; byte table[7] = {COLOR_RED,COLOR_GREEN,COLOR_BLUE,COLOR_MAGENTA,COLOR_CYAN,COLOR_YELLOW,COLOR_WHITE}; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(b1_pin, OUTPUT); pinMode(g1_pin, OUTPUT); pinMode(r1_pin, OUTPUT); pinMode(bp0, INPUT); pinMode(b2_pin, OUTPUT); pinMode(g2_pin, OUTPUT); pinMode(r2_pin, OUTPUT); pinMode(bp2, INPUT); pinMode(b3_pin, OUTPUT); pinMode(g3_pin, OUTPUT); pinMode(r3_pin, OUTPUT); pinMode(bp3, INPUT); pinMode(validation, INPUT); } void displayColor1(byte color) { // Version anode commune digitalWrite(r1_pin, !bitRead(color, 2)); digitalWrite(g1_pin, !bitRead(color, 1)); digitalWrite(b1_pin, !bitRead(color, 0)); } void displayColor2(byte color) { // Version anode commune digitalWrite(r2_pin, !bitRead(color, 2)); digitalWrite(g2_pin, !bitRead(color, 1)); digitalWrite(b2_pin, !bitRead(color, 0)); } void displayColor3(byte color) { // Version anode commune digitalWrite(r3_pin, !bitRead(color, 2)); digitalWrite(g3_pin, !bitRead(color, 1)); digitalWrite(b3_pin, !bitRead(color, 0)); } void loop() { // put your main code here, to run repeatedly: // displayColor1(table[1]); if( digitalRead(bp0) && millis() - previousMillis2 > 1000 ) { displayColor1(table[i]); i=i+1; previousMillis2 = millis(); if (table[i] == COLOR_BLUE) { Serial.println("labyrinthe ok"); val1 = 1; } if( i >= 7) { i= 0; } ... (63 lignes restantes) Réduire message.txt 3 Ko code 1 #define morse_pin D2 #define b_pin D1 #define g_pin D3 #define r_pin D4 #define bp1 D5 #define val A0 #define morse_pin D2 #define b_pin D1 #define g_pin D3 #define r_pin D4 #define bp1 D5 #define val A0 unsigned long previousMillis = 0; unsigned long previousMillis2 = 0; int i =0; /* Couleurs (format RGB) */ const byte COLOR_BLACK = 0b000; const byte COLOR_RED = 0b100; const byte COLOR_GREEN = 0b010; const byte COLOR_BLUE = 0b001; const byte COLOR_MAGENTA = 0b101; const byte COLOR_CYAN = 0b011; const byte COLOR_YELLOW = 0b110; const byte COLOR_WHITE = 0b111; byte table[7] = {COLOR_RED,COLOR_GREEN,COLOR_BLUE,COLOR_MAGENTA,COLOR_CYAN,COLOR_YELLOW,COLOR_WHITE}; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(morse_pin, OUTPUT); pinMode(b_pin, OUTPUT); pinMode(g_pin, OUTPUT); pinMode(r_pin, OUTPUT); pinMode(bp1, INPUT); pinMode(val, OUTPUT); } // ##########################################################################Switch Color) void displayColor(byte color) { // Version anode commune digitalWrite(r_pin, !bitRead(color, 2)); digitalWrite(g_pin, !bitRead(color, 1)); digitalWrite(b_pin, !bitRead(color, 0)); } void loop() { // ##########################################################################blue victory (Morse Switch) if ( (0 < millis()-previousMillis) && (millis()-previousMillis< 3000) ){ digitalWrite(morse_pin, HIGH); } if ( ( 3000 < millis()-previousMillis) && (millis()-previousMillis< 3500) ){ digitalWrite(morse_pin, LOW); } if ( (3500 < millis()-previousMillis) && (millis()-previousMillis<4000) ){ digitalWrite(morse_pin, HIGH); } if ( (4000 < millis()-previousMillis) && (millis()-previousMillis< 4500) ){ digitalWrite(morse_pin, LOW); } if ( (4500 < millis()-previousMillis) && (millis()-previousMillis< 5000) ){ digitalWrite(morse_pin, HIGH); } if ( (5000 < millis()-previousMillis) && (millis()-previousMillis< 5500) ){ digitalWrite(morse_pin, LOW); } if ( (5500 < millis()-previousMillis) && (millis()-previousMillis< 6000) ){ digitalWrite(morse_pin, HIGH); } if ( (6000 < millis()-previousMillis) && (millis()-previousMillis< 6500)){ digitalWrite(morse_pin, LOW); } if (millis()-previousMillis > 8000){ previousMillis = millis(); } // ##########################################################################blue victory (button Color) if( digitalRead(bp1) && millis() - previousMillis2 > 1000 ) { displayColor(table[i]); i=i+1; previousMillis2 = millis(); if (table[i]== COLOR_GREEN) { Serial.println("morse okkkkkkk"); analogWrite(val, HIGH); } if( i >= 7) { i= 0; } } }