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.
Merge pull request #5 from KenwoodFox/prototype
Prototype
- Loading branch information
Showing
9 changed files
with
157 additions
and
24 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
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 | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -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 | ||
} |
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 |
---|---|---|
@@ -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 | ||
} | ||
} |
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 |
---|---|---|
@@ -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) | ||
} |
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 |
---|---|---|
@@ -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); | ||
} | ||
} |
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 |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} | ||
} |
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,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 | ||
*/ | ||
} |
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,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); | ||
} | ||
} |