This is an example of how to use the SetSensorHTGyro, SensorHTGyro, Wait, TextOut, NumOut, and ButtonPressed functions.
#define GYRO IN_1
#define SAMPLESIZE 100
task main()
{
int i, y, d;
int v, offset;
float gyroAvg, gyroSum = 0;
int data[SAMPLESIZE];
int cSet[7];
for (i=0; i<SAMPLESIZE; i++) {
data[i] = v;
gyroSum += v;
}
gyroAvg = gyroSum/SAMPLESIZE;
offset = gyroAvg+0.5;
for (i=0; i<SAMPLESIZE; i++) {
d = data[i] - offset;
if (d < -3) d = -3;
if (d > 3) d = 3;
d += 3;
cSet[d]++;
}
for (i=0; i<7; i++) {
if (i==0)
else if (i==6)
else
y-= 8;
}
}