Stupid Pet Trick: Mini Pinball

Title: Stupid Pet Trick- Mini Pinball

Date: 29th September 2017

Instructor: Marcela Godoy

Aim: To construct a basic version of Pinball with paddles, boundary wall using servo motors, potentiometer and arduino board. The end product should be engaging and presentable.

Materials used:

Servo motors-2

Potentiometers-2

Arduino board

Breadboard

Jumper wires

Cardboard

Images Printouts

Ball

 

Development:

The initial idea is shown in the sketch below. The design included rotation of servo motors being controlled by potentiometers. The boundary wall and pedals (attatched to motors) were to be made by cardboard. Addtionally, there would be an LED attatched to each paddle which would light on everytime the ball would come in contact with the paddle.

To start off, a servo motor was operated using a potentiometer, the circuit and code was tested to ensure it worked.

This video shows the movement of the servo motor being controlled by the potentiometer.

Another servo motor was attached and operated using a second potentiometer. Code was adjusted accordingly.

A button and LED were added to the circuit with the operation of the LED dependent on the button. Code was adjusted accordingly.

Another button and LED were added to the circuit with the operation of the LED dependent on the button. Code was adjusted accordingly.

The paddle was designed using cardboard. In place of the button of the circuit, copper tape was used on the paddle. A small gap was kept between the copper tape on the paddle. When the ball (covered in copper tape) would come in contact with the paddle, the circuit would be completed, and the LED would light up.

Similarly, another paddle was designed. Both were attached to servo motors and were tested using a ping pong ball covered in copper tape. A boundary wall was designed, and motors were placed on the sides.

The video shows a rudimentary version of the game being played.

The servo motors stopped working. This was a setback as the had to be replaced with standard servo motors and the boundary wall had to be re-designed to accommodate their bigger size.

The idea of using the LEDs was let go of. This was because as the game was being played, the ball would often not hit the paddle at the right place as the paddles would tilt. This was another setback which could not be dealt with in the limited time.

Even with that setback however, the basic idea was still in place and functional.

The connections of the potentiometers were extended using alligator clips for easier control.

The endings of the potentiometer were soldered. This enabled better control by the user.

For visual appeal, printouts were glued to the walls and floor. The (almost) final version is shown as below:

A few other final adjustments were made, including attatchment of the potentiometers to the corners of the board, creating a hole in the upper part of the cardboard, adjusting the height of the board (so that the ball rolls down freely).

A couple of rules for the game were decided. The player has to try and get the ball stuck in the hole against the slope to win. If the ball goes below the paddle, the player loses.

The following videos show the game being played by two different players on the day of the exhibition.

 

Learnings:

  • It is worthwile to plan the designing process well to avoid making a lot of changes during development.
  • Using code samples from Arduino examples and adjusting them acoording to the needs of your circuit.
  • The need to use the right cardboard. For the purposes of mini pinball, thin yet strong cardboard was optimal for the baddles.
  • Small servo motors can be a disappointment, its better to use standard ones to avoid having to redesign your project.
  • How to create an external button, using copper tape.
  • Technique and effectiveness of soldering.
  • Final touches make presentation a lot better.
  • Continuous feedback from users is very important. It enables you to make changes which result in making the project more appealing, interactive and engaging. It was through feedback that printouts were added, potentiometers were soldered and hole was made.

 

#include <Servo.h>

Servo servo1;// create servo object to control a servo
Servo servo2;

int pot1pin = 0;  // analog pin used to connect the potentiometer
int val1;    // variable to read the value from the analog pin


int pot2pin = 1;
int val2;

// set pin numbers:
const int button1Pin = 2;     // the number of the pushbutton pin
const int led1Pin =  12;      // the number of the LED pin

const int button2Pin = 4;     // the number of the pushbutton pin
const int led2Pin =  13;      // the number of the LED pin

// variables will change:
int button1State = 0;// variable for reading the pushbutton status
int button2State = 0;

void setup() {
  servo1.attach(9);// attaches the servo on pin 9 to the servo object
  servo2.attach(11);

  // initialize the LED pin as an output:
  pinMode(led1Pin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(button1Pin, INPUT);

   // initialize the LED pin as an output:
  pinMode(led2Pin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(button2Pin, INPUT);

}

void loop() {
  val1 = analogRead(pot1pin);            // reads the value of the potentiometer (value between 0 and 1023)
  val1 = map(val1, 0, 1023, 40, 100);     // scale it to use it with the servo (value between 0 and 180)
  servo1.write(val1);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there

  val2 = analogRead(pot2pin);            // reads the value of the potentiometer (value between 0 and 1023)
  val2 = map(val2, 0, 1023, 50, 110);     // scale it to use it with the servo (value between 0 and 180)
  servo2.write(val2);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there

  // read the state of the pushbutton value:
  button1State = digitalRead(button1Pin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (button1State == HIGH) {
    // turn LED on:
    digitalWrite(led1Pin, HIGH);
  } else {
    // turn LED off:
    digitalWrite(led1Pin, LOW);
}

 // read the state of the pushbutton value:
  button2State = digitalRead(button2Pin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (button2State == HIGH) {
    // turn LED on:
    digitalWrite(led2Pin, HIGH);
  } else {
    // turn LED off:
    digitalWrite(led2Pin, LOW);
}

}

One thought on “Stupid Pet Trick: Mini Pinball

  1. I saw you had LED’s in your breadboard, maybe you should have used them too 🙂
    but anyways it was funny because of how slow the potentiometers moved the paddles. I’m glad your process included improvements on your electronic components and also soldering!
    great job and documentation Ahmad!

Leave a Reply