⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ballhandle.c

📁 一个机器人提足球的代码!基于神经网络! 一个机器人提足球的代码!基于神经网络!
💻 C
字号:
#ifndef _BALLHANDLE_
#define _BALLHANDLE_
#include "HardwareInfo.c"
#include <SetMotor.h>
#include <SetTenthS.h>
#include "turnAngle.c"
#include <GetUltrasound.h>
#include "angle.c"
#include "turn.c"

void ballHandle(unsigned int rightDistance, unsigned int leftDistance, unsigned int distance, unsigned char yfy, unsigned char jGuan)
{
    unsigned int distance_middle = 0;   //后超声波测距模块的返回值
    unsigned int distance_left = 0;   //后超声波测距模块的返回值
    SetMotor(_MOTOR_left_, 2, 100);
    SetMotor(_MOTOR_right_, 2, 100);
    SetTenthS(2);
    turnAngle(180, yfy);
    for (int _FOR_3_ = 0; _FOR_3_ < 3; _FOR_3_++ )
    {
        distance_left = GetUltrasound(_ULTRASOUND_left_);
        if ( distance_left<100 )
        {
            break;
        }
    }
    if ( distance_left<leftDistance )
    {
        for (int _FOR_0_ = 0; _FOR_0_ < 3; _FOR_0_++ )
        {
            distance_middle = GetUltrasound(_ULTRASOUND_middle_);
            if ( distance_middle<100 )
            {
                break;
            }
        }
        if ( distance_middle<distance )
        {
            angle(270);
            SetMotor(_MOTOR_left_, 0, 100);
            SetMotor(_MOTOR_right_, 0, 100);
            SetTenthS(2);
            angle(180);
            SetMotor(_MOTOR_left_, 0, 100);
            SetMotor(_MOTOR_right_, 0, 100);
            SetTenthS(2);
            turnAngle(90, yfy);
        }
        else
        {
            SetMotor(_MOTOR_left_, 2, 100);
            SetMotor(_MOTOR_right_, 2, 11);
            SetTenthS(6);
            turn(jGuan);
        }
    }
    else
    {
        if ( distance_left>rightDistance )
        {
            for (int _FOR_1_ = 0; _FOR_1_ < 3; _FOR_1_++ )
            {
                distance_middle = GetUltrasound(_ULTRASOUND_middle_);
                if ( distance_middle<100 )
                {
                    break;
                }
            }
            if ( distance_middle<distance )
            {
                angle(90);
                SetMotor(_MOTOR_left_, 0, 100);
                SetMotor(_MOTOR_right_, 0, 100);
                SetTenthS(2);
                angle(180);
                SetMotor(_MOTOR_left_, 0, 100);
                SetMotor(_MOTOR_right_, 0, 100);
                SetTenthS(2);
                turnAngle(270, yfy);
            }
            else
            {
                SetMotor(_MOTOR_left_, 2, 11);
                SetMotor(_MOTOR_right_, 2, 100);
                SetTenthS(6);
                turn(jGuan);
            }
        }
        else
        {
            for (int _FOR_2_ = 0; _FOR_2_ < 3; _FOR_2_++ )
            {
                distance_middle = GetUltrasound(_ULTRASOUND_middle_);
                if ( distance_middle<100 )
                {
                    break;
                }
            }
            if ( distance_middle<distance )
            {
                SetMotor(_MOTOR_left_, 0, 100);
                SetMotor(_MOTOR_right_, 0, 100);
                SetTenthS(2);
                SetMotor(_MOTOR_left_, 2, 10);
                SetMotor(_MOTOR_right_, 2, 100);
                SetTenthS(6);
                turn(jGuan);
            }
            else
            {
                SetMotor(_MOTOR_right_, 2, 10);
                SetMotor(_MOTOR_left_, 2, 100);
                SetTenthS(6);
                turn(jGuan);
            }
        }
    }
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -