Tested SPK on GND , PWM port of L476RG

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kartjang
Date:
Sat Jan 07 04:23:27 2017 +0000
Parent:
0:57d59c7a025b
Commit message:
PWM test with SPK 2 channel

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 57d59c7a025b -r 58d4d03ac403 main.cpp
--- a/main.cpp	Sat Jan 07 04:06:49 2017 +0000
+++ b/main.cpp	Sat Jan 07 04:23:27 2017 +0000
@@ -2,18 +2,19 @@
 
 DigitalOut  my_led(LED1);
 InterruptIn my_button(USER_BUTTON);
-PwmOut      my_pwm(PB_3);
+PwmOut      my_pwmR(PB_3);
+PwmOut      my_pwmL(PB_5);
 
 void pressed() {
     /*
-    if (my_pwm.read() == 0.25) {
-        my_pwm.write(0.75);
+    if (my_pwmRR.read() == 0.25) {
+        my_pwmRR.write(0.75);
     }
-    else if (my_pwm.read() == 0.5) {
-        my_pwm.write(0.25);
+    else if (my_pwmRR.read() == 0.5) {
+        my_pwmRR.write(0.25);
     }    
     else {
-        my_pwm.write(0.50);
+        my_pwmRR.write(0.50);
     }
     */
 }
@@ -26,8 +27,11 @@
     float pwm_v = 0.0;
     char direction;
     // Set PWM
-    my_pwm.period_ms(1);
-    my_pwm.write(pwm_v);
+    my_pwmR.period_ms(8);
+    my_pwmR.write(pwm_v);
+ 
+    my_pwmL.period_ms(5);
+    my_pwmL.write(pwm_v);
     
     // Set button
     my_button.fall(&pressed);
@@ -48,7 +52,8 @@
         else 
             pwm_v-=0.1;
             
-        my_pwm.write(pwm_v);  
+        my_pwmR.write(pwm_v);  
+        my_pwmL.write(pwm_v); 
         printf("==LOOP== pwm_v : %.1f   DIR : %d \n",pwm_v,direction); 
         wait(0.1); // 500 ms
     }