1
Dependencies: mbed
Revision 0:22d018a3b548, committed 2015-04-20
- Comitter:
- abm_mechatronika
- Date:
- Mon Apr 20 07:50:00 2015 +0000
- Commit message:
- fotorez
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 |
diff -r 000000000000 -r 22d018a3b548 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 20 07:50:00 2015 +0000 @@ -0,0 +1,59 @@ +#include "mbed.h" + +int analog_zero_0 = 0; +AnalogIn fotorezystor(PTB0); +Serial pc(USBTX, USBRX); + +float voltage(AnalogIn czujnik, float zero_analog) { + return (czujnik.read() - zero_analog) * 2.9035; + } + +int main() { + pc.baud(9600); + int i=0; + int p=0; + int r=0; + int k=0; + float o=0; + float m,n; + float suma=0; + float suma2=0; + + while(true) { + m = voltage(fotorezystor, analog_zero_0); + if (m < 0.05) + p=1; + + for (i=0; i<10; i++) + { + wait_us(10); + m = voltage(fotorezystor, analog_zero_0); + suma = suma + m; + } + + n = voltage(fotorezystor, analog_zero_0); + if (n > 0.4) + r = 1; + else r=0; + + for (i=0; i<10; i++) + { + wait_us(10); + n = voltage(fotorezystor, analog_zero_0); + suma2 = suma2 + n; + } + + if ((p==1) && (r==1) && (suma>suma2)) + { + pc.printf("obrot\t%.2f\n",o); + p=0; + o=o+0.25; + } + + pc.printf("%.d\n",k); + k++; + wait_ms(10); + suma = m; + suma2 = n; + } +}
diff -r 000000000000 -r 22d018a3b548 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Apr 20 07:50:00 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0 \ No newline at end of file