

The following is your code, but with the changes mentioned above implemented. To answer your question, after the first case is executed, all the other while loops are checking if the value is smaller than both your upper AND lower limits.
#Robotc while loop code#
That isn't good practice, as it can lead to placing blocks of code inside loops unintentionally. What is causing the array to store values before the while loops finish positioning the head to the proper angle? The sonar does not scan once the head has hit each 45 degree interval respectively even though the programming seems correct.

While(SensorValue<1200 & SensorValue<1100) While(SensorValue<1900 & SensorValue<1800)

While(SensorValue<2800 & SensorValue<2700) Int frontscandistance //Array that hold each of the 5 angles at 45 degree intervalsįrontscandistance = SensorValue #pragma config(Motor, port5, steer, tmotorVex393_MC29, openLoop) #pragma config(Motor, port4, drivem, tmotorVex393_MC29, openLoop) #pragma config(Motor, port2, head, tmotorVex393_MC29, openLoop) #pragma config(Sensor, dgtl7, wheelrot, sensorQuadEncoder) #pragma config(Sensor, dgtl5, steerrot, sensorQuadEncoder) #pragma config(Sensor, dgtl3, bsonar, sensorSONAR_inch) #pragma config(Sensor, dgtl1, fsonar, sensorSONAR_inch) Obstacle Avoidance Robot (Head rotation system in the middle) #pragma config(Sensor, in1, headrot, sensorPotentiometer) However, the sonar sensor stores values for certain angles before the head has actually reached that specified angle. The sonar sensor must be able to scan a distance and then move 45 degrees, repeating the process until it reaches 180 degrees (to the right) only once it reaches that point of rotation, the scan distances are put into an array to be used by an avoidance task to be developed at a later time. I have found the potentiometer values for the 5 sets of 45 degree intervals with the total 180 degrees required and documented. The robot needs to be able to check 180 degrees in front of it, so I have made a "head" the sensor is mounted on that is attached to a motor with an axle that runs through a potentiometer. WHERE BETWEEN M.freightLeave AND DATEDIFF(DAY,-1, M.missionStart) BETWEEN datediff(day, +1, M.missionEnd) AND M.freightReturn) AND LM.I am using a sonar sensor to create an obstacle avoiding robot. SELECT Result.MissionNo, Result.TransportStatus What about a query without the loop: ALTER PROCEDURE datetime, as int, datetime I tried inserting the sets into a temp tableīut then found out that temp tables do not output. When the stored procedure is called I only get the first set. WHERE I.itemid = DATEADD(DAY, understand that it is not the done thing to loop in a query but I haven’t succeeded doing it another way. WHERE BETWEEN M.freightLeave AND DATEDIFF(DAY,-1, M.missionStart) BETWEEN datediff(day, +1, M.missionEnd) AND M.freightReturn) AND LM.Packaging = 'A Main' WHERE BETWEEN M.freightLeave AND M.freightReturn and I.itemID = items in missions that have packaging "A Main". INNER JOIN Missions AS M on LM.missionID = M.MissionID INNER JOIN LinkMissionItem as LM ON I.itemID = LM.itemID WHEN BETWEEN M.freightLeave AND DATEDIFF(DAY,-1, M.missionStart) BETWEEN datediff(day, +1, M.missionEnd) AND M.freightReturn) THEN 'Tan' WHEN BETWEEN M.missionStart AND M.missionEnd THEN 'Orange' M.missionStart, M.missionEnd, M.freightReturn, LM.Packaging, SELECT I.itemID, I., M.MissionName, M.MissionNo, M.freightLeave,

WHILE <= Result.MissionNo, Result.TransportStatus ALTER PROCEDURE datetime, as int, datetime I would like to find a way of returning the result of this query to my C# program.
