Salut !
Très beau début, hâte de voir la suite !
Très beau début, hâte de voir la suite !
Besoin de contacter un admin pour une proposition, une suggestion ou discuter d'un probleme ?
C'est ici : High_Cobra, AsPiC ou Pich
Cette section vous permet de consulter les contributions (messages, sujets et fichiers joints) d'un utilisateur. Vous ne pourrez voir que les contributions des zones auxquelles vous avez accès.
Voir les contributions MenuCitation de: AsPiC le Jeudi 27 Mai 2021, 10:40:04 AM
Pourquoi ne pas garder à l'identique mais réduit à ton échelle la partie haute qui présente une avancée et donc un renfort pour les sides comme sur la borne originale ?
https://gamoovernet.pixhotel.fr/pics_gamoovernet890px/20210527103948-AsPiC-01C507DD-3A4B-4303-A108-6C834586D125.jpeg
Citation de: ɐɹqoƆ‾ɥƃᴉH le Mercredi 26 Mai 2021, 21:07:19 PMJ'essaie, je veux les dénaturer le moins possible tout en les tronquant à mort.
Ton alignement est vraiment class, je trouve que t'as bien reproduit l'esthétique de tous les meubles d'origine !
Citation de: ɐɹqoƆ‾ɥƃᴉH le Mercredi 26 Mai 2021, 21:07:19 PMC'est ce que je pensais faire:
Au pire, tu peux peut-être réduire un peu le coté trop proéminent du haut pour que ça colle mieux au reste.
//-------------- LIBRAIRIES ----------------------//****************************************************************
#include <SevenSegmentAsciiMap.h> //
#include <SevenSegmentExtended.h> // Librairies pour les afficheurs 4 digits 7 segments
#include <SevenSegmentTM1637.h> //
#include "Arduino.h" //
#include "SoftwareSerial.h" // Librairies Dfmini
#include "DFRobotDFPlayerMini.h" //
#include <Adafruit_NeoPixel.h> // Librairie pour les leds
//-------------- DECLARATION MATOS ---------------//****************************************************************
SevenSegmentTM1637 TM1(24, 22); //afficheur du BAS déclaration -- CLK 24 -- DIO 22 --
SevenSegmentTM1637 TM2(28, 26); //afficheur du CENTRE déclaration -- CLK 28 -- DIO 26 --
SevenSegmentTM1637 TM3(32, 30); //afficheur du HAUT déclaration -- CLK 32 -- DIO 30 --
Adafruit_NeoPixel STRIP(8, 34, NEO_GRBW + NEO_KHZ800); // Bande led déclaration -- NBR LED 8 -- DIO 34 --
SoftwareSerial mySoftwareSerial(13, 12); // Dfmini déclaration -- RX 12 -- TX 13 -- DOIVENT ETRES PWR
DFRobotDFPlayerMini myDFPlayer; //
void printDetail(uint8_t type, int value); //
//------------- DECLARATION VARIAVLES -------------//***************************************************************
int Latence = 50; // Pour gérer le delay de l'arduino (multiple de 50 sinon ce sera la merde !!!!!)
int TempAFF = 0; // Temporaire pour les Afficheurs
int TempLED = 0; // Temporaire pour les Leds
int TempLEDBRILL = 0; int TempLEDBRILLAD = 0; // Tempoiraire scintillement Leds
int TempBONUS = 0; // Tempoiraire décompte bonus
int Highscore = 0; // Highscore
int Bille = 0; // Bille on bar
int Etape = 0; // Trou demandé
int Bonus = 0; // Variable bonus
int Score = 0; // variable Score
int BTNcredit = 0; // Bouton Credit
const int stepPinMotor1 = 5; // Step Moteur 1 -- PIN 5 --
const int dirPinMotor1 = 4; // Direction Moteur 1 -- PIN 4 --
int Motor1Bouge = 0;
int BttnMontMotor1 = 0; // Bouton Up Motor 1
int BttnDscdMotor1 = 0; // Bouton Down Motor 1
int Motor1 = 0; // Bougeage de Motor 1
int Amode = 1; // Boucle ATTRACK MODE
int Debutpartie = 0; // Initialisation de la partie après le crédit
int Initbarre = 0; // Initialisation Bonus et partie
int DescenteBarre = 0;// Pour que les barres aillent chercher une nouvelle bille
int MonteBarre = 0; // Pour que les barres remonteent
int Principale = 0; // Boucle principale avec bougeage des barres, bonus qui descent, billes qui passent dans un trou etc...
int Trou = 0; // Trou dans laquelle est tombé la Bille
int BonTrou = 0; // Boucle Bille dans le bon trou
int BadTrou = 0; // Boucle Bille dans le mauvais trou
int Gameover = 0; // Boucle Gamover
void setup() {
TM1.begin(); TM1.setPrintDelay(500); TM1.clear(); // Afficheur du BAS initialisation (début / brightness / RAZ)
TM2.begin(); TM2.setPrintDelay(500); TM2.clear(); // Afficheur du CENTRE initialisation
TM3.begin(); TM3.setPrintDelay(500); TM3.clear(); // Afficheur du HAUT initialisation
STRIP.begin(); STRIP.clear(); STRIP.show(); STRIP.setBrightness(30); // Bande led initialisation (début, clear + affichage, brightness)
mySoftwareSerial.begin(9600); Serial.begin(115200); // Dfmini comm serie
!myDFPlayer.begin(mySoftwareSerial); // Dfmini initialisation
myDFPlayer.volume(15); // Dfmini volume (0~30)
pinMode (36, INPUT_PULLUP); // Bouton Crédit en PULLUP -- PIN 36 --
pinMode(stepPinMotor1,OUTPUT); // Step Moteur 1
pinMode(dirPinMotor1,OUTPUT); // Direction Moteur 1
pinMode (38, INPUT_PULLUP); // Fin de course bas Moteur 1 -- PIN 38 --
pinMode (52, INPUT_PULLUP); // Bouton Moteur 1 Monte -- PIN 52 --
pinMode (50, INPUT_PULLUP); // Bonton Moteur 1 Descend -- PIN 38 --
pinMode(23, INPUT); // Mauvais Trou
pinMode(43, INPUT); // Trou 1
pinMode(41, INPUT); // Trou 2
pinMode(39, INPUT); // Trou 3
pinMode(37, INPUT); // Trou 4
pinMode(35, INPUT); // Trou 5
pinMode(33, INPUT); // Trou 6
pinMode(31, INPUT); // Trou 7
pinMode(29, INPUT); // Trou 8
pinMode(27, INPUT); // Trou 9
pinMode(25, INPUT); // Trou 10
Serial.begin(9600); //Pour la console
}
void loop() {
if (Motor1 == 0) {delay(Latence);} // millisecondes de mise a jour de la boucle si moteurs immobiles
if (Motor1 == 1) {
digitalWrite(dirPinMotor1,LOW); // direction Motor1 vers le Haut
for (int i = 0 ; i < 100; i++) {
digitalWrite(stepPinMotor1,HIGH); delayMicroseconds(500);
digitalWrite(stepPinMotor1,LOW); delayMicroseconds(500);}
Motor1 = 0;}
if (Motor1 == 2) {
digitalWrite(dirPinMotor1,HIGH); // direction Motor1 vers le Haut
for (int i = 0 ; i < 100; i++) {
digitalWrite(stepPinMotor1,HIGH); delayMicroseconds(500);
digitalWrite(stepPinMotor1,LOW); delayMicroseconds(500);}
Motor1 = 0;}
//--------------------------------------------------- ATTRACK MODE -------------------------------------------------
if (Amode == 1){
BTNcredit = digitalRead(36); // Verif si boutton coin est appuyé
if (BTNcredit == LOW) { Amode = 0; Debutpartie = 1; Etape = 1; // Sortie d'Attrack mode et Debut de Partie
myDFPlayer.playMp3Folder(6); // Dfmini SON pièce qui tombe
delay(1000); //
TM1.clear(); TM2.clear();TM3.clear(); // On efface les Afficheurs
STRIP.clear(); STRIP.show(); STRIP.setBrightness(30); // RAZ valeurs Bandes LEDs
TempLEDBRILL = 0; TempLEDBRILLAD = 5; TempAFF = 0; TempLED = 0;} // RAZ Valeurs Tempo
TempAFF++; int TempAFF2 = TempAFF * Latence;
switch (TempAFF2) { // Faire defiler text ecran du bas
case (1000): TM1.clear(); TM1.print("PLAY"); break;
case (2000): TM1.clear(); TM1.print("ICE"); break;
case (3000): TM1.clear(); TM1.print("COLD"); break;
case (4000): TM1.clear(); TM1.print("BEER"); break;
case (5000): TM1.clear(); break;
case (6000): TM1.clear(); TM1.setCursor(1, DECALAGE (Highscore)); TM1.print(Highscore); TempAFF = 0; break;}
TempLED++;
if ( TempLED <= 10 ) { STRIP.setBrightness(60);STRIP.setPixelColor(TempLED, 240, 240, 20); STRIP.setPixelColor(TempLED-1, 130, 130, 50); STRIP.show();}
if ( TempLED > 10 && TempLED <= 20 ){ STRIP.setPixelColor(TempLED-12, 0, 0, 0); STRIP.show(); }
if ( TempLED > 20 && TempLED <= 30 ){ STRIP.setPixelColor(TempLED-20, 240, 240, 20); STRIP.setPixelColor(TempLED-21, 130, 130, 50); STRIP.setPixelColor(TempLED-22, 0, 0, 0); STRIP.show(); }
if ( TempLED >= 30 && TempLED <= 40 ){ STRIP.setPixelColor(TempLED-32, 130, 130, 50); STRIP.show();}
if ( TempLED >= 50 && TempLED <= 60 ){ STRIP.setPixelColor(TempLED-52, 0, 0, 0); STRIP.show(); }
if ( TempLED == 60 ){ for (int i= 0; i<8; i++ ) {TempLEDBRILL = 20; STRIP.setBrightness(TempLEDBRILL); STRIP.setPixelColor(i, 230, 230 ,230); STRIP.show(); TempLEDBRILLAD=10;}}
if ( TempLED > 60 && TempLED <=180) {TempLEDBRILL = TempLEDBRILL + TempLEDBRILLAD ; STRIP.setBrightness(TempLEDBRILL); STRIP.show(); if (TempLEDBRILL >70 || TempLEDBRILL < 20){TempLEDBRILLAD=-TempLEDBRILLAD;} }
if ( TempLED == 180 ){ for (int i= 0; i<8; i++ ) {TempLEDBRILL = 20; STRIP.setBrightness(TempLEDBRILL); STRIP.setPixelColor(i, 0, 0 ,0); STRIP.show();}}
if (TempLED >= 200) { TempLED=0;}
} //----- FIN DE ATTRACK MODE
//--------------------------------------------------- DEBUT DE PARTIE ---------------------------------
if (Debutpartie == 1){ Bille++; Debutpartie =0; Initbarre = 1; // Sortie Debut de Partie vers Initialisation des barres
TM3.clear(); TM3.print(Bille); // Affichage Bille on barre
STRIP.clear();STRIP.setPixelColor(Etape-1, 240, 240, 20);STRIP.show();} // Allumage LED trou demandé
//----------------------------------------- INITIALISATION DES BARRES ET BONUS ------------------------
if (Initbarre ==1){ Bonus = Etape *100; TM2.clear(); TM2.setCursor(1, DECALAGE (Bonus)); TM2.print(Bonus); // Affichage Bonus
TM1.clear(); TM1.setCursor(1, DECALAGE (Score)); TM1.print(Score); // Affichage Score
Initbarre = 0; DescenteBarre = 1; TempBONUS = -10;} // Sortie Initialisation barres vers DescenteBarre
//-------------------------------------------------- DESCENTE DES BARRES ------------------------------
if (DescenteBarre ==1){
digitalWrite(dirPinMotor1,HIGH); // Direction Moteur 1 vers le bas
int ConFinDeCourse1 = digitalRead(38); // Lecteur Contacteur Fin de course Moteur 1
if (ConFinDeCourse1 == HIGH) {
Motor1 = 2; } // Pour faire sauter le delais de la boucle principale
if (ConFinDeCourse1 == LOW) {
Motor1 = 0;
myDFPlayer.playMp3Folder(1); // Dfmini SON Debut de partie
DescenteBarre = 0; MonteBarre = 1;}} // Sortie DescenteBarre barres vers MonteBarre
//-------------------------------------------------- MONTE DES BARRES ------------------------------
if (MonteBarre ==1){
digitalWrite(dirPinMotor1,LOW); // Direction Moteur 1 vers le bas
for (int i = 0 ; i < 3000; i++) {
digitalWrite(stepPinMotor1,HIGH);
delayMicroseconds(500);
digitalWrite(stepPinMotor1,LOW);
delayMicroseconds(500); }
MonteBarre = 0; Principale = 1;} // Sortie MonteBarre barres vers Principale
//----------------------------------------------------BOUCLE PRINCIPALE--------------------------------
if (Principale == 1) {
TempBONUS++; if (TempBONUS > (3000/Latence) && Bonus > 0) {Bonus = Bonus - 10; // Décompte Bonus
myDFPlayer.playMp3Folder(5); // Dfmini Bonus -10
TM2.clear(); TM2.setCursor(1, DECALAGE (Bonus)); TM2.print(Bonus); //
TempBONUS = 0;}
//
TempLEDBRILL = TempLEDBRILL + TempLEDBRILLAD;
STRIP.setBrightness(TempLEDBRILL); STRIP.setPixelColor(Etape-1, 240, 240, 20);
STRIP.show();
if (TempLEDBRILL >70 ){TempLEDBRILLAD=-10;};
if (TempLEDBRILL <10 ){TempLEDBRILLAD= 10;}
//----- Barre: detection deplacement
BttnMontMotor1 = digitalRead(52); // Moteur 1
BttnDscdMotor1 = digitalRead(50); //
if (BttnMontMotor1 == LOW){ Motor1 = 1;} // Montera
if (BttnDscdMotor1 == LOW){ Motor1 = 2;} // Descendra
//----- Detection du Trou
int Troudetect = 0; Trou=0;
Troudetect = digitalRead(23); if (Troudetect == LOW){ Trou=20;} // Mauvais Trou
Troudetect = digitalRead(43); if (Troudetect == LOW){ Trou=1;} // Trou 1
Troudetect = digitalRead(41); if (Troudetect == LOW){ Trou=2;} // Trou 2
Troudetect = digitalRead(39); if (Troudetect == LOW){ Trou=3;} // Trou 3
Troudetect = digitalRead(37); if (Troudetect == LOW){ Trou=4;} // Trou 4
Troudetect = digitalRead(35); if (Troudetect == LOW){ Trou=5;} // Trou 5
Troudetect = digitalRead(33); if (Troudetect == LOW){ Trou=6;} // Trou 6
Troudetect = digitalRead(31); if (Troudetect == LOW){ Trou=7;} // Trou 7
Troudetect = digitalRead(29); if (Troudetect == LOW){ Trou=8;} // Trou 8
Troudetect = digitalRead(27); if (Troudetect == LOW){ Trou=9;} // Trou 9
Troudetect = digitalRead(25); if (Troudetect == LOW){ Trou=10;} // Trou 10
if (Trou != 0 && Trou == Etape) { BonTrou =1 ; Principale = 0 ;} // Bille tombé dans le Bon Trou :D
if (Trou != 0 && Trou != Etape) { BadTrou =1 ; Principale = 0 ;} // Bille tombé dans le Mauvais Trou :(
} //----- FIN DE BOUCLE PRINCIPALE
//----------------------------------------------------------BON Trou-----------------------------------
if (BonTrou == 1) {
myDFPlayer.playMp3Folder(3); // Dfmini SON Bon trou
TM2.blink(); TempBONUS = Bonus/10;
for ( int i=0; i < TempBONUS; i++){ // Décompte du bonus
Bonus= Bonus -10; Score = Score +10;
myDFPlayer.playMp3Folder(4); delay (150- (i)); // Dfmini SON Bonus decompte
TM2.clear(); TM2.setCursor(1, DECALAGE (Bonus)); TM2.print(Bonus); // Affichage Bonus
TM1.clear(); TM1.setCursor(1, DECALAGE (Score)); TM1.print(Score);} // Affichage Score
Etape++; if (Etape > 10) {Etape=1;} BonTrou =0; Initbarre =1;TM1.blink();STRIP.clear();STRIP.show();} // Retour Initialisation barre
//--------------------------------------------------------MAUVAIS Trou----------------------------------
if (BadTrou == 1){
for (int i= 0; i<10; i++ ) {STRIP.setPixelColor(i, 230, 0 ,0); STRIP.show();} // LEDS en Rouge
TM3.clear(); TM3.print("-"); TM2.clear(); TM2.print("----"); TM1.clear(); TM1.print("OUPS"); // OUPS Message
myDFPlayer.playMp3Folder(9); // Dfmini SON Mauvais trou
delay (3000);
if (Bille == 3) { Gameover = 1;} // Verif si GAME OVER
Debutpartie = 1; BadTrou = 0;} // Retour debut de partie
//----------------------------------------------------------GAME OVER------------------------------------
if (Gameover == 1) { myDFPlayer.playMp3Folder(8); // Dfmini SON GAME OVER
TM1.clear(); TM2.clear(); TM3.clear();
TM1.print(" GAME OVER YOUR Score ");
TM1.clear(); TM1.setCursor(1, DECALAGE (Score)); TM1.print(Score); delay (500);
TM2.blink(); delay (1000); TM1.clear();
if ( Score > Highscore) { Highscore = Score;
TM1.clear(); TM1.print(" NEW"); TM1.blink(); TM1.print("HIGH"); TM1.blink(); TM1.print("SCOR"); TM1.blink(); TM1.clear();}
Amode = 1; Gameover = 0; Debutpartie = 0; Bille = 0; Etape = 0; Score = 0;}
//Serial.print (BttnMontMotor1);
Serial.println (Motor1);
//printDetail(myDFPlayer.readType(), myDFPlayer.read());
}//----- FIN LOOP
// Fonction pour trouver decalage des afficheurs *******************
int DECALAGE (int Adecaler) {
int Decal = 0;
if ( Adecaler <1000){Decal = 1;}
if ( Adecaler <100){Decal = 2;}
if ( Adecaler <10){Decal = 3;}
return Decal;
}
// Fonction Comm Dfmini ************************ *******************
void printDetail(uint8_t type, int value){
switch (type) {
case TimeOut: Serial.println(F("Time Out!")); break;
case WrongStack: Serial.println(F("Stack Wrong!")); break;
case DFPlayerCardInserted: Serial.println(F("Card Inserted!")); break;
case DFPlayerCardRemoved: Serial.println(F("Card Removed!")); break;
case DFPlayerCardOnline: Serial.println(F("Card Online!")); break;
case DFPlayerUSBInserted: Serial.println("USB Inserted!"); break;
case DFPlayerUSBRemoved: Serial.println("USB Removed!"); break;
case DFPlayerPlayFinished: Serial.print(F("Number:")); Serial.print(value); Serial.println(F(" Play Finished!")); break;
case DFPlayerError: Serial.print(F("DFPlayerError:"));
switch (value) {
case Busy: Serial.println(F("Card not found")); break;
case Sleeping: Serial.println(F("Sleeping")); break;
case SerialWrongStack: Serial.println(F("Get Wrong Stack")); break;
case CheckSumNotMatch: Serial.println(F("Check Sum Not Match")); break;
case FileIndexOut: Serial.println(F("File Index Out of Bound")); break;
case FileMismatch: Serial.println(F("Cannot Find File")); break;
case Advertise: Serial.println(F("In Advertise")); break;
default: break;
}
break; default: break;
}
}
//-------------- LIBRAIRIES ----------------------//****************************************************************
#include <SevenSegmentAsciiMap.h> //
#include <SevenSegmentExtended.h> // Librairies pour les afficheurs 4 digits 7 segments
#include <SevenSegmentTM1637.h> //
#include "Arduino.h" //
#include "SoftwareSerial.h" // Librairies Dfmini
#include "DFRobotDFPlayerMini.h" //
#include <Adafruit_NeoPixel.h> // Librairie pour les leds
//-------------- DECLARATION MATOS ---------------//****************************************************************
SevenSegmentTM1637 TM1(24, 22); //afficheur du BAS déclaration -- CLK 24 -- DIO 22 --
SevenSegmentTM1637 TM2(28, 26); //afficheur du CENTRE déclaration -- CLK 28 -- DIO 26 --
SevenSegmentTM1637 TM3(32, 30); //afficheur du HAUT déclaration -- CLK 32 -- DIO 30 --
Adafruit_NeoPixel STRIP(8, 34, NEO_GRBW + NEO_KHZ800); // Bande led déclaration -- NBR LED 8 -- DIO 34 --
SoftwareSerial mySoftwareSerial(13, 12); // Dfmini déclaration -- RX 12 -- TX 13 -- DOIVENT ETRES PWR
DFRobotDFPlayerMini myDFPlayer; //
void printDetail(uint8_t type, int value); //
//------------- DECLARATION VARIAVLES -------------//***************************************************************
int Latence = 50; // Pour gérer le delay de l'arduino (multiple de 50 sinon ce sera la merde !!!!!)
int TempAFF = 0; // Temporaire pour les Afficheurs
int TempLED = 0; // Temporaire pour les Leds
int TempLEDBRILL = 0; int TempLEDBRILLAD = 0; // Tempoiraire scintillement Leds
int TempBONUS = 0; // Tempoiraire décompte bonus
int Highscore = 0; // Highscore
int Bille = 0; // Bille on bar
int Etape = 0; // Trou demandé
int Bonus = 0; // Variable bonus
int Score = 0; // variable Score
int BTNcredit = 0; // Bouton Credit
const int stepPinMotor1 = 5; // Step Moteur 1 -- PIN 5 --
const int dirPinMotor1 = 4; // Direction Moteur 1 -- PIN 4 --
int Motor1Bouge = 0;
int Amode = 1; // Boucle ATTRACK MODE
int Debutpartie = 0; // Initialisation de la partie après le crédit
int Initbarre = 0; // Initialisation Bonus et partie
int DescenteBarre = 0;// Pour que les barres aillent chercher une nouvelle bille
int MonteBarre = 0; // Pour que les barres remonteent
int Principale = 0; // Boucle principale avec bougeage des barres, bonus qui descent, billes qui passent dans un trou etc...
int Trou = 0; // Trou dans laquelle est tombé la Bille
int BonTrou = 0; // Boucle Bille dans le bon trou
int BadTrou = 0; // Boucle Bille dans le mauvais trou
int Gameover = 0; // Boucle Gamover
void setup() {
TM1.begin(); TM1.setPrintDelay(500); TM1.clear(); // Afficheur du BAS initialisation (début / brightness / RAZ)
TM2.begin(); TM2.setPrintDelay(500); TM2.clear(); // Afficheur du CENTRE initialisation
TM3.begin(); TM3.setPrintDelay(500); TM3.clear(); // Afficheur du HAUT initialisation
STRIP.begin(); STRIP.clear(); STRIP.show(); STRIP.setBrightness(30); // Bande led initialisation (début, clear + affichage, brightness)
mySoftwareSerial.begin(9600); Serial.begin(115200); // Dfmini comm serie
!myDFPlayer.begin(mySoftwareSerial); // Dfmini initialisation
myDFPlayer.volume(15); // Dfmini volume (0~30)
pinMode (36, INPUT_PULLUP); // Bouton Crédit en PULLUP -- PIN 36 --
pinMode(stepPinMotor1,OUTPUT); // Step Moteur 1
pinMode(dirPinMotor1,OUTPUT); // Direction Moteur 1
pinMode (38, INPUT_PULLUP); // Fin de course bas Moteur 1 -- PIN 38 --
pinMode(23, INPUT); // Mauvais Trou
pinMode(43, INPUT); // Trou 1
pinMode(41, INPUT); // Trou 2
pinMode(39, INPUT); // Trou 3
pinMode(37, INPUT); // Trou 4
pinMode(35, INPUT); // Trou 5
pinMode(33, INPUT); // Trou 6
pinMode(31, INPUT); // Trou 7
pinMode(29, INPUT); // Trou 8
pinMode(27, INPUT); // Trou 9
pinMode(25, INPUT); // Trou 10
Serial.begin(9600); //Pour la console
}
void loop() {
if (Motor1Bouge == 0) {delay(Latence);} // millisecondes de mise a jour de la boucle si moteurs immobiles
//--------------------------------------------------- ATTRACK MODE -------------------------------------------------
if (Amode == 1){
BTNcredit = digitalRead(36); // Verif si boutton coin est appuyé
if (BTNcredit == LOW) { Amode = 0; Debutpartie = 1; Etape = 1; // Sortie d'Attrack mode et Debut de Partie
myDFPlayer.playMp3Folder(6); // Dfmini SON pièce qui tombe
delay(1000); //
TM1.clear(); TM2.clear();TM3.clear(); // On efface les Afficheurs
STRIP.clear(); STRIP.show(); STRIP.setBrightness(30); // RAZ valeurs Bandes LEDs
TempLEDBRILL = 0; TempLEDBRILLAD = 5; TempAFF = 0; TempLED = 0;} // RAZ Valeurs Tempo
TempAFF++; int TempAFF2 = TempAFF * Latence;
switch (TempAFF2) { // Faire defiler text ecran du bas
case (1000): TM1.clear(); TM1.print("PLAY"); break;
case (2000): TM1.clear(); TM1.print("ICE"); break;
case (3000): TM1.clear(); TM1.print("COLD"); break;
case (4000): TM1.clear(); TM1.print("BEER"); break;
case (5000): TM1.clear(); break;
case (6000): TM1.clear(); TM1.setCursor(1, DECALAGE (Highscore)); TM1.print(Highscore); TempAFF = 0; break;}
TempLED++;
if ( TempLED <= 10 ) { STRIP.setBrightness(60);STRIP.setPixelColor(TempLED, 240, 240, 20); STRIP.setPixelColor(TempLED-1, 130, 130, 50); STRIP.show();}
if ( TempLED > 10 && TempLED <= 20 ){ STRIP.setPixelColor(TempLED-12, 0, 0, 0); STRIP.show(); }
if ( TempLED > 20 && TempLED <= 30 ){ STRIP.setPixelColor(TempLED-20, 240, 240, 20); STRIP.setPixelColor(TempLED-21, 130, 130, 50); STRIP.setPixelColor(TempLED-22, 0, 0, 0); STRIP.show(); }
if ( TempLED >= 30 && TempLED <= 40 ){ STRIP.setPixelColor(TempLED-32, 130, 130, 50); STRIP.show();}
if ( TempLED >= 50 && TempLED <= 60 ){ STRIP.setPixelColor(TempLED-52, 0, 0, 0); STRIP.show(); }
if ( TempLED == 60 ){ for (int i= 0; i<8; i++ ) {TempLEDBRILL = 20; STRIP.setBrightness(TempLEDBRILL); STRIP.setPixelColor(i, 230, 230 ,230); STRIP.show(); TempLEDBRILLAD=10;}}
if ( TempLED > 60 && TempLED <=180) {TempLEDBRILL = TempLEDBRILL + TempLEDBRILLAD ; STRIP.setBrightness(TempLEDBRILL); STRIP.show(); if (TempLEDBRILL >70 || TempLEDBRILL < 20){TempLEDBRILLAD=-TempLEDBRILLAD;} }
if ( TempLED == 180 ){ for (int i= 0; i<8; i++ ) {TempLEDBRILL = 20; STRIP.setBrightness(TempLEDBRILL); STRIP.setPixelColor(i, 0, 0 ,0); STRIP.show();}}
if (TempLED >= 200) { TempLED=0;}
} //----- FIN DE ATTRACK MODE
//--------------------------------------------------- DEBUT DE PARTIE ---------------------------------
if (Debutpartie == 1){ Bille++; Debutpartie =0; Initbarre = 1; // Sortie Debut de Partie vers Initialisation des barres
TM3.clear(); TM3.print(Bille); // Affichage Bille on barre
STRIP.clear();STRIP.setPixelColor(Etape-1, 240, 240, 20);STRIP.show();} // Allumage LED trou demandé
//----------------------------------------- INITIALISATION DES BARRES ET BONUS ------------------------
if (Initbarre ==1){ Bonus = Etape *100; TM2.clear(); TM2.setCursor(1, DECALAGE (Bonus)); TM2.print(Bonus); // Affichage Bonus
TM1.clear(); TM1.setCursor(1, DECALAGE (Score)); TM1.print(Score); // Affichage Score
Initbarre = 0; DescenteBarre = 1; TempBONUS = 0;} // Sortie Initialisation barres vers DescenteBarre
//-------------------------------------------------- DESCENTE DES BARRES ------------------------------
if (DescenteBarre ==1){
digitalWrite(dirPinMotor1,HIGH); // Direction Moteur 1 vers le bas
int ConFinDeCourse1 = digitalRead(38); // Lecteur Contacteur Fin de course Moteur 1
if (ConFinDeCourse1 == HIGH) {
Motor1Bouge = 1; // Pour faire sauter le delais de la boucle principale
digitalWrite(stepPinMotor1,HIGH);
delayMicroseconds(500);
digitalWrite(stepPinMotor1,LOW);
delayMicroseconds(500); }
if (ConFinDeCourse1 == LOW) {
Motor1Bouge = 0;
myDFPlayer.playMp3Folder(1); // Dfmini SON Debut de partie
DescenteBarre = 0; MonteBarre = 1;}} // Sortie DescenteBarre barres vers MonteBarre
//-------------------------------------------------- MONTE DES BARRES ------------------------------
if (MonteBarre ==1){
digitalWrite(dirPinMotor1,LOW); // Direction Moteur 1 vers le bas
for (int i = 0 ; i < 3000; i++) {
digitalWrite(stepPinMotor1,HIGH);
delayMicroseconds(700);
digitalWrite(stepPinMotor1,LOW);
delayMicroseconds(700); }
MonteBarre = 0; Principale = 1;} // Sortie MonteBarre barres vers Principale
//----------------------------------------------------BOUCLE PRINCIPALE--------------------------------
if (Principale == 1) { delay(Latence); // Delais (latence voulu)
TempBONUS++; if (TempBONUS > (2000/Latence) && Bonus > 0) {Bonus = Bonus - 10; // Décompte Bonus
myDFPlayer.playMp3Folder(5); // Dfmini Bonus -10
TM2.clear(); TM2.setCursor(1, DECALAGE (Bonus)); TM2.print(Bonus); //
TempBONUS = 0;}
//
TempLEDBRILL = TempLEDBRILL + TempLEDBRILLAD;
STRIP.setBrightness(TempLEDBRILL); STRIP.setPixelColor(Etape-1, 240, 240, 20);
STRIP.show();
if (TempLEDBRILL >70 ){TempLEDBRILLAD=-10;};
if (TempLEDBRILL <10 ){TempLEDBRILLAD= 10;}
//-----Detection du Trou
int Troudetect = 0; Trou=0;
Troudetect = digitalRead(23); if (Troudetect == LOW){ Trou=20;} // Mauvais Trou
Troudetect = digitalRead(43); if (Troudetect == LOW){ Trou=1;} // Trou 1
Troudetect = digitalRead(41); if (Troudetect == LOW){ Trou=2;} // Trou 2
Troudetect = digitalRead(39); if (Troudetect == LOW){ Trou=3;} // Trou 3
Troudetect = digitalRead(37); if (Troudetect == LOW){ Trou=4;} // Trou 4
Troudetect = digitalRead(35); if (Troudetect == LOW){ Trou=5;} // Trou 5
Troudetect = digitalRead(33); if (Troudetect == LOW){ Trou=6;} // Trou 6
Troudetect = digitalRead(31); if (Troudetect == LOW){ Trou=7;} // Trou 7
Troudetect = digitalRead(29); if (Troudetect == LOW){ Trou=8;} // Trou 8
Troudetect = digitalRead(27); if (Troudetect == LOW){ Trou=9;} // Trou 9
Troudetect = digitalRead(25); if (Troudetect == LOW){ Trou=10;} // Trou 10
if (Trou != 0 && Trou == Etape) { BonTrou =1 ; Principale = 0 ;} // Bille tombé dans le Bon Trou :D
if (Trou != 0 && Trou != Etape) { BadTrou =1 ; Principale = 0 ;} // Bille tombé dans le Mauvais Trou :(
} //----- FIN DE BOUCLE PRINCIPALE
//----------------------------------------------------------BON Trou-----------------------------------
if (BonTrou == 1) {
myDFPlayer.playMp3Folder(3); // Dfmini SON Bon trou
TM2.blink(); TempBONUS = Bonus/10;
for ( int i=0; i < TempBONUS; i++){ // Décompte du bonus
Bonus= Bonus -10; Score = Score +10;
myDFPlayer.playMp3Folder(4); delay (200- (i)); // Dfmini SON Bonus decompte
TM2.clear(); TM2.setCursor(1, DECALAGE (Bonus)); TM2.print(Bonus); // Affichage Bonus
TM1.clear(); TM1.setCursor(1, DECALAGE (Score)); TM1.print(Score);} // Affichage Score
Etape++; if (Etape > 10) {Etape=1;} BonTrou =0; Initbarre =1;TM1.blink();STRIP.clear();STRIP.show();} // Retour Initialisation barre
//--------------------------------------------------------MAUVAIS Trou----------------------------------
if (BadTrou == 1){
for (int i= 0; i<10; i++ ) {STRIP.setPixelColor(i, 230, 0 ,0); STRIP.show();} // LEDS en Rouge
TM3.clear(); TM3.print("-"); TM2.clear(); TM2.print("----"); TM1.clear(); TM1.print("OUPS"); // OUPS Message
myDFPlayer.playMp3Folder(9); // Dfmini SON Mauvais trou
delay (3000);
if (Bille == 3) { Gameover = 1;} // Verif si GAME OVER
Debutpartie = 1; BadTrou = 0;} // Retour debut de partie
//----------------------------------------------------------GAME OVER------------------------------------
if (Gameover == 1) { myDFPlayer.playMp3Folder(8); // Dfmini SON GAME OVER
TM1.clear(); TM2.clear(); TM3.clear();
TM1.print(" GAME OVER YOUR Score ");
TM1.clear(); TM1.setCursor(1, DECALAGE (Score)); TM1.print(Score); delay (500);
TM2.blink(); delay (1000); TM1.clear();
if ( Score > Highscore) { Highscore = Score;
TM1.clear(); TM1.print(" NEW"); TM1.blink(); TM1.print("HIGH"); TM1.blink(); TM1.print("SCOR"); TM1.blink(); TM1.clear();}
Amode = 1; Gameover = 0; Debutpartie = 0; Bille = 0; Etape = 0; Score = 0;}
int ConFinDeCourse1 = digitalRead(38);
Serial.println (ConFinDeCourse1);
//printDetail(myDFPlayer.readType(), myDFPlayer.read());
}//----- FIN LOOP
// Fonction pour trouver decalage des afficheurs *******************
int DECALAGE (int Adecaler) {
int Decal = 0;
if ( Adecaler <1000){Decal = 1;}
if ( Adecaler <100){Decal = 2;}
if ( Adecaler <10){Decal = 3;}
return Decal;
}
// Fonction Comm Dfmini ************************ *******************
void printDetail(uint8_t type, int value){
switch (type) {
case TimeOut: Serial.println(F("Time Out!")); break;
case WrongStack: Serial.println(F("Stack Wrong!")); break;
case DFPlayerCardInserted: Serial.println(F("Card Inserted!")); break;
case DFPlayerCardRemoved: Serial.println(F("Card Removed!")); break;
case DFPlayerCardOnline: Serial.println(F("Card Online!")); break;
case DFPlayerUSBInserted: Serial.println("USB Inserted!"); break;
case DFPlayerUSBRemoved: Serial.println("USB Removed!"); break;
case DFPlayerPlayFinished: Serial.print(F("Number:")); Serial.print(value); Serial.println(F(" Play Finished!")); break;
case DFPlayerError: Serial.print(F("DFPlayerError:"));
switch (value) {
case Busy: Serial.println(F("Card not found")); break;
case Sleeping: Serial.println(F("Sleeping")); break;
case SerialWrongStack: Serial.println(F("Get Wrong Stack")); break;
case CheckSumNotMatch: Serial.println(F("Check Sum Not Match")); break;
case FileIndexOut: Serial.println(F("File Index Out of Bound")); break;
case FileMismatch: Serial.println(F("Cannot Find File")); break;
case Advertise: Serial.println(F("In Advertise")); break;
default: break;
}
break; default: break;
}
}
Citation de: AsPiC le Jeudi 13 Mai 2021, 21:04:11 PM
Curieux de voir comment tu vas gérer la parti gestion des guns sur un lcd pour la VC
Mais d'abord il faut finir la Ice Cold Beer !
Citation de: Little_Rabbit le Jeudi 13 Mai 2021, 21:48:42 PM
Et de voir ainsi Moto Racer au sien d'une compile de jeux d'arcade, ça fait chaud au cœur ! Bon, c'est clair que l'interface n'avait pas du tout été pensée "panel arcade", on est bien dans l'univers du PC... Est-ce qu'intégrer un mini trackball, ou un track pad, ne serait pas envisageable ? Les menus de la version PlayStation s'y prêteraient peut être mieux (je me souviens qu'on supportait les NegCon pour la conduite, mais je ne me rappelle pas si on peut naviguer avec dans les menus...). Mais bien sûr la définition image n'est pas celle d'un PC !...
Citation de: -fab- le Jeudi 06 Mai 2021, 18:12:40 PMPour le haut, oui surement, avec les moteurs pas à pas, tu peux savoir précisément de combien ils se sont déplacés.
Sur le système de Milker Ulucay , c'est le code qui gère la fin de course pour pas que le support de la barre vienne en butée sur l'axe du moteur ou la poulie ?
Citation de: Little_Rabbit le Jeudi 06 Mai 2021, 18:54:12 PM
Salut,
En Googlant rapidement, je suis tombé sur cette vidéo intéressante de WIP car on voit dans le détail comment est foutu le système de poulies et entraînement de la barre sur l'original Taito (avec un bel accent Québécois en prime ):
youtube.com/watch?v=3SlB4BfR14s
(par contre, il bouge tellement sa caméra dans tous les sens que ça peut limite donner la gerbe à la longue ! )
Et si j'ai bien compris, il utilise du tube de lave-glace en guise de courroie !
@berunours : que penses-tu prendre pour la barre télescopique sur laquelle la bille roule ?
A+
Citation de: ɐɹqoƆ‾ɥƃᴉH le Jeudi 06 Mai 2021, 13:55:57 PMJ'étais parti sur ça au départ, mais je pense que ce sera trop lent.
Sinon, toujours avec des moteurs pas à pas, tu peux aussi t'inspirer des axes Z des imprimantes 3D, ça peut faire une bonne base de travail.
Citation de: sushy18 le Jeudi 06 Mai 2021, 08:31:47 AMMerci, mais sans ton taf de défrichage, rien n'aurait été possible.
Bravo !!! même si je suis un poil jaloux
je note l'excellent travail.
vraiment top !
Citation de: sushy18 le Jeudi 06 Mai 2021, 08:31:47 AMJe viens de le ralentir car les sons "merdouillaient" un peu, mais je vais corriger ça.
suggestion : le décompte de points peut être un peu accéléré ?
Citation de: sushy18 le Jeudi 06 Mai 2021, 08:31:47 AM
au passage je suis le travail d'un turc sur Facebook ( son origine en s'en bat les reins c'est surtout qu'il publie en turc )
Milker Ulucay
Il vend des bornes inspirées de ICB et Zeke's peak
https://gamoovernet.pixhotel.fr/pics_gamoovernet890px/20210506084105-sushy18-177013513-271449394712220-2671097409251752953-n.jpg
https://gamoovernet.pixhotel.fr/pics_gamoovernet890px/20210506084142-sushy18-173900417-285779893127687-3507596279168130928-n.jpg
je l'ai tellement saoulé avec mes questions et avec beaucoup d'humour qu'il m'a fait une proposition de design:
https://gamoovernet.pixhotel.fr/pics_gamoovernet890px/20210506084913-sushy18-179783792-1155678471562411-8002074352329338532-n.jpg
puis dit travailler sur :
https://gamoovernet.pixhotel.fr/pics_gamoovernet890px/20210506084317-sushy18-180829543-10223201473117879-8027998242673347509-n.jpg
déja en v3.0
ce que je trouve surtout intéressant c'est son system, un peu différent de l'ICB pour monter et descendre le coté de la barre:
il ne s'est pas fait chié de barres verticales et me semble adapté pour un format mini :
//-------------- LIBRAIRIES ----------------------//****************************************************************
#include <SevenSegmentAsciiMap.h> //
#include <SevenSegmentExtended.h> // Librairies pour les afficheurs 4 digits 7 segments
#include <SevenSegmentTM1637.h> //
#include "Arduino.h" //
#include "SoftwareSerial.h" // Librairies Dfmini
#include "DFRobotDFPlayerMini.h" //
#include <Adafruit_NeoPixel.h> // Librairie pour les leds
#include "Arduino.h" //
#include "SoftwareSerial.h" // Librairie pour le Dfmini
#include "DFRobotDFPlayerMini.h" //
//-------------- DECLARATION MATOS ---------------//****************************************************************
SevenSegmentTM1637 TM1(24, 22); //afficheur du BAS déclaration -- CLK 24 -- DIO 22 --
SevenSegmentTM1637 TM2(28, 26); //afficheur du CENTRE déclaration -- CLK 28 -- DIO 26 --
SevenSegmentTM1637 TM3(32, 30); //afficheur du HAUT déclaration -- CLK 32 -- DIO 30 --
Adafruit_NeoPixel STRIP(8, 34, NEO_GRBW + NEO_KHZ800); // Bande led déclaration -- NBR LED 8 -- DIO 34 --
SoftwareSerial mySoftwareSerial(13, 12); // Dfmini déclaration -- RX 12 -- TX 13 -- DOIVENT ETRES PWR
DFRobotDFPlayerMini myDFPlayer; //
void printDetail(uint8_t type, int value); //
//------------- DECLARATION VARIAVLES -------------//***************************************************************
int Latence = 50; // Pour gérer le delay de l'arduino (multiple de 50 sinon ce sera la merde !!!!!)
int TempAFF = 0; // Temporaire pour les Afficheurs
int TempLED = 0; // Temporaire pour les Leds
int TempLEDBRILL = 0; int TempLEDBRILLAD = 0; // Tempoiraire scintillement Leds
int TempBONUS = 0; // Tempoiraire décompte bonus
int Highscore = 0; // Highscore
int Bille = 0; // Bille on bar
int Etape = 0; // Trou demandé
int Bonus = 0; // Variable bonus
int Score = 0; // variable Score
int BTNcredit = 0; // Bouton Credit
int Amode = 1; // Boucle ATTRACK MODE
int Debutpartie = 0; // Initialisation de la partie après le crédit
int Initbarre = 0; // Pour que les barres aillent chercher une nouvelle bille
int Principale = 0; // Boucle principale avec bougeage des barres, bonus qui descent, billes qui passent dans un trou etc...
int Trou = 0; // Trou dans laquelle est tombé la Bille
int BonTrou = 0; // Boucle Bille dans le bon trou
int BadTrou = 0; // Boucle Bille dans le mauvais trou
int Gameover = 0; // Boucle Gamover
void setup() {
TM1.begin(); TM1.setPrintDelay(500); TM1.clear(); // Afficheur du BAS initialisation (début / brightness / RAZ)
TM2.begin(); TM2.setPrintDelay(500); TM2.clear(); // Afficheur du CENTRE initialisation
TM3.begin(); TM3.setPrintDelay(500); TM3.clear(); // Afficheur du HAUT initialisation
STRIP.begin(); STRIP.clear(); STRIP.show(); STRIP.setBrightness(30); // Bande led initialisation (début, clear + affichage, brightness)
mySoftwareSerial.begin(9600); Serial.begin(115200); // Dfmini comm serie
!myDFPlayer.begin(mySoftwareSerial); // Dfmini initialisation
myDFPlayer.volume(15); // Dfmini volume (0~30)
pinMode (36, INPUT_PULLUP); // Bouton Crédit en PULLUP -- PIN 36 --
pinMode(23, INPUT); // Mauvais Trou
pinMode(43, INPUT); // Trou 1
pinMode(41, INPUT); // Trou 2
pinMode(39, INPUT); // Trou 3
pinMode(37, INPUT); // Trou 4
pinMode(35, INPUT); // Trou 5
pinMode(33, INPUT); // Trou 6
pinMode(31, INPUT); // Trou 7
pinMode(29, INPUT); // Trou 8
pinMode(27, INPUT); // Trou 9
pinMode(25, INPUT); // Trou 10
Serial.begin(9600); //Pour la console
}
void loop() {
delay(Latence); // millisecondes de mise a jour de la boucle
//--------------------------------------------------- ATTRACK MODE -------------------------------------------------
if (Amode == 1){
BTNcredit = digitalRead(36); // Verif si boutton coin est appuyé
if (BTNcredit == LOW) { Amode = 0; Debutpartie = 1; Etape = 1; // Sortie d'Attrack mode et Debut de Partie
myDFPlayer.playMp3Folder(6); // Dfmini SON pièce qui tombe
delay(1000); //
TM1.clear(); TM2.clear();TM3.clear(); // On efface les Afficheurs
STRIP.clear(); STRIP.show(); STRIP.setBrightness(30); // RAZ valeurs Bandes LEDs
TempLEDBRILL = 0; TempLEDBRILLAD = 5; TempAFF = 0; TempLED = 0;} // RAZ Valeurs Tempo
TempAFF++; int TempAFF2 = TempAFF * Latence;
switch (TempAFF2) { // Faire defiler text ecran du bas
case (1000): TM1.clear(); TM1.print("PLAY"); break;
case (2000): TM1.clear(); TM1.print("ICE"); break;
case (3000): TM1.clear(); TM1.print("COLD"); break;
case (4000): TM1.clear(); TM1.print("BEER"); break;
case (5000): TM1.clear(); break;
case (6000): TM1.clear(); TM1.setCursor(1, DECALAGE (Highscore)); TM1.print(Highscore); TempAFF = 0; break;}
TempLED++;
if ( TempLED <= 10 ) { STRIP.setBrightness(60);STRIP.setPixelColor(TempLED, 240, 240, 20); STRIP.setPixelColor(TempLED-1, 130, 130, 50); STRIP.show();}
if ( TempLED > 10 && TempLED <= 20 ){ STRIP.setPixelColor(TempLED-12, 0, 0, 0); STRIP.show(); }
if ( TempLED > 20 && TempLED <= 30 ){ STRIP.setPixelColor(TempLED-20, 240, 240, 20); STRIP.setPixelColor(TempLED-21, 130, 130, 50); STRIP.setPixelColor(TempLED-22, 0, 0, 0); STRIP.show(); }
if ( TempLED >= 30 && TempLED <= 40 ){ STRIP.setPixelColor(TempLED-32, 130, 130, 50); STRIP.show();}
if ( TempLED >= 50 && TempLED <= 60 ){ STRIP.setPixelColor(TempLED-52, 0, 0, 0); STRIP.show(); }
if ( TempLED == 60 ){ for (int i= 0; i<8; i++ ) {TempLEDBRILL = 20; STRIP.setBrightness(TempLEDBRILL); STRIP.setPixelColor(i, 230, 230 ,230); STRIP.show(); TempLEDBRILLAD=10;}}
if ( TempLED > 60 && TempLED <=180) {TempLEDBRILL = TempLEDBRILL + TempLEDBRILLAD ; STRIP.setBrightness(TempLEDBRILL); STRIP.show(); if (TempLEDBRILL >70 || TempLEDBRILL < 20){TempLEDBRILLAD=-TempLEDBRILLAD;} }
if ( TempLED == 180 ){ for (int i= 0; i<8; i++ ) {TempLEDBRILL = 20; STRIP.setBrightness(TempLEDBRILL); STRIP.setPixelColor(i, 0, 0 ,0); STRIP.show();}}
if (TempLED >= 200) { TempLED=0;}
} //----- FIN DE ATTRACK MODE
//--------------------------------------------------- DEBUT DE PARTIE ---------------------------------
if (Debutpartie == 1){ Bille++; Debutpartie =0; Initbarre = 1; // Sortie Debut de Partie vers Initialisation des barres
TM3.clear(); TM3.print(Bille); // Affichage Bille on barre
STRIP.clear();STRIP.setPixelColor(Etape-1, 240, 240, 20);STRIP.show();} // Allumage LED trou demandé
//----------------------------------------- INITIALISATION DES BARRES ET BONUS ------------------------
if (Initbarre ==1){ Bonus = Etape *100; TM2.clear(); TM2.setCursor(1, DECALAGE (Bonus)); TM2.print(Bonus); // Affichage Bonus
TM1.clear(); TM1.setCursor(1, DECALAGE (Score)); TM1.print(Score); // Affichage Score
myDFPlayer.playMp3Folder(1); // Dfmini SON Debut de partie
delay (5000); //--- <><><><><> --- Attendre que lesw barres prennent la bille
Initbarre = 0; Principale = 1; TempBONUS = 0;} // Sortie Initialisation barres vers Principale
//----------------------------------------------------BOUCLE PRINCIPALE--------------------------------
if (Principale == 1) { delay(Latence); // Delais (latence voulu)
TempBONUS++; if (TempBONUS > (2000/Latence) && Bonus > 0) {Bonus = Bonus - 10; // Décompte Bonus
myDFPlayer.playMp3Folder(5); // Dfmini Bonus -10
TM2.clear(); TM2.setCursor(1, DECALAGE (Bonus)); TM2.print(Bonus); //
TempBONUS = 0;}
//
TempLEDBRILL = TempLEDBRILL + TempLEDBRILLAD;
STRIP.setBrightness(TempLEDBRILL); STRIP.setPixelColor(Etape-1, 240, 240, 20);
STRIP.show();
if (TempLEDBRILL >70 ){TempLEDBRILLAD=-10;};
if (TempLEDBRILL <10 ){TempLEDBRILLAD= 10;}
//-----Detection du Trou
int Troudetect = 0; Trou=0;
Troudetect = digitalRead(23); if (Troudetect == LOW){ Trou=20;} // Mauvais Trou
Troudetect = digitalRead(43); if (Troudetect == LOW){ Trou=1;} // Trou 1
Troudetect = digitalRead(41); if (Troudetect == LOW){ Trou=2;} // Trou 2
Troudetect = digitalRead(39); if (Troudetect == LOW){ Trou=3;} // Trou 3
Troudetect = digitalRead(37); if (Troudetect == LOW){ Trou=4;} // Trou 4
Troudetect = digitalRead(35); if (Troudetect == LOW){ Trou=5;} // Trou 5
Troudetect = digitalRead(33); if (Troudetect == LOW){ Trou=6;} // Trou 6
Troudetect = digitalRead(31); if (Troudetect == LOW){ Trou=7;} // Trou 7
Troudetect = digitalRead(29); if (Troudetect == LOW){ Trou=8;} // Trou 8
Troudetect = digitalRead(27); if (Troudetect == LOW){ Trou=9;} // Trou 9
Troudetect = digitalRead(25); if (Troudetect == LOW){ Trou=10;} // Trou 10
if (Trou != 0 && Trou == Etape) { BonTrou =1 ; Principale = 0 ;} // Bille tombé dans le Bon Trou :D
if (Trou != 0 && Trou != Etape) { BadTrou =1 ; Principale = 0 ;} // Bille tombé dans le Mauvais Trou :(
} //----- FIN DE BOUCLE PRINCIPALE
//----------------------------------------------------------BON Trou-----------------------------------
if (BonTrou == 1) {
myDFPlayer.playMp3Folder(3); // Dfmini SON Bon trou
TM2.blink(); TempBONUS = Bonus/10;
for ( int i=0; i < TempBONUS; i++){ // Décompte du bonus
Bonus= Bonus -10; Score = Score +10;
myDFPlayer.playMp3Folder(4); delay (200- (i)); // Dfmini SON Bonus decompte
TM2.clear(); TM2.setCursor(1, DECALAGE (Bonus)); TM2.print(Bonus); // Affichage Bonus
TM1.clear(); TM1.setCursor(1, DECALAGE (Score)); TM1.print(Score);} // Affichage Score
Etape++; if (Etape > 10) {Etape=1;} BonTrou =0; Initbarre =1;TM1.blink();STRIP.clear();STRIP.show();} // Retour Initialisation barre
//--------------------------------------------------------MAUVAIS Trou----------------------------------
if (BadTrou == 1){
for (int i= 0; i<10; i++ ) {STRIP.setPixelColor(i, 230, 0 ,0); STRIP.show();} // LEDS en Rouge
TM3.clear(); TM3.print("-"); TM2.clear(); TM2.print("----"); TM1.clear(); TM1.print("OUPS"); // OUPS Message
myDFPlayer.playMp3Folder(9); // Dfmini SON Mauvais trou
delay (3000);
if (Bille == 3) { Gameover = 1;} // Verif si GAME OVER
Debutpartie = 1; BadTrou = 0;} // Retour debut de partie
//----------------------------------------------------------GAME OVER------------------------------------
if (Gameover == 1) { myDFPlayer.playMp3Folder(8); // Dfmini SON GAME OVER
TM1.clear(); TM2.clear(); TM3.clear();
TM1.print(" GAME OVER YOUR Score ");
TM1.clear(); TM1.setCursor(1, DECALAGE (Score)); TM1.print(Score); delay (500);
TM2.blink(); delay (1000); TM1.clear();
if ( Score > Highscore) { Highscore = Score;
TM1.clear(); TM1.print(" NEW"); TM1.blink(); TM1.print("HIGH"); TM1.blink(); TM1.print("SCOR"); TM1.blink(); TM1.clear();}
Amode = 1; Gameover = 0; Debutpartie = 0; Bille = 0; Etape = 0; Score = 0;}
Serial.println (Trou);
//printDetail(myDFPlayer.readType(), myDFPlayer.read());
}//----- FIN LOOP
// Fonction pour trouver decalage des afficheurs *******************
int DECALAGE (int Adecaler) {
int Decal = 0;
if ( Adecaler <1000){Decal = 1;}
if ( Adecaler <100){Decal = 2;}
if ( Adecaler <10){Decal = 3;}
return Decal;
}
// Fonction Comm Dfmini ************************ *******************
void printDetail(uint8_t type, int value){
switch (type) {
case TimeOut: Serial.println(F("Time Out!")); break;
case WrongStack: Serial.println(F("Stack Wrong!")); break;
case DFPlayerCardInserted: Serial.println(F("Card Inserted!")); break;
case DFPlayerCardRemoved: Serial.println(F("Card Removed!")); break;
case DFPlayerCardOnline: Serial.println(F("Card Online!")); break;
case DFPlayerUSBInserted: Serial.println("USB Inserted!"); break;
case DFPlayerUSBRemoved: Serial.println("USB Removed!"); break;
case DFPlayerPlayFinished: Serial.print(F("Number:")); Serial.print(value); Serial.println(F(" Play Finished!")); break;
case DFPlayerError: Serial.print(F("DFPlayerError:"));
switch (value) {
case Busy: Serial.println(F("Card not found")); break;
case Sleeping: Serial.println(F("Sleeping")); break;
case SerialWrongStack: Serial.println(F("Get Wrong Stack")); break;
case CheckSumNotMatch: Serial.println(F("Check Sum Not Match")); break;
case FileIndexOut: Serial.println(F("File Index Out of Bound")); break;
case FileMismatch: Serial.println(F("Cannot Find File")); break;
case Advertise: Serial.println(F("In Advertise")); break;
default: break;
}
break; default: break;
}
}