Hi i am trying to program my robot to use a LCD but as soon as i put the program in the LCD worked the way i wanted it to but the robot wouldn’t move. can someone fix it so the LCD is displaying the stuff i want but the robot also actually working and moving.
I also tried using 2 while loops but that made the LCD not work but the robot did work.
#pragma config(Sensor, in7, autonp, sensorNone)
#pragma config(Sensor, in8, autonc, sensorPotentiometer)
#pragma config(Sensor, dgtl2, ad, sensorTouch)
#pragma config(Sensor, dgtl4, autons, sensorTouch)
#pragma config(Sensor, dgtl10, claw, sensorDigitalOut)
#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, d2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, d1, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port7, a4, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, a5, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, a6, 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 autonc ]<=500 ) {
//fence stars
if(SensorValue autonp ] >=500 ) {
//do the fence stars on the left side
}
else {
//do the fence stars on the right side
}
}
else {
//field stars
if(SensorValue autonp ] <=499 ) {
//do the field stars on the left side
}
else {
//Do the field stars on the right side
}
}
}
task usercontrol() {
while(true)
{
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("auto side"); // Display left or right for auto
displayLCDPos(1,0); // Set the cursor to line 1, position 0 (bottom line, far left)
displayNextLCDString("which one"); // Display which auto the robot is going to do
sleep(5000);
// somthin funny about vex
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-345-7686"); // Display "ROBOTC :]"
sleep(3000);
//disply robo name and stuff
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("Alpha Robotics's"); // Display "Hello from"
displayLCDPos(1,0); // Set the cursor to line 1, position 0 (bottom line, far left)
displayNextLCDString("//////Alpha\\\\\\"); // Display "ROBOTC :]"
sleep(5000);
if(vexRT[Btn8L] == 1)
{
SensorValue[solenoid] = 1;
}
if(vexRT[Btn8L] == 0)
{
SensorValue[solenoid] = 0;
}
if(vexRT[Btn6D]==0)
{
SensorValue[claw]=1;
}
if(vexRT[Btn6D]==1)
{
SensorValue[claw]=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);
}