Project showcase
Makerball

Makerball

Makerball is a DIY pinball machine kit that can be upgraded digitally with the Arduino Genuino 101. Here we show you the electronical part.

  • 2,408 views
  • 0 comments
  • 9 respects

Components and supplies

Apps and online services

About this project

Idea: Common pinball machines use hundreds of wires, chips, switches and sensors. I thought there is an easier, simpler solution to build a pinball machine (that is as much fun). That's how MAKERBALL started. So basically, Makerball is an affordable, simple DIY pinball machine kit.

I made more than six prototypes which you can find on my website (www.makerball.org) as well. Here I'm gonna show you how the electronical parts work. It's very easy.

Hardware:

Good thing is that a pinball ball is conductive. As soon as the ball hits one of the two conductive copper foil plates, electricity floats.

The conductive copper foils are connected with wires to the microcontroller. I used the Arduino Genuino 101 which worked very well.

Software:

The basic coding was written in Arduino. It is quite simple and checks whether or not there is a signal coming from the copper foils that are connected by wires to the Arduino. The Arduino communicates with the app on the smartphone via Bluetooth (Arduino Genuino 101 has an integrated Bluetooth shield). The coding of the app was written with Xcode.

I will soon put the code open-source so it can be changed, personalised and optimised as you wish. You can also write your own apps. Why not programme the sensors to use them, for example, like a game controller with left, right, shoot and jump buttons?

If you have questions in the meantime, please contact me via e-mail: hello@makerball.org

Cheers from Switzerland. Have fun!

Lain

Code

Arduino Main CodeArduino
This code takes the signals coming from the 3 sensors and the bluetooth.
unsigned long timeMillis = 0;
unsigned long timeReset = 0;



void setup()
{
  Serial.begin(9600);      // sets the serial port to 9600
  setup_bluetooth();
  setup_sensor_a();
  setup_sensor_b();
  setup_sensor_c();
  setup_sensor_d();
}

void loop()
{
  loop_bluetooth();
}


void second_loop(){
  timeMillis = millis();
  loop_sensor_a();
  loop_sensor_b();
  loop_sensor_c();
  loop_sensor_d();
}
Arduino Bluettoth CodeArduino
This code handles the bluetooth connection from the Genuino 101 to a smartphone.
//https://www.arduino.cc/en/Tutorial/Genuino101CurieBLEHeartRateMonitor
#include <CurieBLE.h>

int const outLED = 13; // customize name
boolean isBluetoothOnline = false;
int const maxSendValue = 255;
int const bluetoothSendDelay = 10;


BLEPeripheral blePeripheral;  // BLE Peripheral Device (the board you're programming)
BLEService bleService("025A7775-49AA-42BD-BBDB-E2AE77782966"); // BLE LED Service

// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEIntCharacteristic switchCharacteristic("F38A2C23-BC54-40FC-BED0-60EDDA139F47", BLERead | BLEWrite | BLENotify);


void setup_bluetooth() {
  pinMode(outLED, OUTPUT);   // initialize the LED on pin 13 to indicate when a central is connected

  // set advertised local name and service UUID:
  blePeripheral.setLocalName("LED");
  blePeripheral.setAdvertisedServiceUuid(bleService.uuid());

  // add service and characteristic:
  blePeripheral.addAttribute(bleService);
  blePeripheral.addAttribute(switchCharacteristic);


  // set the initial value for the characeristic:
  switchCharacteristic.setValue(0);

  // begin advertising BLE service:
  blePeripheral.begin();

  Serial.println("BLE LED Peripheral");
}


void loop_bluetooth() {
  // listen for BLE peripherals to connect:
  BLECentral central = blePeripheral.central();

  // if a central is connected to peripheral:
  if (central) {
    Serial.print("Connected to central: ");
    // print the central's MAC address:
    Serial.println(central.address());

    // while the central is still connected to peripheral:
    while (central.connected()) {
      isBluetoothOnline = true;
      digitalWrite(13, isBluetoothOnline);
      second_loop();
    }

    // when the central disconnects, print it out:
    Serial.print(F("Disconnected from central: "));
    Serial.println(central.address());
    isBluetoothOnline = false;
    digitalWrite(13, isBluetoothOnline);
  }
}

void sendSensorValue(int value) {

  Serial.print("write value: ");
  Serial.println(value, DEC);


  if (value <= maxSendValue) {
    switchCharacteristic.setValue(value);
  } else {
    int loops = (int) floor(value / maxSendValue);
    int modulo = (int) value % maxSendValue;

    for (int i = 0; i < loops; i++) {
      switchCharacteristic.setValue(maxSendValue);
      delay(bluetoothSendDelay);
    }
    if (modulo != 0) {
      switchCharacteristic.setValue(modulo);
    }
  }
}
Arduino Sensor CodeArduino
This code checks the signals from the conductive copper foils.
int const outputValueA = 0;  // customize name and value.

int const inPinA = 8; // customize name

unsigned long sensorBreakA = 5000;  // customize name
unsigned long sensorBreakTimeA = timeReset; // customize name

void setup_sensor_a() {
  pinMode(inPinA, INPUT); // customize name
  Serial.println("Setup up sensor A : done");
}



void loop_sensor_a() {
  int val = digitalRead(inPinA);  // customize name

  // prüfen, wie lange es dauert, bis er wieder eine prüfung macht
  Serial.println(millis(), DEC);

  // prüfen, wie lange sensor berührt wird
  if (val == 1){
    Serial.println(millis(), DEC);
  }

  if (sensorBreakTimeA == timeReset && val == 1) { // customize name
    sensorBreakTimeA = timeMillis + sensorBreakA; // customize name
    Serial.print("send value : ");
    Serial.println(outputValueA, DEC);
    sendSensorValue(outputValueA);
  } else if (sensorBreakTimeA > timeMillis) { // customize name
    //Serial.println("break :  A");             // customize name
  } else if (sensorBreakTimeA < timeMillis) { // customize name
    sensorBreakTimeA = timeReset;             // customize name
    //Serial.println(val, DEC);
  }
}

Custom parts and enclosures

Connections
This image shows how to connect the wires.
Makerball starter elements exkl x3s1hx5xpx

Schematics

Schematic of the parts
This is how the parts are connected.
170512 sensors arduino schema 3 tjlt10nmor

Comments

Similar projects you might like

Arduino Based Amazon Echo Using 1Sheeld

Project tutorial by ahmed ismail

  • 35,415 views
  • 80 comments
  • 97 respects

Arduino 101 - Intel Curie Pattern Matching Dress

Project tutorial by Kitty Yeung

  • 9,865 views
  • 17 comments
  • 52 respects

Arduino 101 Connects with Raspberry Pi Zero W

Project tutorial by Alexis Santiago Allende

  • 8,352 views
  • 0 comments
  • 17 respects

Arduino 101 Packet Radio IMU

Project showcase by Gregory O. Voronin and Phil V

  • 6,986 views
  • 2 comments
  • 19 respects

VEPCRo - Vertical External Pole Climbing Robot

Project showcase by Pramod C Wickramasinghe

  • 6,305 views
  • 11 comments
  • 32 respects

SMART CUBE: A New Way to Control Your Home

Project tutorial by Alberto Sartori

  • 13,948 views
  • 7 comments
  • 31 respects
Add projectSign up / Login