diff --git a/MiniChallenge2/flash.c b/MiniChallenge2/flash.c new file mode 100644 index 0000000..90a80d4 --- /dev/null +++ b/MiniChallenge2/flash.c @@ -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 + } + } +} diff --git a/MiniChallenge2/motorInit.c b/MiniChallenge2/motorInit.c new file mode 100644 index 0000000..9dda0fe --- /dev/null +++ b/MiniChallenge2/motorInit.c @@ -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 +} diff --git a/MiniChallenge2/source.c b/MiniChallenge2/source.c new file mode 100644 index 0000000..bb103e5 --- /dev/null +++ b/MiniChallenge2/source.c @@ -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 + } +} diff --git a/MiniChallenge3/source.c b/MiniChallenge3/source.c new file mode 100644 index 0000000..5b6a54e --- /dev/null +++ b/MiniChallenge3/source.c @@ -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) +} diff --git a/SimpleBlink/source.c b/SimpleBlink/source.c new file mode 100644 index 0000000..b78525f --- /dev/null +++ b/SimpleBlink/source.c @@ -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); + } +} diff --git a/firstCodeProject/blink.h b/firstCodeProject/blink.h new file mode 100644 index 0000000..0c95dd8 --- /dev/null +++ b/firstCodeProject/blink.h @@ -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; + } + } + } +} diff --git a/firstCodeProject/runMotors.h b/firstCodeProject/runMotors.h index 3f10bfd..64fbd42 100644 --- a/firstCodeProject/runMotors.h +++ b/firstCodeProject/runMotors.h @@ -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 + */ } diff --git a/firstCodeProject/source.c b/firstCodeProject/source.c index e461c54..82ecb4c 100644 --- a/firstCodeProject/source.c +++ b/firstCodeProject/source.c @@ -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); } } diff --git a/firstCodeProject/toggleBlink.h b/firstCodeProject/toggleBlink.h index cfba703..0ca3ee7 100644 --- a/firstCodeProject/toggleBlink.h +++ b/firstCodeProject/toggleBlink.h @@ -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); - } }