PWM Örneği

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
ctasdemir
Date:
Fri May 11 04:57:13 2018 +0000
Commit message:
PWM ?rne?i

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri May 11 04:57:13 2018 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+
+PwmOut mypwm(PA_7);
+
+DigitalOut myled(LED1);
+
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+int pwm_val = 1;
+
+int main() {
+    
+    mypwm.period_ms(10);
+    mypwm.pulsewidth_us(100);
+  
+    pc.printf("pwm set to %.2f %%\n", mypwm.read() * 100);
+    
+    while(1) {
+        myled = !myled;
+        
+    pc.printf("pwm set to %.2f %%\n", mypwm.read() * 100);
+    
+          mypwm.pulsewidth_us(pwm_val+=100);
+          if(pwm_val > 10000)
+          {
+              pwm_val = 0;
+              }
+        
+        wait(0.001);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri May 11 04:57:13 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e7ca05fa8600
\ No newline at end of file