Problem detection of frequency vibrations of an epileptic seizure patient

I’m trying to measure vibrations in frequency with a Wii Nunchuk accelerometer, i have found the acceleration of the the Nunchuk in the x-axis. However, converting these values to frequency have been an issue, since i do not know what type of units the Wii Nunchuk measures in. In addition, I’m trying to open a solenoid valve to allow air to inflate a balloon and stop pumping air at a certain time shortly after. I have a threshold value where this will be executed at above a certain frequency. Also, i have a darlington transistor from the Arduino to the solenoid.

Created By: Alberto Lopez
Date: 03/23/14
accel sketch
simple sketch to output average values of the x-axes
detects if acceleration goes above threshold
and turns on Solenoid if it goes above threshold

To Do’s

  1. Convert acceleration to Frequencies of an epileptic patient.

  2. Stop the balloon from inflating after a couple of seconds.

const int xPin = 4; // analog input pins
const int THRESHOLD = 1000; //threshold
#define Solenoid 7 //solenoid pin

const int numReadings = 10;
int readings[numReadings]; // the readings from the analog input
int index = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average

void setup()
Serial.begin(9600); // note the higher than usual serial speed
pinMode(Solenoid, OUTPUT); //solenoid set as an ouput
for (int thisReading = 0; thisReading < numReadings; thisReading++)
readings[thisReading] = 0;

void loop()

// subtract the last reading:
total= total - readings[index];
// read from the sensor:
readings[index] = analogRead(xPin);
// add the reading to the total:
total= total + readings[index];
// advance to the next position in the array:
index = index + 1;

// if we’re at the end of the array…
if (index >= numReadings)
// …wrap around to the beginning:
index = 0;

// calculate the average:
average = total / numReadings;
// send it to the computer as ASCII digits
Serial.print("X_avg = "); //print
delay(1000); // delay in between reads for stability

if (average >= THRESHOLD) //if vibrations are greater than

digitalWrite(Solenoid, HIGH); //turn on solenoid
digitalWrite(Solenoid, LOW); //turn off solenoid


frequency only involves units of time.

What units does the Wii Nunchuk Accelerometer use, does it use milli-g's? I have not been able to find the datasheet for the Wii Nunchuk, which would explain this information. Also, does it make sense to program the solenoid this way, i'm using a unl2803a darlington transistor with a solenoid, but have not been able to get it to open using this code.