h

Dependencies:   mbed

Fork of HelloWorld by judo ~

Revision:
4:f0a11480f39f
Parent:
3:641eefd1110b
Child:
5:afabac4fce1b
--- a/main.cpp	Wed Oct 26 21:17:17 2016 +0000
+++ b/main.cpp	Mon Nov 14 19:59:54 2016 +0000
@@ -3,14 +3,77 @@
 
 //DigitalOut output_pin_A(LED1);
 
-PaceHeart* Pacer = new PaceHeart();
+PaceHeart* Pacer = new PaceHeart;
+DigitalOut led(LED1);
+Serial s(USBTX, USBRX);
+void baud(int baudrate) {
+    
+    s.baud(baudrate);
+}
+    
 
 int main() {
+    /*
+    baud(57600);
+     s.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down\n");
     while(1) {
+      char c = s.getc();
+      pc.putc(pc.getc()); //echoes back input
+        if((c == 'u')) {
+            
+            led = !led;
+        }
+        if((c == 'd')) {
+            led = 0;
+        } 
+    }*/
+    Pacer-> pace_A();
+       /* PwmOut out(PTA0);        pulse width thingy    
+        PwmIn  in(PTD1);            
+        float pe,pw,ds;
+
+    // set the PwmOut in seconds
+        out.pulsewidth(2);
+        out.period(4);
+
+        while (true) {
+        pe= in.period();
+        pw= in.pulsewidth();
+        ds= in.dutycycle();
+        pc.printf("A period= %f, pulsewidth= %f, duty cycle= %f\n\r",pe, pw, ds);
+
+        wait(1);
+        }
         
-        Pacer->pace_V();
-       
-        Pacer->pace_A();
-        
-    }
+        AnalogOut aout(p18);  //sets up pin 18 as an analogue output
+        AnalogueIn ain(p15);  //sets up pin 15 and an analogue input
+ 
+        int main(){
+             aout=0.5;  //sets output to 0.5*VCC
+            while(1){    //sets up a loop
+             if (ain>0.3){   //tests whether the input is above 0.3
+            aout=0;  //sets the output to 0
+      }
+      aout = 0.5;
+      wait(1);
+      aout = 0;
+      
+   }
+   
+           sine wave output
+           const double pi = 3.141592653589793238462;
+            const double amplitude = 0.5f;
+            const double offset = 65535/2;
+            double rads = 0.0;
+            uint16_t sample = 0;
+            
+            while(1) {
+                // sinewave output
+                for (int i = 0; i < 360; i++) {
+                    rads = (pi * i) / 180.0f;
+                    sample = (uint16_t)(amplitude * (offset * (cos(rads + pi))) + offset);
+                    aout.write_u16(sample);
+                }
+            }
+    */
 }