From a0273c44341a9f94a08d76aa35e60f04fe87e717 Mon Sep 17 00:00:00 2001 From: KenwoodFox <31870999+KenwoodFox@users.noreply.github.com> Date: Wed, 26 Sep 2018 12:06:05 -0400 Subject: [PATCH 1/3] Quickdate Got some testing done today --- MiniChallenge2/drive.c | 23 +++++++++++++++++++++++ MiniChallenge2/flash.c | 12 ++++++++++++ MiniChallenge2/source.c | 19 +++++++++++++++++++ SimpleBlink/source.c | 20 ++++++++++++++++++++ firstCodeProject/blink.h | 33 +++++++++++++++++++++++++++++++++ firstCodeProject/runMotors.h | 14 +++++--------- firstCodeProject/source.c | 13 +++++++++---- firstCodeProject/toggleBlink.h | 17 ++++++----------- 8 files changed, 127 insertions(+), 24 deletions(-) create mode 100644 MiniChallenge2/drive.c create mode 100644 MiniChallenge2/flash.c create mode 100644 MiniChallenge2/source.c create mode 100644 SimpleBlink/source.c create mode 100644 firstCodeProject/blink.h diff --git a/MiniChallenge2/drive.c b/MiniChallenge2/drive.c new file mode 100644 index 0000000..919abbc --- /dev/null +++ b/MiniChallenge2/drive.c @@ -0,0 +1,23 @@ +int initComplete = false; + +task drive() +{ + int rev = 1000; + + if(initComplete == false) + { + //init + startMotor(starboardMotor, 80); + startMotor(portMotor, 80); + delay(rev); //adjust me! 1 rev + startMotor(starboardMotor, 0); + startMotor(portMotor, 0); + initComplete = true; + } + + while(SensorValue(limitSwitch) == false) + { + startMotor(starboardMotor, -80); + startMotor(portMotor, -80); + } +} diff --git a/MiniChallenge2/flash.c b/MiniChallenge2/flash.c new file mode 100644 index 0000000..6649a92 --- /dev/null +++ b/MiniChallenge2/flash.c @@ -0,0 +1,12 @@ +task blink() +{ + //int blinkState = 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/source.c b/MiniChallenge2/source.c new file mode 100644 index 0000000..1699cf1 --- /dev/null +++ b/MiniChallenge2/source.c @@ -0,0 +1,19 @@ +#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 "drive.c" + +task main() +{ + while(true){ + startTask(blink); + startTask(drive); + + delay(2000); + } +} 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); - } } From 00e70c82bfe87741bc4ae2299f395ae4f16c0541 Mon Sep 17 00:00:00 2001 From: KenwoodFox <31870999+KenwoodFox@users.noreply.github.com> Date: Thu, 27 Sep 2018 11:46:51 -0400 Subject: [PATCH 2/3] Compile before thingy --- MiniChallenge2/drive.c | 23 ----------------------- MiniChallenge2/motorInit.c | 11 +++++++++++ MiniChallenge2/source.c | 31 ++++++++++++++++++++++++++++--- MiniChallenge3/source.c | 13 +++++++++++++ 4 files changed, 52 insertions(+), 26 deletions(-) delete mode 100644 MiniChallenge2/drive.c create mode 100644 MiniChallenge2/motorInit.c create mode 100644 MiniChallenge3/source.c diff --git a/MiniChallenge2/drive.c b/MiniChallenge2/drive.c deleted file mode 100644 index 919abbc..0000000 --- a/MiniChallenge2/drive.c +++ /dev/null @@ -1,23 +0,0 @@ -int initComplete = false; - -task drive() -{ - int rev = 1000; - - if(initComplete == false) - { - //init - startMotor(starboardMotor, 80); - startMotor(portMotor, 80); - delay(rev); //adjust me! 1 rev - startMotor(starboardMotor, 0); - startMotor(portMotor, 0); - initComplete = true; - } - - while(SensorValue(limitSwitch) == false) - { - startMotor(starboardMotor, -80); - startMotor(portMotor, -80); - } -} 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 index 1699cf1..512cf61 100644 --- a/MiniChallenge2/source.c +++ b/MiniChallenge2/source.c @@ -6,13 +6,38 @@ //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// #include "flash.c" -#include "drive.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); + } + } +} task main() { + //things to run once: + motorInit(); + + //things to run over and over while(true){ - startTask(blink); - startTask(drive); + startTask(blink, 5); + startTask(driveTask, 10); delay(2000); } 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) +} From 71005446ef467f39db7fccdd6c6cef5904afd77b Mon Sep 17 00:00:00 2001 From: KenwoodFox <31870999+KenwoodFox@users.noreply.github.com> Date: Thu, 27 Sep 2018 11:58:39 -0400 Subject: [PATCH 3/3] Pushed to gat hoob for meine friends I really do have freiends --- MiniChallenge2/flash.c | 14 ++++++++------ MiniChallenge2/source.c | 16 +++++++++------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/MiniChallenge2/flash.c b/MiniChallenge2/flash.c index 6649a92..90a80d4 100644 --- a/MiniChallenge2/flash.c +++ b/MiniChallenge2/flash.c @@ -1,12 +1,14 @@ task blink() { //int blinkState = true; - - while(SensorValue(bumpSwitch) == true) //If you are holding the bump switch + while(true) { - turnLEDOn(LEDOne); - delay(1000); //...do the code - turnLEDOff(LEDOne); - delay(1000); //more code + 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/source.c b/MiniChallenge2/source.c index 512cf61..bb103e5 100644 --- a/MiniChallenge2/source.c +++ b/MiniChallenge2/source.c @@ -27,18 +27,20 @@ task driveTask() //Tasks need to be defined before the task main, as they will c delay(20); } } + stopMotor(starboardMotor); + stopMotor(portMotor); //stop motors + + stopTask(driveTask); } task main() { //things to run once: motorInit(); - - //things to run over and over - while(true){ - startTask(blink, 5); - startTask(driveTask, 10); - - delay(2000); + startTask(driveTask, 10); + startTask(blink, 5); + while(true) + { + delay(2000); //alotocate all time for task CPU } }