in the beginning of my code i do : US.Resume(); (i had already did US.Start()
than at the end, US.Suspend();
but my Ultrasonic Sensor will not restart.
help plz
how can i pause US detecting and resume it after ?.
public static int usVal;
public static void usRead() //TREAD DU US SENSOR
{
bool infini = true;
while (infini==true)
{
usVal = USdetect(_pin);
}
}
public static Thread US = new Thread(usRead);
public static TristatePort _pin;
...Main()...{
_pin = new TristatePort((Cpu.Pin)FEZ_Pin.Digital.Di52, false, false, Port.ResistorMode.Disabled);
US.Start();
while(true){
while (ScanAvant > 15 || ScanAvant < 10)
{
Thread.Sleep(100);
Debug.Print(ScanAvant.ToString());
ScanAvant = usVal;
}
......
US.suspend();
.....
//it is a long code
US.resume();
}}
If you want to control the thread more accurately I would use an auto reset or manual reset event instead of relying on suspend/resume. You can easily âmissâ a pulse with suspend/resume and the reading thread will be in a deadlock or something like that.
yes, i want to control my thread, but when i do resume. The us sensor wouldnât work
is it a problem with servo ?
because, when i do US.startâŚUS.suspendâŚUS.resume and i donât use servo, it work
but if i use servoâŚit doesnât work