Sample Code

void main(void) { int go = 1; /* escape from infinite while loop */ int on = 0; /* turns to 1 when motor is on */ while(go) { if(!on) { if(digital(1)) { /* checks the sensor in port 1 */ charge(); /* plays 'charge' tune */ motor(0, 100); /* turns on the motor in port 0 to 100 power */ on=1; } } if(digital(2)) { /* checks sensor in port 2 */ off(0); /* turns off motor in port 0 */ go=0; } } }