Saad Tayyab
/
takeover
aaaaaa
Revision 0:3849fc9c544a, committed 2018-05-02
- Comitter:
- rottenegg
- Date:
- Wed May 02 11:30:19 2018 +0000
- Commit message:
- aaaaaaaaa
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed May 02 11:30:19 2018 +0000 @@ -0,0 +1,111 @@ +#include "mbed.h" + +BusOut pins(p20,p19,p18,p17,p16,p15,p14,p13); +Serial pc(USBTX,USBRX); +DigitalOut j(p9); + +void jump(){ + int stop = 0; + char stopp; + pc.printf("To jump press 1 to exit press 0") + while (stop == 0){ + char option = pc.getc + if (option == 1) { + j = 1; + } + else if (option == 0) { + stop = 1; + } + else { + j = 0; + } + } + }; + +void nscan(){ + pc.printf("Scanning... \n"); + int isDone = 0; + int counter = 0; + while( isDone == 0 ) { + pc.printf("scanning %d\n",counter); + char stop; + char stopp; + stopp = pc.readable(); + pins = counter; + wait_ms(3000); + stop = pc.readable(); + if (stop == stopp){ + } + else { + isDone = 1; + } + if (counter == 256) { + isDone = 1; + } + counter++; + } + }; + + +void scan() { + pc.printf("Scanning... \n"); + int isDone = 0; + int counter = 127; + int counter2 = 128; + while( isDone == 0 ) { + pc.printf("scanning %d and %d\n",counter,counter2); + char stop; + char stopp; + stopp = pc.readable(); + pins = counter; + wait_ms(3000); + pins = counter2; + wait_ms(3000); + stop = pc.readable(); + if (stop == stopp){ + } + else { + isDone = 1; + } + if (counter == 0) { + isDone = 1; + } + counter--; + counter2++; + } + }; + + void control() { + pc.printf("Enter Control Number\n"); + int in; + pc.scanf("%d",&in); + pins = in; + + +} +int main() { + while(1) { + pc.printf("Traxter Take Over Program Serial Terminal\n"); + pc.printf("Enter Optimized Scan mode press 1\n"); + pc.printf("Enter Control Mode Press 2\n"); + pc.printf("Enter Normal Scan press 3\n"); + pc.printf("Enter Jump Mode Enter 4\n"); + char ans = pc.getc(); + if (ans == '1'){ + scan(); + } + else if (ans == '3'){ + nscan(); + } + else if (ans == '2'){ + control(); + } + else if (ans == '4'){ + jump(); + } + + else { + pc.printf("Invalid Fool\n"); + } + } + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed May 02 11:30:19 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/aa5281ff4a02 \ No newline at end of file