当前位置: 首页 > 工具软件 > vex > 使用案例 >

C语言VEX编程示范,VEX编程 ROBOT C 主程序万向轮.c

臧俊杰
2023-12-01

#pragma config(Sensor, in2,  Gyro,  sensorGyro)

#pragma config(Sensor, in3,  LiftPot,  sensorPotentiometer)

#pragma config(Sensor, in7,  poten,  sensorPotentiometer)

#pragma config(Sensor, in8,  poten2,  sensorPotentiometer)

#pragma config(Sensor, dgtl1,  TouchSensor,

sensorTouch)

#pragma config(Sensor, dgtl2,  Claw_Encode,

sensorNone)

#pragma config(Sensor, dgtl5,

TouchSensor_Auto, sensorTouch)

#pragma config(Sensor, dgtl6,  Jumper_1,

sensorDigitalIn)

#pragma config(Sensor, dgtl7,  Jumper_2,

sensorDigitalIn)

#pragma config(Sensor, dgtl8,  Jumper_side,

sensorDigitalIn)

#pragma config(Sensor, dgtl9,  Base_Encode,

sensorQuadEncoder)

#pragma config(Sensor, dgtl11, Encode_1,  sensorQuadEncoder)

#pragma config(Motor,  port1,

intake_1,  tmotorVex393_HBridge,

openLoop, reversed)

#pragma config(Motor,  port2,

LeftRun_1,  tmotorVex393HighSpeed_MC29, openLoop,

reversed)

#pragma config(Motor,  port3,

LeftRun_2,  tmotorVex393HighSpeed_MC29, openLoop)

#pragma config(Motor,  port4,

ThrowTool2,

tmotorVex393HighSpeed_MC29,

openLoop, reversed)

#pragma config(Motor,  port5,

UpDown_1,  tmotorVex393_MC29, openLoop,

reversed)

#pragma config(Motor,  port6,

UpDown_2,  tmotorVex393_MC29,

openLoop)

#pragma config(Motor,  port7,

ThrowTool,  tmotorVex393HighSpeed_MC29, openLoop)

#pragma config(Motor,  port8,

RightRun_1,

tmotorVex393TurboSpeed_MC29,

openLoop)

#pragma config(Motor,  port9,

RightRun_2,

tmotorVex393HighSpeed_MC29,

openLoop, reversed)

#pragma config(Motor,  port10,

intake_2,  tmotorVex393_HBridge,

openLoop, reversed)

//

#pragma platform(VEX)

//Competition Control and Duration Settings

#pragma competitionControl(Competition)

#include "Vex_Competition_Includes.c"  //Main competition background code...do not modify!

#pragma autonomousDuration(20)

#pragma userControlDuration(120)

/

int lock=2450;//tai shen zui gao jiao du

int out=1550;//tai shen zhong jian zhi

//int wavein=2700;//bai dong jin lai

//int waveout=1900;//bai dong chu qu

int Btm=1440;//tai shen zui di zhi

//int power=15;

int JoyCtrl=3;//3hao wei cfr yaokong fangshi

int CloseHold=2100;//1000+800

int BasePower=127;

int LiftPower=127;

int ThrowingPower=127;

int ThrowingPower2=127;

int ControlMod=0;

int Fantai=0;

int gro=76;

int Flager=0;

int Flager1=1;

int mode=0;

int side;

int key_value=0;

int Flager3=0;

int Flager4=0;

//int now=SensorValue[Gyro];

//different robot_move mode

#include "void.h"

#include "joystick.h"

#include "mainauto.h"

/

//

//  Pre-Autonomous Functions

//

// You may want to perform some actions before the competition

starts. Do them in the

// following function.

//

/

void pre_auton()

{

SensorType[in1] = sensorNone;

wait1Msec(100);

SensorType[in1] = sensorGyro;

wait1Msec(100);

// now block - use our own comp control

bStopTasksBetweenModes = true;

}

//

void key_test ()

{

if (SensorValue(TouchSensor_Auto) ==

1&&(key_value==0))

{

AutoPro();

key_value=1;

}

}

/

//

//  Autonomous Task

//

// This task is used to control your robot during the

autonomous phase of a VEX Competition.

// You must modify the code to add your own robot specific

commands here.

//

/

task autonomous()

{

AutoPro();

}

///s//

//

//  User Control Task

//

// This task is used to control your robot during the user

control phase of a VEX Competition.

// You must modify the code to add your own robot specific

commands here.

//

/

task usercontrol()

{

#include "userctrl.h"

}

 类似资料: