Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
lpeltoni
Date:
Tue Oct 22 07:02:10 2019 +0000
Commit message:
Button test;

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	Tue Oct 22 07:02:10 2019 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+
+DigitalOut  my_led(LED1);
+InterruptIn my_button(PB_3);
+PwmOut      my_pwm(PA_8);
+
+void pressed() {
+    if (my_pwm.read() == 0.25) {
+        my_pwm.write(0.75);
+    }
+    else {
+        my_pwm.write(0.25);
+    }
+}
+
+int main()
+{
+    // Set PWM
+    my_pwm.period_ms(10);
+    my_pwm.write(0.5);
+    
+    // Set button
+    my_button.fall(&pressed);
+    
+    while (1) {
+        my_led = !my_led;
+        wait(0.5); // 500 ms
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Oct 22 07:02:10 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file