![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
poyecto
main_lecturade_voltaje.cpp@0:cf20365296f5, 2021-12-14 (annotated)
- Committer:
- agat
- Date:
- Tue Dec 14 10:50:46 2021 +0000
- Revision:
- 0:cf20365296f5
lol
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
agat | 0:cf20365296f5 | 1 | #include "mbed.h" |
agat | 0:cf20365296f5 | 2 | |
agat | 0:cf20365296f5 | 3 | Serial pc(USBTX, USBRX); // tx, rx |
agat | 0:cf20365296f5 | 4 | AnalogIn senal(A0); |
agat | 0:cf20365296f5 | 5 | |
agat | 0:cf20365296f5 | 6 | |
agat | 0:cf20365296f5 | 7 | int main() |
agat | 0:cf20365296f5 | 8 | { |
agat | 0:cf20365296f5 | 9 | pc.baud(115200); |
agat | 0:cf20365296f5 | 10 | |
agat | 0:cf20365296f5 | 11 | while (true) { |
agat | 0:cf20365296f5 | 12 | float tension=senal.read()*3.3; |
agat | 0:cf20365296f5 | 13 | pc.printf("Valor voltios %.4f leido flat\n",tension); |
agat | 0:cf20365296f5 | 14 | uint16_t datonentero=senal.read_u16(); |
agat | 0:cf20365296f5 | 15 | tension=(datonentero*3.3)/65536; |
agat | 0:cf20365296f5 | 16 | pc.printf("Valor voltios %.4f leido flat\n",tension); |
agat | 0:cf20365296f5 | 17 | wait(1.0); |
agat | 0:cf20365296f5 | 18 | } |
agat | 0:cf20365296f5 | 19 | } |