Skip to content
This repository has been archived by the owner on Jul 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #6 from KenwoodFox/prototype
Browse files Browse the repository at this point in the history
Housekeeping
  • Loading branch information
KenwoodFox authored Sep 28, 2018
2 parents c8b9871 + 4c79b1b commit a16bc20
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
11 changes: 5 additions & 6 deletions MiniChallenge2/flash.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
task blink()
{
//int blinkState = true;
while(true)
while(true) //forever...
{
while(SensorValue(bumpSwitch) == true) //If you are holding the bump switch
{
turnLEDOn(LEDOne);
delay(1000); //...do the code
turnLEDOff(LEDOne);
delay(1000); //more code
turnLEDOn(LEDOne); //turn on the LED
delay(1000); //wait..
turnLEDOff(LEDOne); //turn it off
delay(1000); //this second wait is here, beacuse as it loops, there needs to be a delay between turning off and then turning back on
}
}
}
9 changes: 5 additions & 4 deletions MiniChallenge2/motorInit.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
void motorInit()
{
int rev = 1000;
//motor init
startMotor(starboardMotor, 80);
int rev = 1000; //this is the revolution duration variable, it exists only inside motorInit,

//motor init
startMotor(starboardMotor, 80); //start both motors going forward at power 80 out of 127 pwm
startMotor(portMotor, 80);
delay(rev); //adjust me! 1 rev
stopMotor(starboardMotor);
stopMotor(starboardMotor); //stop both motors and wait two seconds
stopMotor(portMotor);
delay(2000); //delay for 2 seconds
}
31 changes: 15 additions & 16 deletions MiniChallenge2/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,41 @@
#pragma config(Motor, port3, portMotor, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "flash.c"
#include "motorInit.c"
#include "flash.c" //Include the blink task, that allows us to run a blink thread
#include "motorInit.c" //motorInit.c contains a motor init void,

task driveTask() //Tasks need to be defined before the task main, as they will compile in order
{
int trip = false;
int trip = false; //this trip value determines if the limit switch has been triggered, if true, the motor reverse drive will not run, this allows us to shut on and off the motors in a situation other than just the limit switch

startMotor(starboardMotor, -80);
startMotor(starboardMotor, -80); //these two commands start the motors moving in reverse
startMotor(portMotor, -80);

while(trip == false)
while(trip == false) //for as long as we are not tripped off...
{
if(SensorValue(limitSwitch) == 1)
if(SensorValue(limitSwitch) == 1) //...but if the limit switch is not pressed right now
{
trip = true;
trip = true; //trip the motors off
delay(20);
}
else
else //otherwise
{
delay(20);
delay(20); //dont trip the motors off
}
}
stopMotor(starboardMotor);
stopMotor(portMotor); //stop motors

stopTask(driveTask);
stopTask(driveTask); //stop the drivetask daemen, this will keep the motors from restarting
}

task main()
{
//things to run once:
motorInit();
startTask(driveTask, 10);
startTask(blink, 5);
while(true)
motorInit(); //init the motors with the startup sequence
startTask(driveTask, 10); //begin the drivetask daemen
startTask(blink, 5); //begin the blinking daemen
while(true) //do forever...
{
delay(2000); //alotocate all time for task CPU
delay(2000); //alotocate all CPUT time for tasks
}
}

0 comments on commit a16bc20

Please sign in to comment.