|
Page 1 of 1
|
[ 11 posts ] |
|
Start Program when Push Button is Pushed
Author |
Message |
ChocoTaco
Rookie
Joined: Thu Jan 21, 2016 3:19 pm Posts: 6
|
 Start Program when Push Button is Pushed
I'm trying to make my robot move forwards for a specific amount of time when a button is pushed. The robot is on USB only mode. I want the to 1) turn on the robot and 2)have the robot move forward when the button is pushed. I'm new to this whole gig and I'd really appreciate anyone's help  Here is the code: #pragma config(Sensor, dgtl1, sensorTouch, sensorDigitalIn) #pragma config(Motor, port1, motor1, tmotorVex393_HBridge, openLoop, driveLeft) #pragma config(Motor, port10, motor2, tmotorVex393_HBridge, openLoop, driveRight) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// task main() { if(SensorValue(sensorTouch) == 1) { motor[port1] = 127; motor[port10] = 127; wait1Msec(16198); } }
|
Fri Jan 22, 2016 3:43 pm |
|
 |
CARBOT
Expert
Joined: Thu Dec 01, 2011 12:07 am Posts: 151
|
 Re: Start Program when Push Button is Pushed
What you have would only run if the button was pressed when you started the program. Lookup the while statement and try this:  |  |  |  | Code: #pragma config(Sensor, dgtl1, sensorTouch, sensorDigitalIn) #pragma config(Motor, port1, motor1, tmotorVex393_HBridge, openLoop, driveLeft) #pragma config(Motor, port10, motor2, tmotorVex393_HBridge, openLoop, driveRight) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main() { while(1>0) { if(SensorValue(sensorTouch) == 1) { motor[port1] = 127; motor[port10] = 127; wait1Msec(16198); } } } |  |  |  |  |
|
Sat Jan 23, 2016 6:29 pm |
|
 |
ChocoTaco
Rookie
Joined: Thu Jan 21, 2016 3:19 pm Posts: 6
|
 Re: Start Program when Push Button is Pushed
 |  |  |  | CARBOT wrote: What you have would only run if the button was pressed when you started the program. Lookup the while statement and try this:  |  |  |  | Code: #pragma config(Sensor, dgtl1, sensorTouch, sensorDigitalIn) #pragma config(Motor, port1, motor1, tmotorVex393_HBridge, openLoop, driveLeft) #pragma config(Motor, port10, motor2, tmotorVex393_HBridge, openLoop, driveRight) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main() { while(1>0) { if(SensorValue(sensorTouch) == 1) { motor[port1] = 127; motor[port10] = 127; wait1Msec(16198); } } } |  |  |  |  |
|  |  |  |  |
I tried using that code but I still couldn't get the robot to move  . I don't know if I'm doing something wrong on my end. I'm using a bumper switch if that matters... Also, since I'm using USB only mode, when I turn the robot on, does that mean that the program is ready to run? Would I have to "clear" the cortex of any possibly existing programs? I really appreciate your help.
|
Mon Jan 25, 2016 1:05 pm |
|
 |
CARBOT
Expert
Joined: Thu Dec 01, 2011 12:07 am Posts: 151
|
 Re: Start Program when Push Button is Pushed
Does the robot run if the Cortex is turned on while the USB cable is NOT connected?
|
Tue Jan 26, 2016 12:46 pm |
|
 |
ChocoTaco
Rookie
Joined: Thu Jan 21, 2016 3:19 pm Posts: 6
|
 Re: Start Program when Push Button is Pushed
The robot does not run when the cable is not connected. Nor does it run when the cable is connected. Could this be a firmware issue? Also, there is another person using the robot, so could there be a conflict between my program and theirs?
|
Wed Jan 27, 2016 6:23 pm |
|
 |
CARBOT
Expert
Joined: Thu Dec 01, 2011 12:07 am Posts: 151
|
 Re: Start Program when Push Button is Pushed
From RobotC, if you select ROBOT then PLATFORM TYPE, does it have VEX 2.0 Cortex checked?
From RobotC, if you select ROBOT then VEX CORTEX COMMUNICATION MODE, does it have USB ONLY checked?
What happens when you press COMPILE PROGRAM?
What happens when you press DOWNLOAD TO ROBOT?
|
Thu Jan 28, 2016 10:43 pm |
|
 |
CARBOT
Expert
Joined: Thu Dec 01, 2011 12:07 am Posts: 151
|
 Re: Start Program when Push Button is Pushed
In USB ONLY mode the robot runs the program when powered up if not connected to a PC.
|
Thu Jan 28, 2016 10:45 pm |
|
 |
ChocoTaco
Rookie
Joined: Thu Jan 21, 2016 3:19 pm Posts: 6
|
 Re: Start Program when Push Button is Pushed
I can not download to robot because of the error in the compiling phase.
|
Fri Jan 29, 2016 3:48 pm |
|
 |
ChocoTaco
Rookie
Joined: Thu Jan 21, 2016 3:19 pm Posts: 6
|
 Re: Start Program when Push Button is Pushed
OK so I tried to compile everything again and there were no errors. However, the robot still does not move. I tried changing the port for the push button but that did not change anything. Here is the code as of now:
#pragma config(Sensor, dgtl12, sensorTouch, sensorTouch) #pragma config(Motor, port1, motor1, tmotorVex393_HBridge, openLoop, driveLeft) #pragma config(Motor, port10, motor2, tmotorVex393_HBridge, openLoop, driveRight) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main() { while(1>0) { if(SensorValue(sensorTouch) == 1) { motor[port1] = 127; motor[port10] = 127; wait1Msec(16198); } } }
|
Fri Jan 29, 2016 3:58 pm |
|
 |
CARBOT
Expert
Joined: Thu Dec 01, 2011 12:07 am Posts: 151
|
 Re: Start Program when Push Button is Pushed
Please try this. It worked for me.  |  |  |  | Code: #pragma config(Sensor, dgtl12, sensorTouch, sensorTouch) #pragma config(Motor, port1, motor1, tmotorVex393_HBridge, openLoop, driveLeft) #pragma config(Motor, port10, motor2, tmotorVex393_HBridge, openLoop, driveRight) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// task main() { while(1>0) { if(SensorValue[dgtl12] == 1) { motor[port1] = 40; motor[port10] = 40; wait1Msec(3000); motor[port1] = 0; motor[port10] = 0; } } } |  |  |  |  |
|
Sat Jan 30, 2016 6:37 pm |
|
 |
ChocoTaco
Rookie
Joined: Thu Jan 21, 2016 3:19 pm Posts: 6
|
 Re: Start Program when Push Button is Pushed
It worked!!! Thank you so much for everything
|
Tue Feb 02, 2016 2:22 pm |
|
|
|
Page 1 of 1
|
[ 11 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|