ENIB 2022 - groupe D : Tirolaser : Différence entre versions
(→Photo de l'équipe) |
(→Photo de l'équipe) |
||
Ligne 16 : | Ligne 16 : | ||
\__ / /nn_) ( /nn__\_) ( | \__ / /nn_) ( /nn__\_) ( | ||
`--' /nn__\ /nn__\ | `--' /nn__\ /nn__\ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Que fait ce projet ? == | ==Que fait ce projet ? == |
Version du 18 janvier 2022 à 17:52
Sommaire
Photo de l'équipe
,-. __ ,' `---.___.---' `. ,' ,- `-._ ,' / \ ,\/ / \\ )`._)>) | \\ `>,' _ \ / |\ ) \ | | | |\\ . , / \ | `. | | )) \`. \`-' )-| `. | /(( \ `-` a` _/ ;\ _ )`-.___.--\ / `' `._ ,' \`j`.__/ \ `. \ / , ,' _)\ /` _) ( \ / \__ / /nn_) ( /nn__\_) ( `--' /nn__\ /nn__\
Que fait ce projet ?
C'est un stand de tir avec un pistolet laser.
Liste des composants
- 1 boite en bois
- 1 plaque de carton
- 4 LEDs RGB
- Une Arduino Nano et son câble d'alimentation USB 5V
- Une diode laser
- 3 Piles AA + un rack de 3 piles
- Le boitier de pistolet fait par imprimante 3D
- 2 Photorésistances
- Des câbles
- Un plaque Labdec
Comment refaire ce projet?
Débrouillez vous
Code
#define LDR1 A1 // composante photorésistance sur la pin A1 #define LDR2 A2 // composante photorésistance sur la pin A1 #define LDR3 A3 // composante photorésistance sur la pin A1 #define LDR4 A4 // composante photorésistance sur la pin A1 #define LDR5 A5 // composante photorésistance sur la pin A1 int value_LDR1; int value_LDR2; int value_LDR3; int value_LDR4; int value_LDR5; int target; int new_target; int score; int miss; long T; unsigned long previousMicros_target; unsigned long previousMillis_score; int actual_score; int previous_score; int red_light_pin1 = 2; int green_light_pin1 = 3; int red_light_pin2 = 11; int green_light_pin2 = 10; int green_on; int orange_on; int red_on; void setup() { randomSeed(analogRead(7)); Serial.begin(9600); pinMode(LDR1, INPUT); pinMode(LDR2, INPUT); pinMode(LDR3, INPUT); pinMode(LDR4, INPUT); pinMode(LDR5, INPUT); pinMode(red_light_pin1, OUTPUT); pinMode(green_light_pin1, OUTPUT); pinMode(red_light_pin2, OUTPUT); pinMode(green_light_pin2, OUTPUT); value_LDR1 = 0; green_on = 0; orange_on = 0; red_on = 0; T = 1000; previousMicros_target = 0; previousMillis_score = 0; score = 0; } void loop() { if (target == 0 or new_target == 1){ target = random(1,3); new_target = 0; } unsigned long currentMicros = millis(); //attribution du temps d'éxécution du programme à une variable value_LDR1 = analogRead(LDR1); value_LDR2 = analogRead(LDR2); value_LDR3 = analogRead(LDR3); value_LDR4 = analogRead(LDR4); value_LDR5 = analogRead(LDR5); if (new_target == 0){ if (currentMicros - previousMicros_target >= T and green_on == 0 and orange_on == 0 and red_on == 0){ if (target == 1){ RGB_color_1(255,0); RGB_color_2(255,255); } else if (target == 2){ RGB_color_2(255,0); RGB_color_1(255,255); } previousMicros_target = currentMicros; green_on = 1; } if (currentMicros - previousMicros_target >= T and currentMicros - previousMicros_target <= 2*T and green_on == 1 and orange_on == 0 and red_on == 0){ if (target == 1){ RGB_color_1(0,100); } else if (target == 2){ RGB_color_2(0,100); } green_on = 0; orange_on = 1; } if (currentMicros - previousMicros_target >= 2*T and currentMicros - previousMicros_target <= 3*T and green_on == 0 and orange_on == 1 and red_on == 0){ if (target == 1){ RGB_color_1(0,255); } else if (target == 2){ RGB_color_2(0,255); } orange_on = 0; red_on = 1; } if (currentMicros - previousMicros_target >= 3*T and currentMicros - previousMicros_target <= 4*T and green_on == 0 and orange_on == 0 and red_on == 1){ if (target == 1){ RGB_color_1(255,255); miss = miss + 1; new_target = 1; } else if (target == 2){ RGB_color_2(255,255); miss = miss + 1; new_target = 1; } red_on = 0; } } if (target == 1 and value_LDR1 > 950 and currentMicros - previousMillis_score >= 100){ RGB_color_1(255,255); new_target = 1; green_on = 0; orange_on = 0; red_on = 0; score = score + 1; previousMillis_score = currentMicros; } else if (target == 2 and value_LDR2 > 950 and currentMicros - previousMillis_score >= 100){ RGB_color_1(255,255); new_target = 1; green_on = 0; orange_on = 0; red_on = 0; score = score + 1; previousMillis_score = currentMicros; } } void RGB_color_1(int red_light_value1, int green_light_value1) { analogWrite(red_light_pin1, red_light_value1); analogWrite(green_light_pin1, green_light_value1); } void RGB_color_2(int red_light_value2, int green_light_value2) { analogWrite(red_light_pin2, red_light_value2); analogWrite(green_light_pin2, green_light_value2); } //void RGB_color_3(int red_light_value3, int green_light_value3, int blue_light_value3) // { // analogWrite(red_light_pin3, red_light_value3); // analogWrite(green_light_pin3, green_light_value3); // analogWrite(blue_light_pin3, blue_light_value3); //} //void RGB_color_4(int red_light_value4, int green_light_value4, int blue_light_value4) // { // analogWrite(red_light_pin4, red_light_value4); // analogWrite(green_light_pin4, green_light_value4); // analogWrite(blue_light_pin4, blue_light_value4); //} //void RGB_color_5(int red_light_value5, int green_light_value5, int blue_light_value5) // { // analogWrite(red_light_pin5, red_light_value5); // analogWrite(green_light_pin5, green_light_value5); // analogWrite(blue_light_pin5, blue_light_value5); //}