Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 3:86498e58d1d9
- Parent:
- 0:70f3437369e5
--- a/main.cpp Tue May 19 14:04:53 2015 +0000
+++ b/main.cpp Tue May 19 14:16:22 2015 +0000
@@ -1,1 +1,41 @@
-#include "mbed.h"
\ No newline at end of file
+#include "mbed.h"
+#define PERIODEN_DAUER 10
+
+PwmOut mypwm(PWM_OUT);
+AnalogIn analog_value0(A0); //For Hall-Sensor
+
+DigitalOut myled(LED1);
+
+// Prototypen
+float hall_umrechnung();
+
+int main() {
+
+ while(1) {
+ mypwm.period_ms(PERIODEN_DAUER);
+ mypwm.pulsewidth_ms(PERIODEN_DAUER*hall_umrechnung());
+ myled = !myled;
+ wait(1);
+ }
+}
+
+float hall_umrechnung()
+{
+ float meas0;
+ meas0 = analog_value0.read() - 0,2503;
+ if(meas0 < 0)
+ {
+ meas0 = 0;
+ }
+
+ meas0 = meas0*2;
+
+ if(meas0 > 1)
+ {
+ meas0 = 1;
+ }
+
+ return meas0;
+
+
+}
\ No newline at end of file