Embedded systems project

Dependencies:   mbed

Revision:
0:8fd20cb893b7
--- /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
+    }
+}