This repository has been archived by the owner on Jul 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
53 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
//this function by joe, remeber to include my drivetrain.c before including this file | ||
|
||
void easyGas(int targetSpeed, int accelValue, float accelDirection) | ||
{ | ||
float speed = 0; //arb value for the current speed | ||
void easyGas(int robotSpeed, int targetSpeed, int accelValue, float accelDirection) | ||
{ //The speed the robot is going, the speed you want it to go, the value of deacceleration, the direction and magnitude | ||
|
||
while(speed != targetSpeed || speed > 127) //while you are not at target speed OR the speed value is bigger than the max output, THIS WILL TRIGGER IN CASE OF AN ERROR | ||
while(robotSpeed != targetSpeed && robotSpeed < 127 && robotSpeed > -127) //while you are not at target speed OR the speed value is bigger than the max output, THIS WILL TRIGGER IN CASE OF AN ERROR | ||
{ | ||
speed = speed + accelDirection; //add accelDirection to the speed value | ||
robotSpeed = robotSpeed + accelDirection; //add accelDirection to the speed value | ||
delay(accelValue); //delay for this long | ||
starboardDriveTrain(speed); //set the speed | ||
portDriveTrain(speed); | ||
starboardDriveTrain(robotSpeed); //set the speed | ||
portDriveTrain(robotSpeed); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,36 @@ | ||
#pragma config(Sensor, dgtl1, bumpSwitch, sensorTouch) | ||
#pragma config(Motor, port6, starboardFore, tmotorVex393_HBridge, openLoop, reversed) | ||
#pragma config(Motor, port10, portFore, tmotorServoContinuousRotation, openLoop) | ||
#pragma config(Sensor, dgtl1, LED, sensorLEDtoVCC) | ||
#pragma config(Sensor, dgtl12, bumpSwitch, sensorTouch) | ||
#pragma config(Motor, port1, starboardAft, tmotorVex393_HBridge, openLoop, reversed) | ||
#pragma config(Motor, port5, portAft, tmotorServoContinuousRotation, openLoop) | ||
#pragma config(Motor, port1, starboardAft, tmotorVex393_HBridge, openLoop, reversed) | ||
#pragma config(Motor, port6, starboardFore, tmotorVex393_MC29, openLoop, reversed) | ||
#pragma config(Motor, port10, portFore, tmotorServoContinuousRotation, openLoop) | ||
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// | ||
|
||
#include "drivetrain.h" //include the drivetrain header | ||
#include "easyGas.h" //include the easygas header | ||
|
||
int i = 0; | ||
|
||
task main() | ||
{ | ||
//while(SensorValue[bumpSwitch] != true) //while bumpswitch is not pressed | ||
//{ | ||
// delay(10); //wait 10ms | ||
//} | ||
while(SensorValue[bumpSwitch] != true) //while bumpswitch is not pressed | ||
{ | ||
delay(50); //wait 50ms | ||
turnLEDOn(LED); | ||
delay(50); | ||
turnLEDOff(LED); | ||
} | ||
|
||
delay(900); //after pressing the bump switch, wait 900ms before starting the program | ||
while( i < 6) | ||
{ | ||
delay(100); | ||
turnLEDOn(LED); | ||
delay(100); | ||
turnLEDOff(LED); | ||
i++; | ||
} | ||
|
||
easyGas(100, 5, 0.5); //accelerate at a rate of 0.5 every 5ms to 100 pwm | ||
easyGas(0, 100, 5, 1); //Accelerate from 0, to 100, in time increments of 5ms, forward. | ||
delay(4000); //magic delay for the leangth of the | ||
easyGas(100, 5, -0.5); //accelerate at a rate of -0.5 every 5ms to 100 pwm | ||
easyGas(100, 0, 5, -1); //Accelerate from 100, to 0, in time increments of 5ms, backward. | ||
} |