tim010 tim010
/
Grupa7-GlavniprojekatRadar
Muris Nuhodžić Edis Kunić
Revision 0:6c2fbb3ed2b9, committed 2014-06-05
- Comitter:
- tim010
- Date:
- Thu Jun 05 17:56:50 2014 +0000
- Commit message:
- MMuris Nuhod?i? ; Edis Kuni?
Changed in this revision
diff -r 000000000000 -r 6c2fbb3ed2b9 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jun 05 17:56:50 2014 +0000 @@ -0,0 +1,53 @@ +#include "mbed.h" +#include "sMotor.h" +AnalogIn IR(dp4); + +Serial pc(USBTX, USBRX); +sMotor motor(dp9, dp10, dp11, dp13); // creates new stepper motor: IN1, IN2, IN3, IN4 + +int step_speed = 1200 ; // set default motor speed +int numstep = 512/36; // defines full turn of 360 degree +int direction = 0; //0 for right, 1 for left +int brojkoraka = 36 ; +bool p=true; + /*int distanca[]={ 10 , 15 , 20 ,25 , 30 , 35 , 40 , 45 , 50 , 55 , 60 , 65 , 70 , 75 , 80 , 85 , 90}; + float naponi[]={ 0.89, 0.87, 0.81, 0.71 , 0.62 , 0.54, 0.47, 0.43, 0.39 , 0.34, 0.32, 0.29, 0.28 , 0.25, 0.24, 0.23, 0.21 };*/ + +int provjeri(float n){ + if(n<0.21)return 200; + if(n>0.89)return 1; + if(n<=0.89 && n>0.87) return 10; + if(n<=0.87 && n>0.81) return 15; + if(n<=0.81 && n>0.71) return 20; + if(n<=0.71 && n>0.62) return 25; + if(n<=0.62 && n>0.54) return 30; + if(n<=0.54 && n>0.47) return 35; + if(n<=0.47 && n>0.43) return 40; + if(n<=0.43 && n>0.39) return 45; + if(n<=0.39 && n>0.34) return 50; + if(n<=0.34 && n>0.32) return 55; + if(n<=0.32 && n>0.29) return 60; + if(n<=0.29 && n>0.28) return 65; + if(n<=0.28 && n>0.25) return 70; + if(n<=0.25 && n>0.24) return 75; + if(n<=0.24 && n>0.23) return 80; + if(n<=0.23 && n>0.21) return 85; + } +int main() { + float a; + +int brojac=0; + while(1) + + { + motor.step(numstep, direction, step_speed); + a = IR; + brojac++; + if(brojac==36){brojac=0;direction=1-direction;} + int b=provjeri(a); + pc.printf("%d\n",b ); + wait(1); + } + + +} \ No newline at end of file
diff -r 000000000000 -r 6c2fbb3ed2b9 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Jun 05 17:56:50 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877 \ No newline at end of file
diff -r 000000000000 -r 6c2fbb3ed2b9 sMotor.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sMotor.lib Thu Jun 05 17:56:50 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/XtaticO/code/sMotor/#4b3b9e047ce3