ADXL193 Accelerometer Assistance Needed!

Hello,

I am I need of some assistance with some code I have found. I want to be able to measure the G-load of the deceleration of a helmet I designed with various materials and constructions built with-in it.

Currently I have in my possession: Arduino Uno Board; ADXL193 +/- 250g accelerometer; breadboard and jumper wires.

Here is the code:

import processing.opengl.*;
import processing.serial. *;
Serial serial;
int WIDTH = 1440;
int analog_in = 0;

PFont font;
void setup() {
size(WIDTH,900,0PENGL);
font= loadFont("Helvetica-Bold-20.vlw");
textFont(font, 20);
textAiign(TOP,LEFT);
serial =new Serial(this, Serial.list()[O], 115200);
background(255);
smooth();
}

int val = 0;
void draw(){
background(255);
fiii(O);
stroke(O);
while (serial.available() > 0) {
int c =serial.read();
if (c >= '0' && c <= '9') {
val =val  * 10 + ((int)c - (int)'O');
} else if (c == '\n') {
next(val);
val= 0;
}
}

text("input: "+ analog_in, 40,140);
renderBuffer();
text("max-noise: " + maxlnBuffer(), 340,90);
text("min-noise: "+ minlnBuffer(), 340, 40);
text("initial min: " + maxlnBuffer2(), 40,40);
text("initial max:"+ minlnBuffer2(), 40,90);
}
float minInBuffer() {
float min= 99999;
for (inti= 0; i <WIDTH;  i++) {
if (min> buffer[i])
min = buffer[i];
}
return min;
}

float maxlnBuffer() {
float max= 0;
for (inti= 0; i <WIDTH;  i++) {
if (max< buffer[i])
max = buffer[i];
}
return max;
}

float minlnBuffer2() {
float min = 99999;
for (inti = 0; i < WIDTH; i++) {
if (min > buffer2[i])
min = buffer2[i];
}

return min;
}
float maxlnBuffer2() {
float max = 0;

for (inti= 0; i <WIDTH; i++){
if (max< buffer2[i])
max = buffer2[i];
}
return max;
}

int index= 0;
float buffer[] =new float[ WIDTH];
float buffer2[] = new float[WIDTH];
float min = 509.0;
float max = 506.0;
float m = 2.0/(max-  min);
float b = 1.0 - m *max;

void next(int val) {

analog_in = val;
float ace=  (analog_in - 508)12;
//println(val);
if (pause)
return;
float gz = m *val + b;
//float gz = 5.f*val*1OOO.f/(8.f*1024.f);

buffer[index] = gz;
buffer2[index] = ace;
index= (index+ 1)% WIDTH;
}
boolean pause= false;

void keyPressed() { if (key == 's') { saveFrame("snapshot.png"); pause =true;
}
if (key == 'p' II key == ' ') {
pause = !pause;
}
}
void renderBuffer() {
int in = WIDTH-1;
float last= 0;
for (inti= index; i <WIDTH; i++, in--) {
line(in,heightl2+buffer[i],in+1 ,last);
last = heightl2+buffer[i];
}
for (inti = 0; i <index; i++, in--) {
line(in,heightl2+buff er[i],in+1 ,last);
last = heightl2+buffer[i];
}
}

Now, with this code the writter used the same equippment as me and managed to get usuable results from the code. I, cannot. The code is riddled with errors:

