Close
0%
0%

bazzboom

a tank game with 2controller and a tank engine

Similar projects worth following
90 views
0 followers
Project Structure and Components:

Electronic Components:

Arduino Uno: Controls the system (joysticks, shooting, LEDs, sound).
Analog Joysticks: Control tank movement (forward/backward, left/right).
Motor: Launches cardboard projectiles when the shoot button is pressed.
LEDs and Resistors: Indicate game status (e.g., shooting readiness).
Buzzer/Speaker: Provides sound effects (e.g., shooting, explosions).
Wires and Connectors: Establish electrical connections.
Physical Materials:

Cardboard: Used for projectiles and tank structure.
Plastic: Used for shooting mechanism and tank parts.
Wood (optional): Reinforces structure and dashboard base.
Additional Components: Buttons, screws, glue, etc.

Project Structure and Components:
Electronic Components:

Arduino Uno: Used to control the entire system, including joysticks, the shooting mechanism, LEDs, and sound effects.
Analog Joysticks: Each player uses a joystick to control their tank’s movement (forward, backward, left, right).
Motor: Used to launch the projectile (cardboard), triggered by a shooting button.
LEDs and Resistors: Indicate game statuses on the dashboard, such as shooting readiness, tank preparation, etc.
Buzzer or Speaker: For sound effects, such as shooting and explosions.
Wires and Connectors: To establish the electrical connections between components.
Physical Materials:

Cardboard: Primarily used for making the lightweight projectiles and the tank's structure.
Plastic (lightweight): Used for making the shooting mechanism and other tank parts that need to be sturdy yet lightweight.
Wood (optional): Used to reinforce the structure, particularly for the dashboard base or stands.
Additional Components: Buttons to activate game functions (shoot), screws, nuts, glue, and other mounting tools.
Project Progress:
December 11, 2024: Final Session
Joystick Improvements and Tank Controls:

The joysticks were calibrated to ensure smooth movement. Each joystick controls the tank’s movement (forward/backward on the Y-axis, left/right on the X-axis). Analog readings are sent to the Arduino, which translates this information to control the tank’s motors.
An Arduino code was written to handle these analog inputs, ensuring precise tank movement.
Prototyping and Shooting Mechanism:

A prototype for the shooting mechanism was finalized. It uses a small DC motor to propel a cardboard projectile when a button is pressed.
The mechanism was tested to ensure that the projectiles are launched with enough force but remain safe. The small motor ensures that the projectile is launched at a reasonable distance while keeping the game safe.
Arduino Code for Shooting Control: The code for managing the shooting with Arduino was enhanced, and the following logic was implemented:

Button Press Detection: When a button is pressed (e.g., a push-button type), a signal is sent to the Arduino to activate the motor and launch the projectile.
Motor Control Code:
cpp
Copier le code
const int joystickPinX = A0;
const int joystickPinY = A1;
const int shootButtonPin = 2;
const int motorPin = 3; // Connected to the motor that launches the projectile

void setup() {
  pinMode(shootButtonPin, INPUT);
  pinMode(motorPin, OUTPUT);
  Serial.begin(9600); // Start serial communication for debugging
}

void loop() {
  int joystickX = analogRead(joystickPinX); // Read the X position of the joystick
  int joystickY = analogRead(joystickPinY); // Read the Y position of the joystick
  bool shootButtonState = digitalRead(shootButtonPin); // Check if the shoot button is pressed
  
  // Tank movement controls
  if (joystickX > 512) {
    // Move right
    Serial.println("Moving Right");
  } else if (joystickX < 512) {
    // Move left
    Serial.println("Moving Left");
  }

  if (joystickY > 512) {
    // Move forward
    Serial.println("Moving Forward");
  } else if (joystickY < 512) {
    // Move backward
    Serial.println("Moving Backward");
  }

  // Shooting logic
  if (shootButtonState == HIGH) {
    digitalWrite(motorPin, HIGH);  // Activate the motor to launch the projectile
    delay(500);  // Shoot for 500ms
    digitalWrite(motorPin, LOW);   // Stop the motor
    Serial.println("Fired!");
  }
  
  delay(50); // Short delay to avoid overloading the loop
}
Dashboard Development:

The dashboard was equipped with LEDs to indicate...

Read more »

123.ino

arduino code

