#pragma config(Sensor, S1, MSPFM, sensorI2CCustom)
#include "drivers/mindsensors-pfmate.h"
void doTest(int channel) {
nxtDisplayTextLine(5, "Chan: %d", channel);
PlaySound(soundBeepBeep);
while(bSoundActive) EndTimeSlice();
nxtDisplayTextLine(6, "Motor: A");
nxtDisplayTextLine(7, "Dir: fwd");
for (int speed = 1; speed < 8; speed++) {
MSPFMcontrolMotorA(MSPFM, channel, MSPFM_FORWARD, speed);
wait1Msec(500);
}
nxtDisplayTextLine(7, "Dir: brake");
MSPFMcontrolMotorA(MSPFM, channel, MSPFM_BRAKE, 0);
wait1Msec(500);
nxtDisplayTextLine(7, "Dir: rev");
for (int speed = 1; speed < 8; speed++) {
MSPFMcontrolMotorA(MSPFM, channel, MSPFM_REVERSE, speed);
wait1Msec(500);
}
nxtDisplayTextLine(7, "Dir: float");
MSPFMcontrolMotorA(MSPFM, channel, MSPFM_FLOAT, 0);
wait1Msec(500);
PlaySound(soundBeepBeep);
while(bSoundActive) EndTimeSlice();
nxtDisplayTextLine(6, "Motor: B");
nxtDisplayTextLine(7, "Dir: fwd");
for (int speed = 1; speed < 8; speed++) {
MSPFMcontrolMotorB(MSPFM, channel, MSPFM_FORWARD, speed);
wait1Msec(500);
}
nxtDisplayTextLine(7, "Dir: brake");
MSPFMcontrolMotorB(MSPFM, channel, MSPFM_BRAKE, 0);
wait1Msec(500);
nxtDisplayTextLine(7, "Dir: rev");
for (int speed = 1; speed < 8; speed++) {
MSPFMcontrolMotorB(MSPFM, channel, MSPFM_REVERSE, speed);
wait1Msec(500);
}
nxtDisplayTextLine(7, "Dir: float");
MSPFMcontrolMotorB(MSPFM, channel, MSPFM_FLOAT, 0);
wait1Msec(500);
PlaySound(soundBeepBeep);
while(bSoundActive) EndTimeSlice();
nxtDisplayTextLine(6, "Motor: A+B");
nxtDisplayTextLine(7, "Dir: fwd+rev");
for (int speed = 1; speed < 8; speed++) {
MSPFMcontrolMotorAB(MSPFM, channel, MSPFM_FORWARD, speed, MSPFM_REVERSE, speed);
wait1Msec(500);
}
nxtDisplayTextLine(7, "Dir: brake");
MSPFMcontrolMotorAB(MSPFM, channel, MSPFM_BRAKE, 0, MSPFM_BRAKE, 0);
wait1Msec(500);
nxtDisplayTextLine(7, "Dir: rev+fwd");
for (int speed = 1; speed < 8; speed++) {
MSPFMcontrolMotorAB(MSPFM, channel, MSPFM_REVERSE, speed, MSPFM_FORWARD, speed);
wait1Msec(500);
}
nxtDisplayTextLine(7, "Dir: float");
MSPFMcontrolMotorAB(MSPFM, channel, MSPFM_FLOAT, 0, MSPFM_FLOAT, 0);
wait1Msec(500);
}
task main() {
nxtDisplayCenteredTextLine(0, "Mindsensors");
nxtDisplayCenteredBigTextLine(1, "PFMate");
nxtDisplayCenteredTextLine(3, "Test 1");
wait1Msec(2000);
for (int channel = 1; channel < 5; channel++) {
doTest(channel);
}
}