Señales analogicas

Dependencies:   mbed

Committer:
javiervicente
Date:
Tue Dec 01 12:32:41 2020 +0000
Revision:
0:400fbf72c1de
analogica;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
javiervicente 0:400fbf72c1de 1 #include "mbed.h"
javiervicente 0:400fbf72c1de 2
javiervicente 0:400fbf72c1de 3 Serial pc(USBTX, USBRX); // tx, rx
javiervicente 0:400fbf72c1de 4 AnalogIn senal(A0);
javiervicente 0:400fbf72c1de 5
javiervicente 0:400fbf72c1de 6
javiervicente 0:400fbf72c1de 7 int main()
javiervicente 0:400fbf72c1de 8 {
javiervicente 0:400fbf72c1de 9 pc.baud(115200);
javiervicente 0:400fbf72c1de 10
javiervicente 0:400fbf72c1de 11 while (true) {
javiervicente 0:400fbf72c1de 12 float tension=senal.read()*3.3;
javiervicente 0:400fbf72c1de 13 pc.printf("Valor voltios %.4f leido flat\n",tension);
javiervicente 0:400fbf72c1de 14 uint16_t datonentero=senal.read_u16();
javiervicente 0:400fbf72c1de 15 tension=(datonentero*3.3)/65536;
javiervicente 0:400fbf72c1de 16 pc.printf("Valor voltios %.4f leido flat\n",tension);
javiervicente 0:400fbf72c1de 17 wait(1.0);
javiervicente 0:400fbf72c1de 18 }
javiervicente 0:400fbf72c1de 19 }