Saad Tayyab
/
takeover
aaaaaa
main.cpp
- Committer:
- rottenegg
- Date:
- 2018-05-02
- Revision:
- 0:3849fc9c544a
File content as of revision 0:3849fc9c544a:
#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"); } } }