Hamza Mahmoud
Published ยฉ CC BY-NC-SA

E-STADUIM GAME Using Arduino

Control A goal Keeper and make a commentary voice using mp3 as we will see and a sensor that calculates if the ball passed the goal line

AdvancedFull instructions provided3 hours161
E-STADUIM GAME Using Arduino

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
ร—1
Breadboard (generic)
Breadboard (generic)
ร—1
MP3 Module
ร—1
USB Cable Assembly, USB Type A Plug to Micro USB Type B Plug
USB Cable Assembly, USB Type A Plug to Micro USB Type B Plug
ร—1
Flash Memory Card, SD Card
Flash Memory Card, SD Card
ร—1
Jumper wires (generic)
Jumper wires (generic)
ร—30
Resistor 1k ohm
Resistor 1k ohm
ร—1
4ohm 0.3 Watt Speaker
ร—1
SG90 Micro-servo motor
SG90 Micro-servo motor
ร—1
Joystick Module
ร—1
3 Pin IR Sensor
ร—1
Male/Female Jumper Wires
Male/Female Jumper Wires
ร—30
Buzzer
Buzzer
ร—1
5V 2A Power Adaptor
ร—1
Rosetta to DC socket
ร—1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Drill / Driver, 20 V
Drill / Driver, 20 V
Hot glue gun (generic)
Hot glue gun (generic)
Maquettes
( Net , Football Players, lights and trees to decorate )
30X40 Synthetic grass
30X40 wood

Story

Read more

Schematics

Commentery Audio

Add This MP3 To Your SD Card

Schemtic 1

Schemtic 2

Schemtic 3

Code

Arduino Code

C/C++
Arduino Code
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);

#include<Servo.h>
Servo servo;

int x_axis;

int servo_val;

int IRSensor = 2; // connect ir sensor to arduino pin 2
int LED = 13; // conect Led to arduino pin 13



void setup() {
  // put your setup code here, to run once:
pinMode (IRSensor, INPUT); // sensor pin INPUT
  pinMode (LED, OUTPUT);
pinMode(A0,INPUT);

servo.attach(9); // servo pin number 9
 mySoftwareSerial.begin(9600);
  Serial.begin(115200);
  
  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
  
  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while(true);
  }
  Serial.println(F("DFPlayer Mini online."));
  
  myDFPlayer.volume(30);  //Set volume value. From 0 to 30
  myDFPlayer.play(1);  //Play the first mp3
}

void loop() {
  // put your main code here, to run repeatedly:
x_axis=analogRead(A0);

servo_val=map(x_axis,0,1023,0,90);

servo.write(servo_val);
int statusSensor = digitalRead (IRSensor);
  
  if (statusSensor == 1)
    digitalWrite(LED, LOW);   // LED LOW
  
  
  else
  {
    digitalWrite(LED, HIGH); // LED High
    delay(3000);
  }

  static unsigned long timer = millis();
  
  if (millis() - timer > 3000) {
    timer = millis();
    //myDFPlayer.next();  //Play next mp3 every 3 second.
  }
  
  if (myDFPlayer.available()) {
    printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states.
  }
}

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 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;
  }
}

Credits

Hamza Mahmoud
2 projects โ€ข 1 follower
Connect Minds, Create Your Future ๐Ÿ˜‰โšกโšก #IAM681 ๐Ÿ˜‰โšกโšกูˆุตู„ ุงู„ุนู‚ูˆู„ ุŒ ุงุตู†ุน ุงู„ู…ุณุชู‚ุจู„ #IAM681 ๐Ÿ˜
Contact

Comments

Please log in or sign up to comment.