Instructables

Wireless Finger Drum

Featured

Step 6: Make it wireless!

RevIO was designed to be XBee ready.
See details of RevIO pins at http://www.instructables.com/id/Build-The-RevIO-Arduino-Clone-My-Way/

Just plug the breakout board in, loads the sketch, and plays!

What's the sketch does?
RevIO or Arduino is monitoring the Analog pins connected to FSRs. Whenever the FSR get pressed, it transmits the command wirelessly via XBee transmitter (attached to Arduino) to XBee receiver module connected to the PC.
And the Processing program on the PC will translate the command and play the drum sound accordingly.

Following is an Arduino Sketch, upload the sketch to Arduino. (already included in the zip files in the following step, FSRControl.ina)

Note: The XBee module or XBee Breakout board need to be removed  while uploading the sketch to Arduino or RevIO.
Because the TX and RX pins on FTDI adapter for uploading sketch share the same TX and RX pins of XBee module.

/*
FSRControl.ino
*/

// minimum reading of the sensors that generates a note 
const int THRESHOLD = 25;  

int pinA0 = 0;
int pinA1 = 1;
int pinA2 = 2;
int pinA3 = 3;

static const int avgCount = 4;

int valFSR1, valFSR2, valFSR3, valFSR4 = 0;

int arr1[avgCount];
int arr2[avgCount];
int arr3[avgCount];
int arr4[avgCount];

int i;
int index = 0;

//Average the values in the averaging arrays

void avg()
{
  valFSR1 = valFSR2 = valFSR3 = valFSR4 = 0;

  for(i = 0; i < avgCount; i++)
  {
    valFSR1 += arr1[i];
    valFSR2 += arr2[i];
    valFSR3 += arr3[i];
    valFSR4 += arr4[i];
  }

  valFSR1 /= avgCount;
  valFSR2 /= avgCount;
  valFSR3 /= avgCount;
  valFSR4 /= avgCount;
}

void setup() {
  // reset average arrays
  for (i = 0; i < avgCount; i++)
  {
    arr1[i] = 0;
    arr2[i] = 0;
    arr3[i] = 0;
    arr4[i] = 0;
  }
  index = 0;
   // start serial port at 9600 bps:
  Serial.begin(9600);
}

void loop() {

    // out actual values into the averaging arrays
    arr1[index] = analogRead(pinA0);
    arr2[index] = analogRead(pinA1);
    arr3[index] = analogRead(pinA2);
    arr4[index] = analogRead(pinA3);

  
    // increment index,
    // if index exceeds array sizes reset to zero
     index++;
     if (index >= avgCount)
     {
       index = 0;
     }
   
    // calculate average values
    avg();
  
    // divided the value by 4 to scale it down to 0 - 255
    // FSR 1
    if((valFSR1 / 4) > THRESHOLD) {
      //Serial.print(valFSR1 / 4, DEC); Serial.print(", ");
      Serial.write('1');
    }

    // FSR 2      
    else if((valFSR2 / 4) > THRESHOLD) {
      //Serial.print(valFSR2 / 4 , DEC); Serial.print(", ");
      Serial.write('2');
    }
  
    // FSR 3
    else if((valFSR3 / 4) > THRESHOLD) {  
      //Serial.print(valFSR3 / 4, DEC); Serial.print(", ");
      Serial.write('3');
    }   
  
    // FSR 4 
    else if((valFSR4 / 4) > THRESHOLD) {
      //Serial.print(valFSR4 /4 , DEC); Serial.println();
      Serial.write('4');
    }
    else {
      Serial.write('0');  
    }
   delay(100);
}


Wireless XBee

In order to wirelessly communicate between PC and Arduino, we need two XBee Modules, and one FTDI cable. One XBee module will be connected to Arduino without FTDI cable.

The second XBee Module will be connected to PC or Laptop via FTDI cable (or xBee Buddy).

It would take up a lot of space and time to explain the installation, configuration, and test the XBee module. Instead I provide you the links that you could use as the starting point on how to work with XBee module(s).

Here are my WIKI XBee tutorials, show how to configure and test XBee module using Hyperterminal, and X-CTU:

Configure XBee using AT Commands.

Configure XBee using X-CTU Software.

My XBee video tutorial.

 
Remove these adsRemove these ads by Signing Up