FollowMe Game using Arduino

Introduction

FollowMe Game using Arduino It is an Arduino-based game that challenges players to follow a pattern of lights with a button press. The game is made up of several components, including an Arduino microcontroller board, LEDs, a button, and resistors.

To play the game, a pattern of lights is displayed on the LEDs. The player must then press the button in the correct sequence to match the pattern of lights. If the player presses the button in the correct sequence, the game continues to the next level. If the player makes a mistake, the game ends.

Hardware Required

Components#Buy From Amazon
Arduino UNO1Buy Now
Buzzer1Buy Now
LED Red, Green, and Blue3Buy Now
Buttons3Buy Now
Resistors 150Ω6Buy Now
Jumper WiresFewBuy Now
Breadboard1Buy Now

Circuit Diagram

Follow-Me-Simple-Arduino-based-game-Circuit

Working Explanations

The LEDs and the button are connected to the digital input and output pins of the Arduino board, and the resistors are used to limit the amount of current flowing through the LEDs.

The Arduino is programmed to generate a random pattern of lights on the LEDs, and the player must then replicate the pattern by pressing the button in the correct sequence. If the player presses the button in the correct sequence, the Arduino generates a new pattern of lights for the next level. If the player makes a mistake, the Arduino signals the end of the game.

The Arduino can be programmed to keep track of the player’s progress and provide feedback on their performance. For example, the Arduino can be programmed to display the player’s score on an LCD display or to light up an LED display. The game can be made more challenging by increasing the number of levels or by decreasing the amount of time the player has to replicate the pattern.

Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow

Code

//For more Projects: www.arduinocircuit.com
/*
 * Lights In Sequence
 * 3 leds are hooked up to pins 2,4,6
 * blink in a random order
 */

//blue, red, green
int colorLedPins[] = {4,2,6};
int colorTones[] = {262, 349, 494};
int colorButtonPins[] = {5,3,7};


int randNumber;

const int piezoPin = 9;
int colorOrder[10];
int userNumber = 0;
int computerNumber = 0;
int buttonState = 0;
int length = 10;

void setup() {
  int n;
  for(n=0; n<3; n++){
    pinMode(colorLedPins[n], OUTPUT);
    digitalWrite(colorLedPins[n], LOW);
  }
  
  for(n=0; n<length; n++) colorOrder[n] =0;
  
  for(n=0; n<3; n++){
    pinMode(colorButtonPins[n], INPUT);
  }
}

void loop() {
  if(userNumber < length)
  {
    checkForUserInput();
  }
  else
  {
    playSequence();
  }
}

void checkForUserInput()
{
   for(int n=0; n<3; n++)
  {
      if(checkForButton(colorButtonPins[n])){
         playColor(n);
         colorOrder[userNumber++] = n;
      } 
  }
}

bool checkForButton(int pinNumber){
  buttonState = digitalRead(pinNumber);
  bool returnValue;
  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {    
      returnValue = true;
  }
  else {
      returnValue = false;
  }
  return returnValue;
}

void playColor(int colorNum){
  tone(piezoPin, colorTones[colorNum], 100);
  blinkLight(colorLedPins[colorNum]);  
}

void blinkLight(int ledPin)
{
  digitalWrite(ledPin, HIGH);
  delay(200);
  digitalWrite(ledPin, LOW);
  noTone(piezoPin);
  delay(100);
}  

void playSequence(){
  if(computerNumber >= length) computerNumber = 0;
  
  playColor(colorOrder[computerNumber++]);
}

Applications

  1. Education: FollowMe Game using Arduino can be used as a tool for teaching electronics, programming, and game design to beginners. The game provides a fun and interactive way to introduce basic concepts such as LEDs, buttons, resistors, and programming.
  2. Entertainment: The FollowMe game can be played as a standalone game or integrated into a larger gaming platform. The game provides a simple and engaging challenge that can be enjoyed by players of all ages.
  3. Skill-building: The FollowMe Game using Arduino can be used as a training tool to improve hand-eye coordination, reaction time, and memory skills. The game can be made more challenging by increasing the number of levels or decreasing the amount of time the player has to replicate the pattern.
  4. Therapy: The FollowMe game can be used as a therapeutic tool for individuals with cognitive or motor impairments. The game can be customized to suit the needs of different individuals and can be used to improve cognitive function, fine motor skills, and hand-eye coordination.
  5. Research: The FollowMe game can be used as a research tool to study human behavior and cognition. The game can be customized to manipulate different variables such as the difficulty level, the speed of the pattern, or the type of feedback provided to the player. The data collected from the game can be used to study decision-making, memory, attention, and learning processes.

Conclusion

Overall, FollowMe is a fun and engaging game that can be used to introduce beginners to electronics, programming, and game design.

Leave a Comment


error: