20 November 2024

Team 7 - Bomberman Controller

Team 7 - Bomberman Controller Description: This is the Bomberman Bomb controller, our conceptual model for this was a controller that takes the shape of the bombs that are used in game, we chose to work with this because we want the players to feel like the bomberman, by holding what seems to be a bomb and using all of the controls on said bomb. For our inputs we have a potentiometer, two switches, a light sensor, and the ultrasonic range sensor. For these inputs, we know looking at the potentiometer rotates left and right and logically we mapped this to the in-game characters left and right movement, turn it right the character will move right, keep it in the middle the character won't move. For the switches that control the vertical movement, we thought it was best to place these in a way where it made sense, the user flicks the top switch up which will make the character move up and if the user flicks the top switch down the character will stop moving upward. The same can be said for the lower switch, the user flicks that switch down and the character will move down, and when flicked up the character will stop moving down. We decided that lighting a fuse to a bomb is one of the crucial parts of cartoon looking bombs like ours so we incorporated the light sensor on the circuit playground to act as if you are lighting the fuse to the bomb. To accomplish this we have a small hole cut out on the controller that is angled to have light reach the circuit playground inside the controller, and the player will wear a small light on a finger on their right hand when playing so they can easily have access to a light while being able to control the switches and potentiometer, without taking away from experience. When light reaches the circuit playground the in-game character will place a bomb down and it will shortly detonate. The ultrasonic range sensor is housed inside our bomb’s fuse as you can easily wave your hand and have it be registered back to the circuit playground. The ultrasonic range sensor is our power-up sensor, as in the game the character can obtain power-ups that can be used in different ways so we thought of something that still incorporates part of the bomb’s design into our controls. Question: Does the integration of the light, and ultrasonic range sensor for the controller enhance the player’s immersive experience or does it make them feel disconnected from the overall interaction?
Controller Photo


Schematic Photo



Video




Code
// Team 7
// Donovan Peckham
// Timothy Williams

#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>


#include <Keyboard.h>
#include <KeyboardLayout.h>
#include <Keyboard_da_DK.h>
#include <Keyboard_de_DE.h>
#include <Keyboard_es_ES.h>
#include <Keyboard_fr_FR.h>
#include <Keyboard_hu_HU.h>
#include <Keyboard_it_IT.h>
#include <Keyboard_pt_PT.h>
#include <Keyboard_sv_SE.h>

#define trigPin 9
#define echoPin 6


const int LEDpin = 13;
const int switchPinUp = A6;
const int switchPinDown = A4;
const int Right = KEY_RIGHT_ARROW;
const int Left = KEY_LEFT_ARROW;
const int Up = KEY_UP_ARROW;
const int Down = KEY_DOWN_ARROW;
const int Z = 122;
const int X = 120;
int potPin = A0;
int sensorValue;


void setup() {
  pinMode(LEDpin, OUTPUT);
  pinMode(switchPinUp, INPUT);
  pinMode(switchPinDown, INPUT);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  Serial.begin(9600);
  while(!Serial);
  Keyboard.begin();
}


void loop() {
  // Potentiometer for Left and Right Movement
  sensorValue = analogRead(potPin);
  Serial.println(sensorValue);
  delay(10);
  if (sensorValue > 700) {
    Keyboard.press(Left);
  }
  if (sensorValue < 300) {
    Keyboard.press(Right);
  }
  if (sensorValue > 300 && sensorValue < 700) {
    Keyboard.release(Left);
    Keyboard.release(Right);
  }

  // Switches for Up and Down Movement
  int switchStateUp = analogRead(switchPinUp);
  int switchStateDown = analogRead(switchPinDown);
  Serial.println(switchStateUp);
  Serial.println(switchStateDown);


  if (switchStateUp < 50) {
    Keyboard.press(Up);
  }
  if (switchStateUp > 100) {
    Keyboard.release(Up);
  }
  if (switchStateDown < 50) {
    Keyboard.press(Down);
  }
  if (switchStateDown > 100) {
    Keyboard.release(Down);
  }

  // Ultrasonic Range Sensor for Powerup Activation
  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;


  if (distance < 10) {
    digitalWrite(LEDpin, HIGH);
    Keyboard.press(Z);
  } else {
    digitalWrite(LEDpin, LOW);
    Keyboard.release(Z);
  }
  if (distance >= 400 || distance <= 0) {
    Serial.println("Out of range");
  } else {
    Serial.print(distance);
    Serial.println(" cm");
  }
  delay(500);

  // Light Sensor for Bomb Placement
  int light = analogRead(A8);
  Serial.print("\t");
  Serial.println(light);
  if (light > 4) {
    Keyboard.press(X);
  }
  if (light <= 1) {
    Keyboard.release(X);
  }

}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.