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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 3:40a93d1f3a01
- Parent:
- 2:bc137c43710d
--- a/main.cpp Sat Feb 13 18:46:02 2021 +0000
+++ b/main.cpp Sat Feb 13 18:46:43 2021 +0000
@@ -5,19 +5,20 @@
*/
#include "mbed.h"
-
+
DigitalOut IN1A (D5);
DigitalOut IN2A (D4);
DigitalOut ENB (A4);
-PwmOut ENA (D2);
+PwmOut ENA (D2);
PwmOut IN1B (A0);
PwmOut IN2B (A1);
-
+
-Serial bt(PA_11,PA_12); // OU (D10,D2)
+Serial bt(PA_11,PA_12); // OU (D10,D2)
Serial pc(USBTX,USBRX);
-int main() {
+int main()
+{
float dutyENA = 0.50;
float dutyIN1B = 0.60;
float dutyIN2B = 0.60;
@@ -27,8 +28,8 @@
bt.printf("Connection Established");
while(1) {
if (bt.readable()) {
- char CONTROL= bt.putc(bt.getc());
-
+ char CONTROL= bt.putc(bt.getc());
+
if(CONTROL == 'R') { // Ré
ENA.write(dutyENA);
ENB = 1;
@@ -47,9 +48,9 @@
IN2B = 0;
IN1B.write(dutyIN1B);
bt.printf("Frente");
- wait_ms(500);
+ wait_ms(500);
}
- if(CONTROL == 'D') {
+ if(CONTROL == 'D') {
ENA.write(dutyENA);
ENB = 0;
IN1A = 0;
@@ -57,7 +58,7 @@
bt.printf("motor para esquerda");
wait_ms(500);
}
- if(CONTROL == 'E') {
+ if(CONTROL == 'E') {
ENA = 0;
ENB = 1;
IN2B=0;
@@ -65,7 +66,7 @@
bt.printf("motor para Direita");
wait_ms(500);
}
- if(CONTROL == 'T') {
+ if(CONTROL == 'T') {
ENA = 0;
ENB =0;
IN1A = 0;
@@ -75,9 +76,9 @@
pc.printf("motor parado");
wait_ms(500);
}
-
+
ENA = 0;
- ENB = 0;
+ ENB = 0;
}
- }
-}
\ No newline at end of file
+ }
+}
\ No newline at end of file