sketch_feb02a.ino:9:16: error: invalid suffix "PENGL" on integer constant
sketch_feb02a:1: error: 'import' does not name a type
sketch_feb02a:2: error: 'import' does not name a type
sketch_feb02a:3: error: 'Serial' does not name a type
sketch_feb02a:7: error: 'PFont' does not name a type
sketch_feb02a.ino: In function 'void setup()':
sketch_feb02a:9: error: 'size' was not declared in this scope
sketch_feb02a:10: error: 'font' was not declared in this scope
sketch_feb02a:10: error: 'loadFont' was not declared in this scope
sketch_feb02a:11: error: 'textFont' was not declared in this scope
sketch_feb02a:12: error: 'TOP' was not declared in this scope
sketch_feb02a:12: error: 'LEFT' was not declared in this scope
sketch_feb02a:12: error: 'textAiign' was not declared in this scope
sketch_feb02a:13: error: 'serial' was not declared in this scope
sketch_feb02a:13: error: expected type-specifier before 'Serial'
sketch_feb02a:13: error: expected `;' before 'Serial'
sketch_feb02a:14: error: 'background' was not declared in this scope
sketch_feb02a:15: error: 'smooth' was not declared in this scope
sketch_feb02a.ino: In function 'void draw()':
sketch_feb02a:20: error: 'background' was not declared in this scope
sketch_feb02a:21: error: 'O' was not declared in this scope
sketch_feb02a:21: error: 'fiii' was not declared in this scope
sketch_feb02a:22: error: 'stroke' was not declared in this scope
sketch_feb02a:23: error: 'serial' was not declared in this scope
sketch_feb02a:33: error: 'text' was not declared in this scope
sketch_feb02a:35: error: invalid operands of types 'const char [12]' and 'float' to binary 'operator+'
sketch_feb02a:36: error: 'minlnBuffer' was not declared in this scope
sketch_feb02a:37: error: invalid operands of types 'const char [14]' and 'float' to binary 'operator+'
sketch_feb02a:38: error: invalid operands of types 'const char [13]' and 'float' to binary 'operator+'
sketch_feb02a.ino: In function 'float minInBuffer()':
sketch_feb02a:42: error: 'inti' was not declared in this scope
sketch_feb02a:42: error: 'i' was not declared in this scope
sketch_feb02a:43: error: 'buffer' was not declared in this scope
sketch_feb02a.ino: In function 'float maxlnBuffer()':
sketch_feb02a:51: error: 'inti' was not declared in this scope
sketch_feb02a:51: error: 'i' was not declared in this scope
sketch_feb02a:52: error: 'buffer' was not declared in this scope
sketch_feb02a.ino: In function 'float minlnBuffer2()':
sketch_feb02a:60: error: 'inti' was not declared in this scope
sketch_feb02a:60: error: 'i' was not declared in this scope
sketch_feb02a:61: error: 'buffer2' was not declared in this scope
sketch_feb02a.ino: In function 'float maxlnBuffer2()':
sketch_feb02a:70: error: 'inti' was not declared in this scope
sketch_feb02a:70: error: 'i' was not declared in this scope
sketch_feb02a:71: error: 'buffer2' was not declared in this scope
sketch_feb02a.ino: At global scope:
sketch_feb02a:78: error: initializer fails to determine size of 'buffer'
sketch_feb02a:79: error: initializer fails to determine size of 'buffer2'
sketch_feb02a.ino: In function 'void next(int)':
sketch_feb02a:88: error: expected ',' or ';' before numeric constant
sketch_feb02a:90: error: 'pause' was not declared in this scope
sketch_feb02a.ino: In function 'void keyPressed()':
sketch_feb02a:101: error: 'key' was not declared in this scope
sketch_feb02a:101: error: 'saveFrame' was not declared in this scope
sketch_feb02a:103: error: 'key' was not declared in this scope
sketch_feb02a:103: error: expected `)' before 'II'
sketch_feb02a.ino: In function 'void renderBuffer()':
sketch_feb02a:110: error: 'inti' was not declared in this scope
sketch_feb02a:110: error: 'i' was not declared in this scope
sketch_feb02a:111: error: 'heightl2' was not declared in this scope
sketch_feb02a:111: error: 'line' was not declared in this scope
sketch_feb02a:114: error: 'i' was not declared in this scope
sketch_feb02a:115: error: 'heightl2' was not declared in this scope
sketch_feb02a:115: error: 'buff' was not declared in this scope
sketch_feb02a:115: error: 'line' was not declared in this scope

Along with "import does not have a name type" in an orange box.

Ultimately, I want the code to interpret the results from the accelerometer and display them to me on a graph so I can draw some conclusions.

Goes without saying really, your help is very much appreciated.

Thanks
Mike