Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
prueba_hsens.cpp
00001 #include "prueba_hsens.h" 00002 #include "Pinout.h" 00003 #include <math.h> 00004 #include <stdio.h> 00005 #include "Log.h" 00006 #include "mbed.h" 00007 00008 extern Log _; //Para luego escribir printf, me compilaba también sin ponerlo 00009 AnalogIn entrada(Pinout::pines::entr); //Definición de la entrada analógica 00010 00011 00012 prueba_hsens::prueba_hsens(){ 00013 00014 this->tension = 0; 00015 this->suma=0; 00016 this->media=0; 00017 this->medida =100; 00018 } 00019 00020 prueba_hsens::~prueba_hsens(){ 00021 printf("Se ha destruido una instancia y nunca se deberia destruir\r\n"); 00022 } 00023 00024 void prueba_hsens::medir_tension(){ 00025 00026 for(uint8_t i =0; i <medida; i++ ){ 00027 printf ("Medida numero "); 00028 printf ("%i",(i+1)); 00029 printf (". Tensión de sensor: "); 00030 this->tension = entrada; 00031 this->tension = this->tension*3.3; 00032 this->suma = this->suma + this->tension; 00033 printf ("%lf", tension); 00034 printf ("\n"); 00035 wait (0.1); 00036 } 00037 this->media = this->suma / medida; 00038 printf ("La tensión media es: "); 00039 printf ("%lf", media); 00040 this->suma = 0; 00041 this->media = 0; 00042 00043 return; 00044 }
Generated on Fri Aug 19 2022 07:33:34 by
1.7.2