Olivia Itzel Solano / Mbed 2 deprecated ControlDeHumedad

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 Serial pc (USBTX, USBRX);
00004 DigitalOut bomba(D2);
00005 DigitalOut ledr(LED1);
00006 DigitalOut ledg(LED2);
00007 AnalogIn hum(A0);
00008 float valor,pin;
00009 
00010 
00011 int main() {
00012      
00013     while(1) {
00014         // valor=hum;
00015          valor=hum.read();
00016          valor= valor*1000;
00017                 wait (1.0);
00018                 
00019          if(valor <=500){
00020         pc.printf("humedo %.0f\n",valor);
00021         ledg=0;
00022         bomba=1;
00023          }else{
00024              ledg=1;
00025             }
00026              if (valor>500 ){
00027                pc.printf("seco %.0f\n",valor);
00028                  ledr=0;
00029                bomba=0;
00030                  }else{
00031                      ledr=1;
00032                  }
00033                  
00034                      }}
00035