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.
conversor.cpp@3:b0a44d2901a1, 2020-06-08 (annotated)
- Committer:
- amandarm
- Date:
- Mon Jun 08 14:36:19 2020 +0000
- Revision:
- 3:b0a44d2901a1
- Parent:
- 2:8e9dbb7523e7
- Child:
- 4:76d5fb3100a3
mudanca busout
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
enricoan | 0:f2560180665b | 1 | #include "mbed.h" |
enricoan | 1:d05e46c73155 | 2 | #include <math.h> |
amandarm | 2:8e9dbb7523e7 | 3 | BusOut saida_digital (D2,D3,D4); |
amandarm | 2:8e9dbb7523e7 | 4 | DigitalIn botao_usuario(PC_13); |
amandarm | 2:8e9dbb7523e7 | 5 | AnalogIn leitura_an(A0); |
enricoan | 0:f2560180665b | 6 | |
enricoan | 0:f2560180665b | 7 | Serial pc(USBTX, USBRX); |
enricoan | 0:f2560180665b | 8 | float valor; |
enricoan | 0:f2560180665b | 9 | |
amandarm | 2:8e9dbb7523e7 | 10 | int SEQUENCIA[8]={ |
amandarm | 2:8e9dbb7523e7 | 11 | 0b000, |
amandarm | 2:8e9dbb7523e7 | 12 | 0b001, |
amandarm | 2:8e9dbb7523e7 | 13 | 0b010, |
amandarm | 2:8e9dbb7523e7 | 14 | 0b011, |
amandarm | 2:8e9dbb7523e7 | 15 | 0b100, |
amandarm | 2:8e9dbb7523e7 | 16 | 0b101, |
amandarm | 2:8e9dbb7523e7 | 17 | 0b110, |
amandarm | 2:8e9dbb7523e7 | 18 | 0b111 |
amandarm | 2:8e9dbb7523e7 | 19 | }; |
amandarm | 2:8e9dbb7523e7 | 20 | |
enricoan | 0:f2560180665b | 21 | int main(){ |
enricoan | 0:f2560180665b | 22 | pc.baud(9600); |
enricoan | 0:f2560180665b | 23 | pc.printf("\r"); |
amandarm | 3:b0a44d2901a1 | 24 | pc.printf("oi"); |
enricoan | 0:f2560180665b | 25 | while(1){ |
amandarm | 2:8e9dbb7523e7 | 26 | for (int i=0; i<8; i++) { |
amandarm | 2:8e9dbb7523e7 | 27 | saida_digital = SEQUENCIA[i]; |
enricoan | 0:f2560180665b | 28 | valor = 3.3*leitura_an.read(); //conversão propriamente dita |
enricoan | 0:f2560180665b | 29 | pc.printf("\r\t%1.3f\n", valor); |
enricoan | 0:f2560180665b | 30 | wait(0.5); |
enricoan | 0:f2560180665b | 31 | } |
amandarm | 2:8e9dbb7523e7 | 32 | |
amandarm | 2:8e9dbb7523e7 | 33 | } |
amandarm | 2:8e9dbb7523e7 | 34 | } |
enricoan | 0:f2560180665b | 35 |