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.
Diff: conversor.cpp
- Revision:
- 7:f69e1333449d
- Parent:
- 6:e8afe3e31edb
- Child:
- 8:20afab089ff8
diff -r e8afe3e31edb -r f69e1333449d conversor.cpp
--- a/conversor.cpp Mon Jun 08 14:49:08 2020 +0000
+++ b/conversor.cpp Mon Jun 08 14:57:33 2020 +0000
@@ -1,7 +1,7 @@
#include "mbed.h"
#include <math.h>
BusOut saida_digital (D2,D3,D4);
-DigitalIn botao_usuario(PC_13);
+InterruptIn botao_usuario(PC_13);
AnalogIn leitura_an(A0);
Serial pc(USBTX, USBRX);
@@ -18,6 +18,14 @@
0b110,
0b111
};
+void funcao_botao(){
+ if (estado_botao < 4){
+ estado_botao++;
+ }
+ else{
+ estado_botao = 0;
+ }
+}
int main(){
estado_botao=0;
@@ -25,14 +33,8 @@
pc.printf("\r");
pc.printf("oi");
while(1){
- if (botao_usuario == 0){ //Onda quadrada
- if (botao_usuario < 4){
- estado_botao++;
- }
- else{
- estado_botao = 0;
- }
- }
+ pc.printf("%d",estado_botao);
+ botao_usuario.fall(&funcao_botao);
if(estado_botao == 0){
for (int i=0; i<8; i++) {
saida_digital = 0b111;
@@ -60,13 +62,13 @@
saida_digital = SEQUENCIA[i];
wait(0.5);
valor=leitura_an.read();
- pc.printf("\r\t%1.3f\n",i);
+ pc.printf("\r\t%1.3f\n",valor);
}
for (int i=8; i>0; i--) {
saida_digital = SEQUENCIA[i];
wait(0.5);
valor=leitura_an.read();
- pc.printf("\r\t%1.3f\n",i);
+ pc.printf("\r\t%1.3f\n",valor);
}
}
