Introduction: ArDuell

A basic "1v1-shooting game" made in technology class using Arduino and Processing.
Compete against your friend in a one o one duel. After one is killed (i.e. hit by five bullets), a new harder round starts. Best out of three.

The characters are controlled in Y-direction with ultrasonic sensors.
Black player uses "Z" to shoot, white player "-".

To reset the game press "R".

Keep scrolling to see how the project was done :)

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Circuit Switching

1x Arduino Uno
3x Breadboards
2x HC-SR04 Ultrasonic Sensors

Connect the Ultrasonic sensors as shown in the circuit switching image:

Sensor 1:
Echo -> Digital Input 2
Trig -> Digital Input 4
Gnd -> GND
Vcc -> 5V

Sensor 2:
Echo -> Digital Input 12
Trig -> Digital Input 13
Gnd -> GND
Vcc -> 5V

Later we built in the sensors in a simple box made of cardboard, and put the Arduino in an old VHS case.
All this is optional of course, but we wanted it to look nice and the sensors were easier to use when fixed to the cardboard box.

Step 2: Arduino Code

Now you will have to upload the Arduino code to your device.
The code is found in the "Arduino_ArDuell.ino" file at the bottom of the page, or here below:

const int trigPin = 13;
const int echoPin = 12;
const int echoPin2 = 2;
const int trigPin2 = 4;

void setup() {
// initialize serial communication:
pinMode(trigPin, OUTPUT);
pinMode(trigPin2, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(echoPin2, INPUT);

void loop() {
float duration, duration2, cm, cm2;
digitalWrite(trigPin, LOW);
digitalWrite(trigPin, HIGH);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
digitalWrite(trigPin2, LOW);
digitalWrite(trigPin2, HIGH);
digitalWrite(trigPin2, LOW);
duration2 = pulseIn(echoPin2, HIGH);
cm = microsecondsToCentimeters(duration);
cm2 = microsecondsToCentimeters(duration2);


float microsecondsToCentimeters(float microseconds) {
return microseconds / 29 / 2; }

Step 3: Processing Code

When the Arduino code is uploaded to your device and you're getting values from the sensors (check the Serial Print), you are ready for the Processing code:

1. Create a folder called "Processing_ArDuell"
2. Download the Processing code. Either from the "Processing_ArDuell.pde" file at the bottom of this page or from Then put it in the folder you just created.

3. Download all pictures from and put them in the same folder.

Step 4: Run the Game

Now open the .pde file with Processing and press play to run the game. Enjoy!

If the characters aren't moving you might need to do a minor change in the code. Find the following row and change the "2" to what usb port you're using:
myPort = new Serial(this, Serial.list()[2], 9600); //change the "2" to the usb port you're using

Made by Axel Holmqvist and Henrik Kockum at Polhemskolan, Lund (Sweden).
Mentor: Axel Månsson

Mail us at if you have any questions.

Be the First to Share


    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Arduino Contest 2020

      Arduino Contest 2020

    2 Discussions


    2 years ago

    Sir: can you reupload pictures ? link is not working

    thanks a Lot !


    5 years ago on Introduction

    Sorry that I have problems with the part of arduino code:





    It was said that RodKnapp is not defined in the scope, and I guess its the same with VitKnapp.

    May you please kindly offer the information about this? Is there anything missing in the code?

    Anyway, its a good project, Thanks for your sharing :)