#pragma config(Sensor, S1, HTSPB, sensorI2CCustom9V)
#include "drivers/hitechnic-superpro.h"
task main() {
ubyte buttonmask = 0;
HTSPBsetupIO(HTSPB, 0x03);
while(true) {
HTSPBwriteIO(HTSPB, 0x00);
eraseDisplay();
nxtDisplayTextLine(2, "running");
wait1Msec(random(5000) + 3000);
if(random(1) > 0) {
HTSPBwriteIO(HTSPB, 0x01);
buttonmask = 0x10;
} else {
HTSPBwriteIO(HTSPB, 0x02);
buttonmask = 0x20;
}
time1[T1] = 0;
while (HTSPBreadIO(HTSPB, 0x30) != buttonmask) {
wait1Msec(5);
}
eraseDisplay();
nxtDisplayTextLine(2, "Time: %d", time1[T1]);
while (HTSPBreadIO(HTSPB, 0x30) != 0x30) {
wait1Msec(5);
}
}
}