📄 recoverytheball.c
字号:
#include "HardwareInfo.c"
#include <GetCompoI.h>
#include <SetLED.h>
#include <SetMotor.h>
int main(void)
{
unsigned char MaxValue = 0; //当前复眼所有通道的最大值返回值
unsigned char var0 = 65; //复眼阀值。
unsigned char MaxNo = 0; //复眼最大值的通道号
unsigned char NO3 = 0; //当前复眼的第三通道号返回值
unsigned char NO4 = 0; //当前复眼的第四通道号返回值
unsigned char NO5 = 0; //当前复眼的第五通道号返回值
while (1)
{
MaxValue = GetCompoI(_COMPOUNDEYE_1_, 9);
MaxNo = GetCompoI(_COMPOUNDEYE_1_, 8);
if ( MaxValue>=var0 )
{
SetLED(_LED_1_, 1);
if ( MaxNo==7 )
{
SetMotor(_MOTOR_left_, 0, 70);
SetMotor(_MOTOR_right_, 2, 30);
}
else
{
if ( MaxNo==6 )
{
SetMotor(_MOTOR_left_, 0, 70);
SetMotor(_MOTOR_right_, 2, 10);
}
else
{
if ( MaxNo==5 )
{
SetMotor(_MOTOR_left_, 0, 50);
SetMotor(_MOTOR_right_, 1, 100);
}
else
{
if ( MaxNo==1 )
{
SetMotor(_MOTOR_left_, 2, 30);
SetMotor(_MOTOR_right_, 0, 70);
}
else
{
if ( MaxNo==2 )
{
SetMotor(_MOTOR_left_, 2, 10);
SetMotor(_MOTOR_right_, 0, 70);
}
else
{
if ( MaxNo==3 )
{
SetMotor(_MOTOR_left_, 1, 100);
SetMotor(_MOTOR_right_, 0, 50);
}
else
{
SetMotor(_MOTOR_left_, 0, 100);
SetMotor(_MOTOR_right_, 0, 100);
}
}
}
}
}
}
}
else
{
SetLED(_LED_1_, 0);
SetMotor(_MOTOR_left_, 0, 50);
SetMotor(_MOTOR_right_, 2, 50);
}
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -