Buzzer com LDR, LED e PWM
Dependencies: mbed
Revision 0:e7d459325c12, committed 2016-05-16
- Comitter:
- guilhermepaulino
- Date:
- Mon May 16 18:17:30 2016 +0000
- Commit message:
- Desafio de buzzer com LDR, LED vermelho e PWM
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 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon May 16 18:17:30 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7c328cabac7e \ No newline at end of file