What's the value of GYRO_SENSITIVITY ?
Also you can use this processing code to display what happens exactly :
import processing.serial.*;
import javax.media.opengl.*;
import processing.opengl.*;
Serial myPort; // The serial port
float[] values;
int currentVal = 0;
PGraphics pg;
//Gestion du temps à rajouter
void setup ()
{
// set the window size:
size(450, 350, OPENGL);
// List all the available serial ports
println(Serial.list());
// I know that the first port in the serial list on my mac
// is always my Arduino, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[0], 9600);
// don't generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');
// set inital background:
background(0);
pg = createGraphics(400,300, JAVA2D);
values = new float[400];
for (int i = 0; i < values.length-1; i++)
values[i] = 150;
delay(400);
}
void draw ()
{
background(0);
pg.beginDraw();
pg.background(35);
DrawGraph(values, currentVal, color(127,34,255));
pg.text("value :" + values[currentVal], 5,50);
pg.endDraw();
image(pg,25,25);
}
void serialEvent (Serial myPort)
{
// get the ASCII string:
String inString = myPort.readStringUntil('\n');
if (inString != null)
{
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
float inByte = float(inString);
if(currentVal < values.length-1)
{
currentVal++;
}
else
{
for (int i = 1 ; i < values.length ; i++)
{
values[i-1] = values[i];
}
}
values[currentVal] = inByte;
}
}
void DrawGraph(float[] data, int drawUntil, color c)
{
float tmp,tmp2;
//Dessin du tableau
if(drawUntil <= data.length)
{
for (int i = 1 ; i < drawUntil ; i++)
{
pg.stroke(c);
pg.strokeWeight(1);
tmp = map(data[i],-500,500,300,0);
tmp2 = map(data[i-1],-500,500,300,0);
pg.line(i-1,tmp2,i,tmp);
}
}
}
You need to modify your arduino code like this :
//Ricardo Arturo Cabral <ing dot cabral dot mejia at gmail
#include <Wire.h>
#include "itg3200.h"
ITG3200 gyro;
void setup(){
Serial.begin(9600);
gyro.begin(0x68);
delay(1000);
}
int cnt=0;
void loop(){
Serial.print(int(gyro.getX())/5);
delay(50);
}
If the processing program fails at starting, just relaunch it, the serial is not completely reliable at starting and makes the program crash.