Enrico Aloisi Nardi / Mbed 2 deprecated conversor_dac

Dependencies:   mbed

Committer:
amandarm
Date:
Mon Jun 08 14:33:14 2020 +0000
Revision:
2:8e9dbb7523e7
Parent:
1:d05e46c73155
Child:
3:b0a44d2901a1
busout

Who changed what in which revision?

UserRevisionLine numberNew 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");
enricoan 0:f2560180665b 24 while(1){
amandarm 2:8e9dbb7523e7 25 for (int i=0; i<8; i++) {
amandarm 2:8e9dbb7523e7 26 saida_digital = SEQUENCIA[i];
enricoan 0:f2560180665b 27 valor = 3.3*leitura_an.read(); //conversão propriamente dita
enricoan 0:f2560180665b 28 pc.printf("\r\t%1.3f\n", valor);
enricoan 0:f2560180665b 29 wait(0.5);
enricoan 0:f2560180665b 30 }
amandarm 2:8e9dbb7523e7 31
amandarm 2:8e9dbb7523e7 32 }
amandarm 2:8e9dbb7523e7 33 }
enricoan 0:f2560180665b 34