Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int z1; //Indice 1 = Table Gauche
- int z1precedent;
- int z1variation;
- int zmax = 0;
- int z2; //Indice 2 = Table Droite
- int z2precedent;
- int z2variation;
- int z3; //Indice 3 = Filet
- int z3precedent;
- int z3variation;
- int z3max = 0;
- int PinLedGauche = 2;
- int PinLedDroite = 3;
- int test = 0;
- unsigned long t1max;
- unsigned long t2max;
- unsigned long timer;
- String Serveur;
- String JoueurRenvoieBalle;
- void setup()
- {
- Serial.begin(9600); // sets the serial port to 9600
- pinMode(PinLedGauche, OUTPUT);
- pinMode(PinLedDroite, OUTPUT);
- digitalWrite(PinLedGauche, LOW);
- digitalWrite(PinLedDroite, LOW);
- Serveur = "Gauche";
- }
- void loop()
- {
- //SERVICE
- switch(Serveur)
- {
- case "Gauche":
- DetectionTable();
- timerService = millis();
- while(millis() - timerService < 10000)
- {
- if(DetectionTable() = "Droite");
- {
- JOUEUR DROITE +1; //JOUEUR GAUCHE PERDU
- }
- if(DetectionTable() = "Gauche");
- {
- timerService = millis();
- while(millis() - timerService > 2000)
- {
- if(DetectionTable() = "Gauche")
- {
- JOUEUR DROITE +1; //JOUEUR GAUCHE PERDU
- }
- if(DetectionTable() = "Droite") //SERVICE REUSSI LE POINT CONTINU
- {
- //CODER ECHANGE JUSQU'A FAUTE D'UN JOUEUR
- }
- }
- }
- else
- {
- JOUEUR DROITE +1; //JOUEUR GAUCHE PERDU
- }
- }
- case "Droite":
- DetectionTable();
- timerService = millis();
- while(millis() - timerService < 10000)
- {
- if(DetectionTable() = "Gauche");
- {
- JOUEUR GAUCHE +1; //JOUEUR DROITE PERDU
- }
- if(DetectionTable() = "Droite");
- {
- timerService = millis();
- while(millis() - timerService > 2000)
- {
- if(DetectionTable() = "Droite")
- {
- JOUEUR GAUCHE +1; //JOUEUR DROITE PERDU
- }
- if(DetectionTable() = "Gauche") //SERVICE REUSSI LE POINT CONTINU
- {
- //CODER ECHANGE JUSQU'A FAUTE D'UN JOUEUR
- }
- }
- }
- }
- }
- String DetectionTable()
- {
- z1precedent = z1;
- z2precedent = z2;
- z3precedent = z3;
- z1 = analogRead(A0);
- z2 = analogRead(A1);
- z3 = analogRead(A2);
- z1variation = abs(z1 - z1precedent);
- z2variation = abs(z2 - z2precedent);
- z3variation = abs(z3 - z3precedent);
- if((z1variation) > 12 || (z2variation) > 12)
- {
- t1max = millis();
- while(millis() - t1max < 350)
- {
- if(z3variation > 10) // ON ETUDIE Z3 (FILET) QUE LORS DU SERVICE, IL FAUDRA RAJOUTER UN PARAMETRE A CETTE FONCTION
- {
- z3max += z3variation;
- }
- zmax += (z1variation - z2variation);
- z1precedent = z1;
- z2precedent = z2;
- z3precedent = z3;
- z1 = analogRead(A0);
- z2 = analogRead(A1);
- z3 = analogRead(A2);
- z1variation = abs(z1 - z1precedent);
- z2variation = abs(z2 - z2precedent);
- z3variation = abs(z3 - z3precedent);
- //Serial.println(z3max);
- if(zmax > 0)
- {
- digitalWrite(PinLedGauche, HIGH);
- digitalWrite(PinLedDroite, LOW);
- return "Gauche";
- }
- if(zmax <0)
- {
- digitalWrite(PinLedGauche, LOW);
- digitalWrite(PinLedDroite, HIGH);
- return "Droite";
- }
- if(z3max > 100)
- {
- return "Let";
- }
- else
- {
- return "Rien";
- }
- }
- }
- zmax = 0;
- z3max = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement