Arduino based Angry Bird Game Controller using Flex Sensor and Potentiometer

It’s all started with a small game from the dark ages called “Mario”, right from the time of being a tiny little guy jumping on ducks to save my princess till being a masculine handsome Prince roaming in Persia (Prince of Persia) fighting against darkness to save my world behind I have been a great fan of playing video games and I grew up playing them. But they do get bored up sometimes and I feel less involved into it. Today, the advanced gaming consoles enables virtual gaming and helps us to feel the game a lot more better than a keyboard or a mouse can do.

Arduino based Angry Bird Game Controller using Flex Sensor and Potentiometer

Being an Arduino Enthusiast I tired playing the famous game called “Angry Birds” using keyboard & mouse and decided to build my own Game Controller using a Flex Sensor and a Potentiometer. When the flex sensor is pulled the bird on the catapult will also be pulled and you can use the potentiometer to set the direction in which it should be launched. Then when you release the flex sensor the bird will be launched. I pretty much enjoyed doing it, so if you are up to building something very similar then this tutorial will be a helpful. This tutorial will also be helpful in Controlling Mouse Cursor using Potentiometer.

Software and Hardware Requirements:

Software:

  1. Arduino IDE
  2. Processing IDE
  3. Angry Birds Game on Computer

Hardware:

  1. Arduino (Any Version)
  2. Potentiometer
  3. Flex Sensor
  4. 47K ohm Resistor
  5. Connecting Wires
  6. Breadboard

Concept Behind:

The Arduino Board reads the values from the Potentiometer and Flex Senor and Transmits them to the Laptop/PC through USB COM port via normal Serial.write() function. We then read this information using Processing and control the mouse cursor using the Robot class in Java which is supported by processing IDE. We have programmed the processing IDE in such a way that when the Flex sensor is pulled a mouse click will be made and based on how much it is pulled the mouse pointer will move in X direction. Then based on the value from potentiometer we will move the mouse cursor in Y direction, this way we can set the direction in which bird should be launched.

Circuit Diagram:

The circuit for playing the Angry Bird using Flex Sensor and Potentiometer is easy.

We have simple connected a potentiometer and a flex sensor to the Analog inputs (A0,A1) of the Arduino. The output of the Flex sensor is also pulled down using a 47K pull down resistor.

You can directly connect it on breadboard or solder them to a Perf board and assemble it on a gloves or something to make it more creative. I have simply used a breadboard to do my connections as shown below:

Arduino Program:

The complete Arduino code is given at the end of the tutorial. Few important lines are explained below.

We initialize the program to work with 9600 baud rate and start reading the values from Flex sensor and Potentiometer. As we know serial.write() function can send only one byte of data at a time. Since One byte is 8 bits and 2^8 = 256. We will be able to send values from 0 to 256. So we have to compress the values of Flex sensor output and Potentiometer Output into 0 to 256.

Arduino based Angry Bird Game Controller using Flex Sensor and Potentiometer schematic

To do that we use the map() function in Arduino. All the values from the flex sensor are converted from 5 to 100, so when we bend the sensor it will increment from 5 and when released it will go back to 5. To mention the mouse clicks the value 1 and 0 is used. When 1 is sent the mouse is pressed and when 0 is sent the mouse is released.

Read more: Arduino based Angry Bird Game Controller using Flex Sensor and Potentiometer


About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation and engineering. My writing style is clear and simple, and I am skilled in using infographics and diagrams. I am a great researcher and am able to present information in a well-organized and logical manner.

Follow Us:
LinkedinTwitter
Scroll to Top