ino - 621.00 bytes - 12/17/2024 at 11:08

Download

  • 1 × arduinocard
  • 1 × sensor Development Kits, Boards and Systems / Emulation Boards and Modules
  • 1 × joystick
  • 1 × aa Capacitors / Aluminum Electrolytic

  • project log

    JeanBej1112/17/2024 at 11:05 0 comments

    Project Logs:

    December 11, 2024: Final Session

    • Joystick Calibration: Joysticks calibrated for smooth movement. Arduino code written to handle analog inputs and control tank movement.
    • Shooting Mechanism: Prototype finalized. Small DC motor propels cardboard projectiles with button activation. Arduino code enhanced to manage shooting.

    December 3, 2024: Tank Design and Assembly

    • Tank Assembly: Physical components finalized, ergonomic chassis designed for different players. Joysticks, shooting mechanism, and dashboard integrated.
    • Shooting Mechanism Testing: Cardboard projectiles launched at a reasonable distance. Adjustments made for optimal launch force.

    November 26, 2024: Shooting Mechanism Finalization & LED Integration

    • Motor Upgrade: More powerful motor selected to ensure consistent projectile launch.
    • LEDs: Soldered and integrated into the dashboard, programmed to indicate game status (e.g., shooting readiness, tank status).

    November 19, 2024: Technical Problems and Solutions

    • Motor and Launch Tube Adjustment: Issue with projectile launch fixed by using a stronger motor and improving launch tube design.

    November 5, 2024: Initial Game Testing

    • Testing: Joysticks and shooting mechanism were tested. Basic code written and visual/audio effects (e.g., buzzer for shooting) were implemented.

    Next Steps:

    • Finalize mechanical assembly and optimize shooting mechanism.
    • Improve accuracy and design (motor adjustments, painting, and decorating the tank).
    • Add more features (sound effects, extra LEDs, LCD screen for score/status).
    • Conduct final testing to ensure system functionality and fun gameplay.

View project log

  • 1
    description of items

    1. Arduino Uno

    • Description: A microcontroller board based on the ATmega328P. It serves as the brain of the system, managing inputs from the joysticks, activating the motor for shooting, controlling LEDs for visual feedback, and producing sound effects through the buzzer or speaker.

    2. Analog Joysticks

    • Description: Two analog joysticks are used to control the movement of the tanks. Each joystick has two axes (X and Y) that send analog signals to the Arduino to move the tank forward, backward, left, or right.

    3. DC Motor

    • Description: A small motor used to launch the cardboard projectiles. It is triggered by a button press and provides the mechanical force necessary to propel the projectiles at a safe but effective distance.

    4. Push Buttons

    • Description: Buttons used to trigger various game functions, such as shooting the projectile. When pressed, they send a signal to the Arduino to activate the motor for projectile launch.

    5. LEDs

    • Description: Light-emitting diodes used for visual feedback on the dashboard. They indicate various game statuses such as shooting readiness, tank movement, and other game events. They help enhance the user experience.

    6. Resistors

    • Description: Electrical components used to limit the current flowing through circuits, particularly with LEDs and other components, to prevent them from burning out.

    7. Buzzer/Speaker

    • Description: A buzzer or small speaker is used for sound effects, such as the sound of shooting or explosions, adding an auditory element to the game and enhancing the gaming experience.

    8. Wires and Connectors

    • Description: Wires and connectors establish electrical connections between all components, allowing signals to flow from the joysticks to the Arduino, from the Arduino to the motor, and powering the LEDs and buzzer.

    9. Cardboard

    • Description: Used to create the lightweight projectiles fired from the tank, as well as part of the tank structure. The material is chosen for being safe and easy to handle during the game.

    10. Plastic (Lightweight)

    • Description: Plastic is used for making the tank’s shooting mechanism and other parts that need to be sturdy but lightweight. It ensures the tank remains durable while being easy to manipulate.

    11. Wood (Optional)

    • Description: Wood may be used to reinforce the structure, especially for the dashboard base or tank stands. It adds stability and helps in securing all components in place.

    12. Screws, Nuts, and Glue

    • Description: These components are used for assembling and securing the physical parts of the tank and dashboard, ensuring everything stays in place and functions properly.

    These components work together to create the interactive tank game, allowing players to control their tanks, fire projectiles, and enjoy visual and audio feedback while playing.

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates