Help with Sonar

Hello, I am in an engineering class where we are program a Stop/ Track system in which an ultrasonic sensor is supposed to “sense” the objects movement and have an LED light flash as the object passes. We are also supposed to use a timer. The teacher is not very good, and we are unable to ask for help on our programming project.
untilTouch (BumpSwitch);
wait (.05);
clearTimer (T1);
time1 (T1)=1;
if {( SensorValue ((Sonar) <=10) && (SensorValue (Sonar) >=1))
turnLEDOn (LED);}
{((Sensorvalue (Sonar) >=14));
turnLEDOff (LED);}
clearTimer (T1);

This is what we have so far.

In this case, I suggest breaking down the program into psuedocode. What should the robot be doing, how long it should be doing each action, in what order should the actions occur, what will cause the actions to change, etc.

Once you have that, start to lay it out in a program in the order that it should be run. Typically, a while loop will control the duration of the program and if/else if/else statements will control the decision-making in the program.

Finally, start to test out each section of the code individually to ensure that the individual segments are working properly before implementing it into the full code. This will ensure that the individual parts work before trying to assemble the full, more complex “machine”.

For more information on both the precoding (psuedocode, flowcharts, etc) and the programming (control structures, sensorValue command, etc), please look through the “Planning and Behaviors” and “Sensing” sections of the ROBOTC for VEX Cortex curriculum (link below).

Planning and Behaviors curriculum section: