scooter / Mbed 2 deprecated Scooter-uC-Programm

Dependencies:   mbed

Revision:
4:a9eefff5ac60
Parent:
1:4d1b3fffabd5
Child:
5:d213c03872fe
--- a/main.cpp	Tue May 19 14:23:35 2015 +0000
+++ b/main.cpp	Tue May 19 14:33:55 2015 +0000
@@ -1,10 +1,42 @@
 #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() {
+  
+  mypwm.period_ms(PERIODEN_DAUER);
+  
+    while(1) {
+        mypwm.pulsewidth_ms(PERIODEN_DAUER*hall_umrechnung());
+        myled = !myled;
+        wait(1);
+    }
+}
 
-int main(){
+float hall_umrechnung()
+{
+    float meas0;
+    meas0 = analog_value0.read() - 0,2503;
+    if(meas0 < 0)
+    {
+        meas0 = 0;
+    }
     
-    
-    
+    meas0 = meas0*2;
     
+    if(meas0 > 1)
+    {
+        meas0 = 1;
+    }
     
-    }
\ No newline at end of file
+    return meas0;
+
+    
+}
\ No newline at end of file