robotc
college code of robotc
git clone https://9o.is/git/robotc.git
linetracking.c
(908B)
1 //*!!Sensor, S2, lightsensor, sensorLightActive, , !!*//
2 //*!! !!*//
3 //*!!Start automatically generated configuration code. !!*//
4 const tSensors lightsensor = (tSensors) S2; //sensorLightActive //*!!!!*//
5 //*!!CLICK to edit 'wizard' created sensor & motor configuration. !!*//
6
7
8 // This program uses the light sensor to track the left side of a line
9
10
11 task main() {
12 int threshold = 43;
13 ClearTimer(T1);
14 while(time1[T1] < 3000) {
15 if(SensorValue(lightsensor) < threshold) {
16 motor[motorC]=0;
17 motor[motorB]=50;
18 } else {
19 motor[motorC]=50;
20 motor[motorB]=0;
21 }
22 }
23 }