Iván Santos
/
ej3
ej3
Revision 0:5b26a9e84373, committed 2022-04-17
- Comitter:
- sedu_santos
- Date:
- Sun Apr 17 16:09:53 2022 +0000
- Commit message:
- ej3
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 Sun Apr 17 16:09:53 2022 +0000 @@ -0,0 +1,40 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); +AnalogIn ldr(A0); +PwmOut led(D2); +PwmOut led2(D7); +PwmOut led3(D8); + +void intensidadLDR() { + pc.baud(4800); + while(1) { + float ldrStatus = ldr.read(); + pc.printf("LDR READING = %4.2f \r\n", ldrStatus); + if(ldrStatus >= 0.75f && ldrStatus <=1.0f) { + led.write(0.25); + led2.write(0.25); + led3.write(0.25); + } else if(ldrStatus >= 0.5f && ldrStatus < 0.75f) { + led.write(0.5); + led2.write(0.5); + led3.write(0.5); + } else if(ldrStatus >= 0.25f && ldrStatus < 0.5f) { + led.write(0.75); + led2.write(0.75); + led3.write(0.75); + } else if(ldrStatus >= 0.0f && ldrStatus < 0.25f) { + led.write(1.0); + led2.write(1.0); + led3.write(1.0); + } else { + led.write(0.0); + led2.write(0.0); + led3.write(0.0); + } + } +} + +int main() { + intensidadLDR(); +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Apr 17 16:09:53 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file