profs_snec_rascol / Mbed 2 deprecated 10-Pwm

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dg81
Date:
Mon May 04 13:29:14 2020 +0000
Parent:
0:75ca8f5758b2
Commit message:
ca tourne

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
--- a/main.cpp	Mon May 04 08:12:44 2020 +0000
+++ b/main.cpp	Mon May 04 13:29:14 2020 +0000
@@ -1,13 +1,21 @@
 #include "mbed.h"
 
-DigitalOut myled(LED2); // la variable "myled" désigne la led connectée à la broche D8 configurée en sortie
-
-int main(void)
-{
-    while(1) {
-        myled=!myled;   // on inverse l'état de la led
-        wait(1);        // on attend 2 secondes
-    }
+PwmOut led(D3);
+ 
+int main() {
+    // specify period first
+    led.period(0.01);      // 4 second period
+    led.write(0.50);      // 50% duty cycle, relative to period
+    //led = 0.5f;          // shorthand for led.write()
+    //led.pulsewidth(2);   // alternative to led.write, set duty cycle time in seconds
+    while(1){
+            led.write(0.25);      // 50% duty cycle, relative to period
+            wait(2);
+            led.write(0.5);      // 50% duty cycle, relative to period
+            wait(2);
+            led.write(0.75);      // 50% duty cycle, relative to period
+            wait(2);
+        }
 }
 
 
--- a/mbed.bld	Mon May 04 08:12:44 2020 +0000
+++ b/mbed.bld	Mon May 04 13:29:14 2020 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file