Stephanie Liu / Mbed 2 deprecated APS_ME_STEPHANIE_1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
stephanie_liu
Date:
Tue Sep 14 02:00:01 2021 +0000
Commit message:
aps 1 - stephanie liu;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 4e66272535f2 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 14 02:00:01 2021 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+//configuração de portas
+AnalogIn POT(A5);
+PwmOut ENA(D2);
+DigitalOut IN1A(D5);
+DigitalOut IN2A(D4);
+InterruptIn ENCONDER(D3);
+
+Timer tempo;
+int pulsos =0;
+const int HIGH = 1;
+const int LOW = 0;
+const int fonte = 12;
+
+//abertura de porta serial com a conexão USB
+Serial pc(USBTX, USBRX);
+  
+ 
+void Contador_BD(){pulsos++;}
+
+void Motor_A(float duty_cyle){
+    IN1A = LOW;
+    IN2A = HIGH;
+    ENA.write(duty_cyle);
+}
+
+int main(){
+    pc.baud(9600);
+    tempo.start(); 
+    ENCONDER.fall(&Contador_BD);
+    while(true){
+        float velocidade = POT.read();
+        Motor_A(velocidade);
+        if(tempo.read_ms() >= 1000){
+            pc.printf("TENSAO ARMADURA: %f\n\r", fonte*velocidade);
+            pc.printf("RPM: %d\n\r",pulsos*2);
+            pulsos=0;
+            tempo.reset();
+        }
+        
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 4e66272535f2 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 14 02:00:01 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file