fancy lampje

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FXOS8700Q FastPWM

Revision:
11:de4a85703169
Parent:
10:e1eb73e19540
Child:
12:7f280a661e71
--- a/main.cpp	Fri Sep 20 09:47:41 2019 +0000
+++ b/main.cpp	Fri Sep 20 10:12:16 2019 +0000
@@ -1,62 +1,31 @@
 #include "mbed.h"
-#include "HIDScope.h"
-#include "QEI.h"
+//#include "HIDScope.h"
+//#include "QEI.h"
 #include "MODSERIAL.h"
 //#include "BiQuad.h"
 #include "FastPWM.h"
 #include <iostream>
-//#include "encoder.h"
 MODSERIAL pc(USBTX, USBRX);
-//Encoder motor1(D13,D12);
-PwmOut led(D9);
-HIDScope scope(3);
+PwmOut pout(A5);
 AnalogIn ain(A0);
- 
-Ticker printstuff;
+
+
+Ticker Theticker;
+volatile char c='x';
+volatile int color=0;
 
-void stuffz(void)
-    {
-    pc.printf("%f",ain*100.0f);
-    }
- 
- 
+void Take_Measurement(void)
+{
+   pc.printf("%f",ain*100.0f);
+}
+
 int main()
 {
-    /*const float degrees_per_count = 90/200.0; //quick approach
-    const float ain_degrees_range = 90; //degrees over which the potmeter can control.
-    const float kp_1_range = -1;
-    AnalogIn setpoint_1(A0);
-    AnalogIn p_value(A1);
-    DigitalOut direction_1(D4);
-    PwmOut pwm_1(D5);
-    float degrees_setpoint;
-    float error;
-    float output;
-    pwm_1.period(1.0/10000); //10kHz
-        
+    Theticker.attach(Take_Measurement,0.5);
+    pc.baud(115200);
+    pout.write(0.5);
+    
     while (true) {
-        degrees_setpoint = setpoint_1 * ain_degrees_range;
-        error = degrees_setpoint-(motor1.getPosition()*degrees_per_count); //error =  setpoint - current
-        output = error*p_value*kp_1_range;
-        if(output > 0)
-        {
-            direction_1.write(true);
-        }
-        else
-        {
-            direction_1.write(false);
-        }
-        pwm_1.write(fabs(output));
-        scope.set(0,motor1.getPosition());
-        scope.set(1,error);
-        scope.set(2,fabs(output));
-        led.write(motor1.getPosition()/100.0);
-        scope.send();
-        wait(0.01);
+        wait_ms(500);
     }
-    */
-    pc.baud()
-    pc.printf("Starting....\r\n");
-    printstuff.attach(stuffz,1);
-    led.write(ain);
 }