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 #5 from KenwoodFox/prototype
Browse files Browse the repository at this point in the history
Prototype
  • Loading branch information
KenwoodFox authored Sep 27, 2018
2 parents 4906cd3 + 7100544 commit c8b9871
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 24 deletions.
14 changes: 14 additions & 0 deletions MiniChallenge2/flash.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
task blink()
{
//int blinkState = true;
while(true)
{
while(SensorValue(bumpSwitch) == true) //If you are holding the bump switch
{
turnLEDOn(LEDOne);
delay(1000); //...do the code
turnLEDOff(LEDOne);
delay(1000); //more code
}
}
}
11 changes: 11 additions & 0 deletions MiniChallenge2/motorInit.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
void motorInit()
{
int rev = 1000;
//motor init
startMotor(starboardMotor, 80);
startMotor(portMotor, 80);
delay(rev); //adjust me! 1 rev
stopMotor(starboardMotor);
stopMotor(portMotor);
delay(2000); //delay for 2 seconds
}
46 changes: 46 additions & 0 deletions MiniChallenge2/source.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma config(Sensor, dgtl1, limitSwitch, sensorTouch)
#pragma config(Sensor, dgtl2, bumpSwitch, sensorTouch)
#pragma config(Sensor, dgtl12, LEDOne, sensorLEDtoVCC)
#pragma config(Motor, port2, starboardMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, portMotor, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "flash.c"
#include "motorInit.c"

task driveTask() //Tasks need to be defined before the task main, as they will compile in order
{
int trip = false;

startMotor(starboardMotor, -80);
startMotor(portMotor, -80);

while(trip == false)
{
if(SensorValue(limitSwitch) == 1)
{
trip = true;
delay(20);
}
else
{
delay(20);
}
}
stopMotor(starboardMotor);
stopMotor(portMotor); //stop motors

stopTask(driveTask);
}

task main()
{
//things to run once:
motorInit();
startTask(driveTask, 10);
startTask(blink, 5);
while(true)
{
delay(2000); //alotocate all time for task CPU
}
}
13 changes: 13 additions & 0 deletions MiniChallenge3/source.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma config(Sensor, dgtl1, limitSwitch, sensorTouch)
#pragma config(Sensor, dgtl2, bumpSwitch, sensorTouch)
#pragma config(Sensor, dgtl12, LEDOne, sensorLEDtoVCC)
#pragma config(Motor, port2, starboardMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, portMotor, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
//task: port wheel turns cw at 127/2 while the bump switch is pressed
//task: turn the starboard motor CW, then CCW alternativly for 1 rev each at low speed, while the limit switch is pressed
//task: ultrasonic sensor tpo turn off a lit LED when an object is closer than 4 inches, the first instance of this will start the servo motor running... (missing information)
}
20 changes: 20 additions & 0 deletions SimpleBlink/source.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma config(Sensor, dgtl1, limitSwitch, sensorTouch)
#pragma config(Sensor, dgtl12, LEDOne, sensorLEDtoVCC)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//


task main()
{
while(true)
{
if(sensorValue(limitSwitch) == true)
{
turnLEDOn(LEDOne);
}
else
{
turnLEDOff(LEDOne);
}
delay(30);
}
}
33 changes: 33 additions & 0 deletions firstCodeProject/blink.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
task blink()
{
int blinkState = true;
while(true)
{
if(blinkState == true) //If you are toggled on...
{
turnLEDOn(LEDOne);
delay(1000); //...do the code
turnLEDOff(LEDOne);
delay(1000); //more code
}
else
{
delay(300); //sets the rescan rate
}

//delay(50);

//toggle
if(SensorValue(limitSwitch) == true) //If the switch is pressed
{
if(blinkState == true) //and you are blinking
{
blinkState = false; //disable the blink
}
else //if you press the switch and you are not blinking
{
blinkState = true;
}
}
}
}
14 changes: 5 additions & 9 deletions firstCodeProject/runMotors.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
void runMotors()
task runMotors()
{
//int runSpeed = 88; //the speed the motors will run

//turn one revolution
delay(2000);
if(limitSwitch != true)
{
//setMultipleMotors(0, portMotor, starboardMotor); //stop
}
/*turn one revolutoon
wait two seconds
reverse untill the bump switch is pressed
*/
}
13 changes: 9 additions & 4 deletions firstCodeProject/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@

#include "toggleBlink.h" //Blink on/off command
#include "runMotors.h" //motor drive command
#include "blink.h" //include the blink subroutine

int operation = true;
//int blinkState = false;

task main()
task main() //This task called upon robot start
{
while(operation == true)
startTask(runMotors); //Start the motors Subroutine
startTask(blink); //Start the blink subroutine

while(operation == true) //While there are no critical opperations
{
toggleBlink();
runMotors();
toggleBlink(); //run the blink routine
delay(10);
}
}
17 changes: 6 additions & 11 deletions firstCodeProject/toggleBlink.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
void toggleBlink() //This function will toggle the flashing of an LED
{
int toggleBlink = false;
/*delete me!!*/int blinkState = true;

if(SensorValue(bumpSwitch) == true) //if you push the bump switch..
{
if(toggleBlink == false) //..and the toggle is off...
if(blinkState == false) //..and the toggle is off...
{
toggleBlink = true; //turn the toggle on.
blinkState = true; //turn the toggle on.
delay(30);
}
else //..and the toggle is on...
{
toggleBlink = false; //turn the toggle off.
blinkState = false; //turn the toggle off.
delay(30);
}
}

if(toggleBlink == true) //If you are toggled on...
{
turnLEDOn(LEDOne);
delay(1000); //...do the code
turnLEDOff(LEDOne);
}
}

0 comments on commit c8b9871

Please # to comment.