// average.nqc // sensors #define BUTTON SENSOR_1 #define EYE SENSOR_2 // number of samples #define N 3 // average needs to be global for display int average = 0; // this function waits for a press and // release of the touch sensor void wait_for_touch() { until(BUTTON == 1); until(BUTTON == 0); PlaySound(SOUND_CLICK); } task main() { int index; int current; int samples[N]; int total = 0; // setup sensors and display SetSensor(BUTTON, SENSOR_TOUCH); SetSensor(EYE, SENSOR_LIGHT); SetUserDisplay(average, 1); // start with N samples for(index=0; index