Rumble for your MAKERbuino!

Hi there!

Every modern videogame supports feedback via rumble effect - and so can your MAKERbuino!

My friend @Rebeqt came up with the idea, so props to him!
I searched for the part and did the coding-stuff.
We ordered the necessary part and it’s as easy as it sounds :slight_smile:

We ordered this little thing to be exact: Mini Flat Vibrating Vibration Motor DC Motor for Arduino - Blue

It needs 3,7V and 90mAh max to start and after it has started, the motor can be operated with 3V - 5,3V and 60mAh max. But we wouldn’t recommend to operate it above 5V (if you are planning to use the motor for another purpose).

The vibration motor breakout board has three pins: VCC, GND and SIG. VCC and GND should be pretty obvious. The SIG pin is used to control the motor. The motor spins as long as the SIG pin has a HIGH signal applied to it.

To get the vibration motor up and running we’ll need to use VBAT to power the motor. This way we won’t put too much load onto the voltage regulator (and because we need 3,7V to start that thing up). We’re using the breakout header to connect the motor to the MAKERbuino. The connection diagram looks like this:

vibration motor connection

It looks like this if you’ve just connected it:

Unfortunately the motor will spin up right after powering up the MAKERbuino. It seems like pin D5 is preset to HIGH. So we’re cutting the cable connecting D5 to the SIG pin and solder a switch in between in the near future. But for now we’ll leave the SIG pin unconnected until we’ve loaded the software to test the motor. The code is, of course, pretty easy to understand as well.

#include <SPI.h>
#include <Gamebuino.h>

Gamebuino gb;
#define vibrationPin 5

void setup() {
  pinMode(vibrationPin, OUTPUT);
  digitalWrite(vibrationPin, LOW);
  gb.begin();
  gb.battery.show = false;
  gb.titleScreen(F("RumbleBuino"));
}

void loop() {
  if(gb.update())
  {
    if(gb.buttons.pressed(BTN_C))
    {
      gb.titleScreen(F("RumbleBuino"));
    }
    if(gb.buttons.repeat(BTN_A, 1))
    {
      digitalWrite(vibrationPin, HIGH);
    }
    else digitalWrite(vibrationPin, LOW);
  }
}

Even if we’re calling digitalWrite(vibrationPin, LOW) before calling gb.begin() the vibration won’t stop until we’ve started the testing tool by pressing the A-button. We can therefore assume that it has no effect since pin 5 will be set high either by the gb.start() or the gb.titleScreen() function (or both).

As long as we’re holding down the A-button the vibration motor will do its job. This is a pretty good start but not very convenient for ingame usage.

So I’ve rewritten the code to offer some different testing methods. I’m using the directional buttons to set a different vibration time. From 1 to 20 (counting clockwise from the Up-button).

#include <SPI.h>
#include <Gamebuino.h>

Gamebuino gb;
#define vibrationPin 5
int vibrationDuration = 0;   //measured in frames (20 frames per second)

void setup() {
  pinMode(vibrationPin, OUTPUT);
  gb.begin();
  gb.battery.show = false;
  gb.titleScreen(F("Vibration Test"));
}

void loop() {
  if(gb.update())
  {
    if(gb.buttons.pressed(BTN_C))
    {
      gb.titleScreen(F("Vibration Test"));
    }
    if(gb.buttons.pressed(BTN_UP))vibrationDuration = 1;
    if(gb.buttons.pressed(BTN_RIGHT))vibrationDuration = 5;
    if(gb.buttons.pressed(BTN_DOWN))vibrationDuration = 10;
    if(gb.buttons.pressed(BTN_LEFT))vibrationDuration = 20;
    if(vibrationDuration > 0)
    {
      digitalWrite(vibrationPin, HIGH);
      vibrationDuration--;
    }
    else digitalWrite(vibrationPin, LOW);
  }
}

This approach makes it very easy to use the vibration feedback within games. We’ve mounted the vibration motor onto the backside of the MAKERbuino using some double sided tape, but we’re working on a way to integrate it seamless into the MAKERbuino :slight_smile:


4 Likes

I love this thing, it has to be made into a tutorial.
Well done @Bl4ckM4ch1n3 :slight_smile:

1 Like

That’s fantastic, I’ll have to look into if I can source one locally, great guide.

I’m glad you guys like the expansion! :slight_smile:
@Dalemaunder or you could buy them in the linked shop. As far as I know they’re offering free shipping world wide. You just need to wait a bit but it’s worth it :smile:

That’s definitely the backup option, the problem is I’m very impatient when it comes to fun hardware, if I see it I want to start fiddling with it asap :laughing:

Maybe you can fix it with a PNP transistor to invert the signal. That’s a hack, but should be working.

I thought about that too but I came to the conclusion that a switch is more convenient. If I mount the vibration motor permanently I don’t want the cables to be connected to the breakout header all the time. So I’ll need to solder some cables somewhere else on the PCB.

If I don’t want to use the rumble effect I can switch it off using a hardware switch but I won’t be able to “switch off” the transistor. And I’ll be able to use pin 5 for another Hardware extension/hack if needed.

Yes switch world be fine. Adding ambiant leds could be cool too (it s will be standard on new gamebuino and should be fun for hits, shots,…).

Can’t wait to get the rumble pack inside of the MAKERbuino. Hope I can get into programming as well :wink:

There are multiple ways to go further actually. For example, using the sound pin to activate vibrations => no modifications of the game required.

Another one would be to use voice coil actuators rather than DC motors. They are much better because you can control both frequency and amplitude at the same time. Thus you have a much wider range of vibration possible. These work similarly to a speaker, except the human tactile perception is around 250Hz (max around 1000Hz), whereas sound is between 200Hz and 20kHz.

This was something I thought about too. But it would vibrate everytime a sound is played. Of course it would be pretty easy as you won’t need to modify the game. But on the other hand there could be vibration when you don’t want it. I intended to use the motor as a source of feedback for the player. Best examples would be if the player got hit or if he fires a shot etc. But using the sound pin would totally break my intended use.

So you could basically control those motors by using pin 5 as it provides a pwm function, right?
The next question is: how small are they? <- Forget about that question, found this:
https://www.precisionmicrodrives.com/product/c10-000-10mm-linear-resonant-actuator-3mm-type

This could be a pretty interesting way.

Yes, you can use PWM. And no I didn’t talk about LRA (which are just slightly better than ERM). I’m talking about this kind for example:

I heard these could be good, but I haven’t tried them yet:

I’ll definitely take a look at this after we’ve finished the current rumble project, thanks! :slight_smile: