update hcsr04.cpp by changing 20000 to 2000
Dependencies: Stepper mbed SDFileSystem Ultrasonic PinDetect millis
Revision 8:3f4d78017fd9, committed 2019-01-18
- Comitter:
- rschimpf78
- Date:
- Fri Jan 18 00:22:13 2019 +0000
- Parent:
- 7:ede305192e3b
- Commit message:
- 1.17;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r ede305192e3b -r 3f4d78017fd9 main.cpp --- a/main.cpp Thu Jan 10 01:32:38 2019 +0000 +++ b/main.cpp Fri Jan 18 00:22:13 2019 +0000 @@ -245,7 +245,7 @@ long Duration = 0; long StartTime = millis(); - while(homeSwitch == 1 && magnetSwitch == 1 && Duration <= 55000 ) + while(homeSwitch == 1 && magnetSwitch == 1 && Duration <= 60000 ) { in1=0; in2=1; @@ -254,28 +254,23 @@ } in1=1; in2=1; - if (Duration > 55000){ + if (Duration > 60000){ stop_error = 5; } + else{ + stop_error = 0; + } } void send() { in1=1; in2=0; - wait(55); + wait(58); in1=1; in2=1; } -void internalpullups() -{ - homeSwitch.mode(PullUp); - wait(.01); - magnetSwitch.mode(PullUp); - wait (.01); -} - void logwriting() { @@ -309,14 +304,14 @@ exit(1); break; case 4: - fprintf(fp,"\nRequested: %ld ",plates); + fprintf(fp,"\nRequested: %ld ", plates); fprintf(fp,"\nSelected: %ld ", sheets); fprintf(fp,"\nDetected: %ld ", path_sheets); fprintf(fp,"\nStop Error: %ld ", stop_error); fclose(fp); break; case 5: - fprintf(fp,"\nRequested: %ld ",plates); + fprintf(fp,"\nRequested: %ld ", plates); fprintf(fp,"\nSelected: %ld ", sheets); fprintf(fp,"\nDetected: %ld ", path_sheets); fprintf(fp,"\nStop Error: %ld ", stop_error); @@ -324,7 +319,7 @@ exit(1); break; case 6: - fprintf(fp,"\nRequested: %ld ",plates); + fprintf(fp,"\nRequested: %ld ", plates); fprintf(fp,"\nSelected: %ld ", sheets); fprintf(fp,"\nBeam Sensor Distance: %ld ", beam_distance); fprintf(fp,"\nStop Error: %ld ", stop_error); @@ -332,7 +327,7 @@ exit(1); break; case 7: - fprintf(fp,"\nRequested: %ld ",plates); + fprintf(fp,"\nRequested: %ld ", plates); fprintf(fp,"\nNot at Start Position "); fprintf(fp,"\nStop Error: %ld ", stop_error); fclose(fp); @@ -365,12 +360,16 @@ int main() { + homeSwitch.mode(PullUp); + wait(.01); + magnetSwitch.mode(PullUp); + wait (.01); mkdir("/sd/mydir", 0777); in1=1; in2=1; en = 1; wait(0.1); - internalpullups(); + while(stop_error==0) { plates = (rand() % 16) + 1;