Buzzer com LDR, LED e PWM

Dependencies:   mbed

Revision:
0:e7d459325c12
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon May 16 18:17:30 2016 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+AnalogIn ain(A0);
+DigitalOut buzzer(PTA17);
+PwmOut ledr(LED1); // LED vermelho
+int x;
+int main(){
+    while(1){
+        x=ain.read();
+        if(x < 0.4){
+            buzzer=0;
+            ledr=1.0f;
+        }
+        else {
+            buzzer=1;
+            //ledr=0.0f;
+            for(float p=0.0f; p < 1.0f; p += 0.01f){
+                ledr=p;
+                wait(0.02);
+            }
+        }
+    }
+}
\ No newline at end of file