Hi
can someone look at my code to make sure the LCD for antonymous will work because i have no way to check until Monday also i would like for when the “autons” touch sensor is changed during user control it would display antonymous left or right for 5 seconds and then go back to the hows my driving thing.
Also if you want you can look over the rest of my code to see if it could be better in any ways.
Thanks!
#pragma config(Sensor, dgtl2, ad, sensorTouch)
#pragma config(Sensor, dgtl4, autons, sensorTouch)
#pragma config(Sensor, dgtl11, au, sensorTouch)
#pragma config(Sensor, dgtl12, solenoid, sensorDigitalOut)
#pragma config(Motor, port2, a1, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port3, a2, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port4, a3, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port5, a4, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, a5, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, a6, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, d1, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port9, d2, tmotorVex393_MC29, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
#pragma platform(VEX)
//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include “Vex_Competition_Includes.c”
void pre_auton() {
// Set bStopTasksBetweenModes to false if you want to keep user created tasks running between
// Autonomous and Tele-Op modes.
bStopTasksBetweenModes = true;
}
task autonomous() {
if(SensorValue(autons) == 1)
{
clearLCDLine(0); // Clear line 1 (0) of the LCD
clearLCDLine(1); // Clear line 2 (1) of the LCD
bLCDBacklight = true; // Turn on LCD Backlight
displayLCDPos(0,0); // Set the cursor to line 0, position 0 (top line, far left)
displayNextLCDString(“autonymous”); // Display “Hello from”
displayLCDPos(1,0); // Set the cursor to line 1, position 0 (bottom line, far left)
displayNextLCDString(“left”); // Display “ROBOTC :]”
setMultipleMotors(100, d1,);
sleep(300);
setMultipleMotors(100, a1, a2, a3,);
setMultipleMotors(100, a4, a5, a6,);
sleep(300);
setMultipleMotors(50, d1, d2);
setMultipleMotors(0, a1, a2, a3,);
setMultipleMotors(0, a4, a5, a6,);
sleep(1700);
setMultipleMotors(0, a1, a2, a3,);
setMultipleMotors(0, d1, d2,);
setMultipleMotors(0, a4, a5, a6,);
sleep(100000);
} else {
clearLCDLine(0); // Clear line 1 (0) of the LCD
clearLCDLine(1); // Clear line 2 (1) of the LCD
bLCDBacklight = true; // Turn on LCD Backlight
displayLCDPos(0,0); // Set the cursor to line 0, position 0 (top line, far left)
displayNextLCDString(“autonymous”); // Display “Hello from”
displayLCDPos(1,0); // Set the cursor to line 1, position 0 (bottom line, far left)
displayNextLCDString(“right”); // Display “ROBOTC :]”
setMultipleMotors(100, d2,);
sleep(300);
setMultipleMotors(100, a1, a2, a3,);
setMultipleMotors(100, a4, a5, a6,);
sleep(300);
setMultipleMotors(50, d1, d2);
setMultipleMotors(0, a1, a2, a3,);
setMultipleMotors(0, a4, a5, a6,);
sleep(1700);
setMultipleMotors(0, a1, a2, a3,);
setMultipleMotors(0, d1, d2,);
setMultipleMotors(0, a4, a5, a6,);
sleep(100000);
}
}
task usercontrol() {
clearLCDLine(0); // Clear line 1 (0) of the LCD
clearLCDLine(1); // Clear line 2 (1) of the LCD
bLCDBacklight = true; // Turn on LCD Backlight
displayLCDPos(0,0); // Set the cursor to line 0, position 0 (top line, far left)
displayNextLCDString(“How’s My Driving”); // Display “Hello from”
displayLCDPos(1,0); // Set the cursor to line 1, position 0 (bottom line, far left)
displayNextLCDString(“1-800-765-9876”); // Display “ROBOTC :]”
while(true)
{
if(vexRT[Btn8L] == 1)
{
SensorValue[solenoid] = 1;
}
if(vexRT[Btn8L] == 0)
{
SensorValue[solenoid] = 0;
}
// Set drive motors
setMultipleMotors(vexRT[Ch2], d1);
setMultipleMotors(vexRT[Ch3], d2);
// Loop while robot's upper sensor is pressed in (add in pneumatic pistons when we get some)
if(SensorValue(au)) {
SensorValue[solenoid] = 1;
// Stop all motors
setMultipleMotors(0, a1, a2, a3, a4,);
setMultipleMotors(0, a5, a6,);
sleep(200);
setMultipleMotors(-50, a1, a2, a3,);
setMultipleMotors(-50, a4, a5, a6,);
sleep(100);
// If button 6U (upper right shoulder button) is pressed, active solenoid
//SensorValue[solenoid] = vexRT[Btn8D];
} else {
// If B5U is pressed, motors gets set to full forward speed
// If B5D is pressed, motors get set to full backward speed
setMultipleMotors((vexRT[Btn5U] - vexRT[Btn5D]) * 100, a1, a2, a3, a4,);
setMultipleMotors((vexRT[Btn5U] - vexRT[Btn5D]) * 100, a5, a6,);
//setMultipleMotors((vexRT[Btn7L] - vexRT[Btn7R]) * 127, a1, a2, a3, a4,);
//setMultipleMotors((vexRT[Btn7L] - vexRT[Btn7R]) * 127, a5, a6,);
}
sleep(20);
}
}