Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 1:7d73836cc7c6
- Parent:
- 0:75ca8f5758b2
--- 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);
+ }
}