Wednesday 12 July 2017

Updated version of the drum machine: Drum machine 3.0 (Even more noise, even more portable.)

If you have read my blog before you will know about the wearable drum machine that I made previously. This year I decided to make the project true to its name. I created a drum machine that was literally on the T-shirt itself. (Picture below.) As you can see it uses four sensors. Of course, there are still limitations because currently, you require the internet connection to run the drum synthesizer.

Major new features compared to gen. 2 project:

PHONE

This year I decided that since it had to be attached to a laptop it would not be deemed wearable. So this year I decided I had to make it fully portable so it now uses an adapter to connect the Arduino to a synthesizer on my phone.


How it works.

The hardware 

The FSR when tapped allows the current to pass through.
The current passes through the copper tape to the crocodile clips.
The crocodile clips connect to the wires which are attached to the Arduino. (To learn how to wire look at the link below.)
The Arduino through an adapter connects to a phone which has a drum synthesizer which activates based on keyboard commands.

The software

The Arduino is acting as a keyboard. Each time the Arduino receives a signal from one of the FSR it produces a keyboard command.
The Synthesizer relies on keyboard commands. For example, if I were to press the button on the keyboard 'F' it would make the sound of cymbals now when you press the FSR on the shirt it would do the exact same thing.


The brains of the project (Arduino)

Connect the FSR to the Arduino


To help you with connecting the FSR to the Arduino I have provided a link. In this link it shows a diagram showing the where to connect the FSR and what type of resistor you require to do so. To understand how FSR work you can do a quick and easy test by also adding an Led into the circuit and seeing how based on how hard you press the led for instance you can make the LED brighter and brighter. If you scroll further down it shows you multiple example codes.

Make it print out keyboard commands when pressed
An important part of the project is the synthesizer. This part of the project remains the same. It uses an online drum machine synthesizer that requires keyboard commands. This way whenever you touch an FSR it produces a keyboard command which gets sent to the synthesizer and produces the sound. The key component of making keyboard commands comes from the Arduino Leonardo which is the only Arduino with the capability of emulating a keyboard or a mouse. To look at how to make keyboard commands using the Arduino Leonardo you can look at the code below or take a look at my older version of the blog. In that, it shows the code for using readings to print keyboard commands.

/* Modified FSR code and USB keyboard code */

#include "Keyboard.h"

int fsrAnalogPin0 = 0; // FSR is connected to analog 0
int fsrAnalogPin1 = 1;
int fsrAnalogPin2 = 2;
//int LEDpin = 11;      // connect Red LED to pin 11 (PWM pin)
int fsrReading0;      // the analog reading from the FSR resistor divider
int fsrReading1;
int fsrReading2;
int pressForce = 20;
int LEDbrightness;

void setup(void) {
  Serial.begin(9600);   // We'll send debugging information via the Serial monitor
//  pinMode(LEDpin, OUTPUT);
  Keyboard.begin(); // initialize control over keyboard
}

void loop(void) {
  fsrReading0 = analogRead(fsrAnalogPin0);
  delay(50);
  fsrReading1 = analogRead(fsrAnalogPin1);
  delay(50);
  fsrReading2 = analogRead(fsrAnalogPin2);
  delay(50);
  //Serial.print("Analog reading = ");
  //Serial.println(fsrReading);

  if (fsrReading0 > pressForce) {
    Keyboard.print("e");
  }
  if (fsrReading1 > pressForce) {
    Keyboard.print("f");
  }
  if (fsrReading2 > pressForce) {
    Keyboard.print("v");
  }

  // we'll need to change the range from the analog reading (0-1023) down to the range
  // used by analogWrite (0-255) with map!
  // LEDbrightness = map(fsrReading, 0, 1023, 0, 255);
  // LED gets brighter the harder you press
  // analogWrite(LEDpin, LEDbrightness);

  delay(50);
}



1 comment:

  1. Great update. Can you please post connection diagrams for using the FSR?

    ReplyDelete