Hi all. I have a simple program that starts 2 ultrasonic sensors that are to control 1 servo each.Then, inside a While loop I Get both sensors and finally either Print to Screen or Setservo. It compiles OK but does not run correctly, however if I comment either one of the sensors it works ok either printing or controlling the servo.
In the process of debugging I discovered that one of the problems seems to be that if you “Start” two sensors, the second one disables the first. Does this mean (please NOT!) that the controller can only control one USensor at a time? I have tried changing ports, inserting Waits etc to no avail. Please help. My project needs a few more US sensors in tandem to work.
Thanks for any guidance on this.
Here is the code in question:
#include “UserAPI.h”
int loop=1;
int left;
int right;
void main (void)
{
StartUltrasonic (1, 11);
StartUltrasonic (2, 12);
while (loop ==1)
{
left=GetUltrasonic (1,11);
right=GetUltrasonic (2,12);
left=left2.55;
right=right2.55;
if (left >=255)
{
left=255;
}
if (right >=255)
{
right=255;
}
SetServo (3, left);
SetServo (2, right);
}
}
//where is the problem? please help, thank you