|
悬赏5乐币未解决
麻烦哪位在程序旁边注释一下没一行程序的意思!谢谢
#define COLOR_SENSOR S2
#define COLOR_MOVE OUT_C
#define COLOR_DROP OUT_B
task main()
{
SetSensorTouch(TOUCH_SENSOR_DROP);
SetSensorColorFull(COLOR_SENSOR);
OnFwd(COLOR_MOVE,50);//马达旋转
Off(COLOR_MOVE);
RotateMotorEx(COLOR_MOVE,50,55,0,false,true);//转动50度
while(true)
{
int degrees = 0;
unsigned int raw[];
int colorval,scaled;
unsigned int norm[];
ReadSensorColorEx(COLOR_SENSOR, colorval, raw, norm, scaled);//colorval可以返回程序detect到6种颜色,raw可以返回RGB的值
switch (colorval)
{
case INPUT_REDCOLOR:
degrees = 0;
break;
case INPUT_YELLOWCOLOR:
degrees = 90;
break;
case INPUT_GREENCOLOR:
degrees = 180;
break;
case INPUT_BLUECOLOR:
degrees = 270;
break;
default:
break;
}
RotateMotorEx(COLOR_MOVE,50,degrees,0,false,true);
OnFwd(COLOR_DROP,50);
RotateMotorEx(COLOR_DROP,50,360*0.8,0,false,true);
RotateMotorEx(COLOR_MOVE,50,(360-degrees)%360,0,false,true);
Wait(300);//Delay 300毫秒
}
}
|
|