Jump a Mole (unfinished)

by nathanfliertje in Living > Pranks, Tricks, & Humor

399 Views, 0 Favorites, 0 Comments

Jump a Mole (unfinished)

IMG_20170123_213811.jpg

The end result should be a response-time-game in wich the player should be waiting for the molde to jump out of the hole. When the mole does, the play should pick it up as quickly as possible and put it back in the hole.

When some rounds have passed, the player should see how many ‘stars’ he has achieved!

Unfortunately I didn't finish this game in time so this instructable will not exactly cover all the steps required to create the real version. However you will get a good start by following this instructable!

Have fun creating and playing it!

Resources

Resources:

Arduino related:

· Arduino

· arduino cables (x7)

· arduino breadboard

· 10kΩ resistor

· button

· servo motor (+ standard plastic attachable)

Wood:

· plywood

· timber (2cm thick)

Other stuff:

· wood glue

· spring (14,2mm x 33mm)

· fretsaw

· a saw that can saw through the 2cm thick timber

Before going to the next step I would recommend taking a good look at the picture of the introduction page.

Rack & Pinion & ‘mole’

IMG_20170123_212831.JPG
IMG_20170123_213603.jpg

In this step we will create the resources that will disable the spring from ‘releasing the mole’. The whole idea is that the mole is going to be locked by a piece of wood that will be put through the lower half of the mole. This piece of wood should be pushed inside and outside of the mole using a pinion that is being rotated by the servo motor.

To create the rack and pinion you should first create the pinion.

You should do this by drawing a perfect circle of about 4cm on multiplex. After this you should draw the tooth’s. You don’t have to draw all of them, since we will only need our lock to be moved for like 3cm. After you have done this, you can get the pinion out of the wood using the fretsaw.

Now we will use this pinion to draw the ‘rack-lock’. First lay your pinion over another piece of plywood. Draw one tooth, rotate the pinion one tooth further, etc.

Dont forget to attach the plastic servo-attachable to the middle of the pinion.

Now we are going to create the mole. (Mine didn’t even resemble a mole) This mole should be 28 cm long and should be created out of the timber. Important to note is that it should contain a hole, in wich the lock should fit quite easily.

I created this hole by first sawing three thin beams, sawing one of these through the middle, and gluing this together with some spacing in the middle-beam.

Base Construction

IMG_20170123_213336.jpg
IMG_20170123_213430.jpg

The idea of this construction is fairly simple: the mole should fit in it and should be lockable by the rack and pinion we already created.

If you have made this, we are going to measure how high the servo motor should be. You can easily test this by attaching your pinion to your servo, laying your lock on the rail and putting your pinion on the right height.

When the mole is down, the button will be pressed and the mole should be locked inside his hole. Therefore you should create 4 mini holes underneath the place where the mole is going to be. These holes are for the connection between the button and the arduino. Around this button, we can put the spring.

The Arduino

IMG_20170123_214638.jpg

Connect the button and the servo to the arduino according to the image above.

Not visible parts:

The yellow wire from the servo goes to pin 9

The yellow wire from the button goes to pin 2

The red wire from the breadboard to the arduino button goes to 5V

The black wire from the breadboard to the arduino goes to Grnd

Arduino Code

This is the code you should use:

#include <Servo.h>

Servo myServo;

int pos = 0;

int buttonState = 0;

const int endPos = 55;

const int servoPin = 9;

const int buttonPin = 2;

bool locked = false;

const int minReleaseDelay = 1500;

const int maxReleaseDelay = 7000;

const int rotDelay = 18;

void setup() {

Serial.begin(9600);

myServo.attach(servoPin);

pinMode(buttonPin, INPUT);

}

void loop() {

buttonState = digitalRead(buttonPin);

if(buttonState == HIGH && !locked){

Lock();

ReleaseAfterTime();

}

}

void Lock(){

Serial.println("lock");

locked = true;

for(int i = 0; i < endPos; i += 1){

Serial.println(i);

myServo.write(i);

delay(rotDelay);

}

}

void ReleaseAfterTime(){

Serial.println("release");

int delayTime = random(minReleaseDelay, maxReleaseDelay);

delay(delayTime);

for(int i = endPos; i > 0; i -= 1){

Serial.println(i);

myServo.write(i);

delay(rotDelay);

}

locked = false;

}

In void Setup we set up the servo and the pins for use.

In void Loop we detect a click of the button.

If the button is clicked, we invoke void Lock and void ReleaseAfterTime. Those two functions do exactly as their names tell.

In void Setup we set up the servo and the pins for use.

In void Loop we detect a click of the button.

If the button is clicked, we invoke void Lock and void ReleaseAfterTime. Those two functions do exactly as their names tell.

How to Finish This for Real

To finish this product, you should make sure that the button that is underneath the mole has a connection with the breadboard. (instead of putting a button directly on the breadboard, as I did)

The player should also get feedback of his response time somehow. A simple way of showing this to the player can be made by setting up some led’s in wich the amount of led’s indicate how fast the player responded. (like a 3-star rate you often see in mobile games)

Furthermore you could create something nice out of the current ‘mole’ we created.

I hope you will have as much fun as I had creating this!