Que pensez vous de celui ci avec intégration du timer et arret urgence
#include <Wire.h>
#include <NXShield.h>
#include <NXTTouch.h>
#include <NXTLight.h>
#include <SumoEyes.h>
#include <ACCLNx.h>
#include <NXTUS.h>
//
// declare the NXShield(s) attached to your Arduino.
//
NXShield nxshield;
//
// declare analog devices attached to nxshields.
//
NXTTouch touch1;
Void main()
{
time=90000
timer(time);
str= 100
avancer(str);// comme ça l'appel de fonction avec paramètre
}
Void timer(int time)
{
int time;
time1=milis();
if (time1>=(time)) // non bloquante !
{time=millis();
else Void arreturgence
}
}
Void arreturgence()
{
nxshield.bank_a.motorReset();
nxshield.bank_b.motorReset();
nxshield.bank_c.motorReset();
}
Void Avancer(int str)
{
int str;
// Drive both motors forward and backward for a specific number of
// rotations
delay(1000);
sprintf(str, "Both Motors Forward %d Rotations", rotations);
Serial.println(str);
str[0] = '\0';//bon reflex =)
nxshield.bank_a.motorRunRotations(SH_Motor_Both,
SH_Direction_Forward,
SH_Speed_Medium,
rotations,
SH_Completion_Wait_For,
SH_Next_Action_BrakeHold);
delay(1000);
sprintf(str, "Both Motors Reverse %d Rotations", rotations);
Serial.println(str);
str[0] = '\0';
nxshield.bank_a.motorRunRotations(SH_Motor_Both,
SH_Direction_Reverse,
SH_Speed_Medium,
rotations,
SH_Completion_Wait_For,
SH_Next_Action_BrakeHold);
Serial.println("Bank B motors >>");
}