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
main.cpp
- Committer:
- hugocampos
- Date:
- 2021-02-13
- Revision:
- 2:bc137c43710d
- Parent:
- 1:d33dca22f3a1
- Child:
- 3:40a93d1f3a01
File content as of revision 2:bc137c43710d:
/*Programa com IHM04A1 (L6206) e bluetooth com 2 motores
Autor: Hugo Campos
Staus: Funcionando
Data:04/10/2020
*/
#include "mbed.h"
DigitalOut IN1A (D5);
DigitalOut IN2A (D4);
DigitalOut ENB (A4);
PwmOut ENA (D2);
PwmOut IN1B (A0);
PwmOut IN2B (A1);
Serial bt(PA_11,PA_12); // OU (D10,D2)
Serial pc(USBTX,USBRX);
int main() {
float dutyENA = 0.50;
float dutyIN1B = 0.60;
float dutyIN2B = 0.60;
bt.baud(9600);
//prints data on mobile
bt.printf("Connection Established");
while(1) {
if (bt.readable()) {
char CONTROL= bt.putc(bt.getc());
if(CONTROL == 'R') { // Ré
ENA.write(dutyENA);
ENB = 1;
IN1A = 1;
IN2A = 0;
IN1B=0;
IN2B.write(dutyIN2B);
bt.printf("Ré");
wait_ms(500);
}
if(CONTROL == 'F') { //Frente
ENA.write(dutyENA);
ENB = 1;
IN1A = 0;
IN2A = 1;
IN2B = 0;
IN1B.write(dutyIN1B);
bt.printf("Frente");
wait_ms(500);
}
if(CONTROL == 'D') {
ENA.write(dutyENA);
ENB = 0;
IN1A = 0;
IN2A = 1;
bt.printf("motor para esquerda");
wait_ms(500);
}
if(CONTROL == 'E') {
ENA = 0;
ENB = 1;
IN2B=0;
IN1B.write(dutyIN1B);
bt.printf("motor para Direita");
wait_ms(500);
}
if(CONTROL == 'T') {
ENA = 0;
ENB =0;
IN1A = 0;
IN2A = 0;
IN2B = 0;
IN1B = 0;
pc.printf("motor parado");
wait_ms(500);
}
ENA = 0;
ENB = 0;
}
}
}