![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Código que gera a onda senoidal
Dependencies: mbed SeeedShieldBot BluetoothSerial
main.cpp@0:466ca3f1c7e1, 2021-05-31 (annotated)
- Committer:
- pedrohmo22
- Date:
- Mon May 31 17:50:58 2021 +0000
- Revision:
- 0:466ca3f1c7e1
- Child:
- 1:3caba2fe325c
codigo_onda_triangular
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pedrohmo22 | 0:466ca3f1c7e1 | 1 | #include "mbed.h" |
pedrohmo22 | 0:466ca3f1c7e1 | 2 | |
pedrohmo22 | 0:466ca3f1c7e1 | 3 | BusOut saida (D3,D4,D5,D6); |
pedrohmo22 | 0:466ca3f1c7e1 | 4 | AnalogIn leitura(A5); |
pedrohmo22 | 0:466ca3f1c7e1 | 5 | Serial pc(USBTX, USBRX); |
pedrohmo22 | 0:466ca3f1c7e1 | 6 | |
pedrohmo22 | 0:466ca3f1c7e1 | 7 | float leitura_float; |
pedrohmo22 | 0:466ca3f1c7e1 | 8 | |
pedrohmo22 | 0:466ca3f1c7e1 | 9 | int main(){ |
pedrohmo22 | 0:466ca3f1c7e1 | 10 | pc.baud(9600); |
pedrohmo22 | 0:466ca3f1c7e1 | 11 | leitura_float = 0; |
pedrohmo22 | 0:466ca3f1c7e1 | 12 | while (1){ |
pedrohmo22 | 0:466ca3f1c7e1 | 13 | for (int i = 0; i <= 15; i++){ |
pedrohmo22 | 0:466ca3f1c7e1 | 14 | saida = i; |
pedrohmo22 | 0:466ca3f1c7e1 | 15 | leitura_float = leitura.read(); |
pedrohmo22 | 0:466ca3f1c7e1 | 16 | pc.printf("\r%f\n",leitura_float*3.3); |
pedrohmo22 | 0:466ca3f1c7e1 | 17 | wait(0.01); |
pedrohmo22 | 0:466ca3f1c7e1 | 18 | } |
pedrohmo22 | 0:466ca3f1c7e1 | 19 | |
pedrohmo22 | 0:466ca3f1c7e1 | 20 | for (int i = 15; i >= 0; i--){ |
pedrohmo22 | 0:466ca3f1c7e1 | 21 | saida = i; |
pedrohmo22 | 0:466ca3f1c7e1 | 22 | leitura_float = leitura.read(); |
pedrohmo22 | 0:466ca3f1c7e1 | 23 | pc.printf("\r%f\n",leitura_float*3.3); |
pedrohmo22 | 0:466ca3f1c7e1 | 24 | wait(0.01); |
pedrohmo22 | 0:466ca3f1c7e1 | 25 | } |
pedrohmo22 | 0:466ca3f1c7e1 | 26 | } |
pedrohmo22 | 0:466ca3f1c7e1 | 27 | } |