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.
main.cpp
- Committer:
- victorhlvsilva
- Date:
- 2019-05-06
- Revision:
- 0:d31aa980a1f9
File content as of revision 0:d31aa980a1f9:
#include "mbed.h"
Serial pc(USBTX, USBRX);
AnalogIn Joy_X(A3);
AnalogIn Joy_Y(A5);
DigitalIn Joy_B(PC_13);
DigitalOut saida_IN1a(D5);
DigitalOut saida_IN1b(A0);
DigitalOut saida_IN2a(D4);
DigitalOut saida_IN2b(A1);
DigitalOut saida_ENa(D2);
DigitalOut saida_ENb(A4);
float JX;
float JY;
bool JB;
bool JBb = 0;
int main() {
saida_ENa = 0;
saida_ENb = 0;
while(1){
JX = Joy_X;
JY = Joy_Y;
JB = Joy_B;
if (JB == 0){
saida_ENb = 1;
saida_ENa = 0;
saida_IN1b = 0;
saida_IN2b = 1;
wait_ms(500);
saida_IN2b = 0;
while(JB == 0){
}
saida_IN1b = 1;
saida_IN2b = 0;
wait_ms(500);
saida_IN1b = 0;
}
if (JX >= 0.6f || JX <= 0.4f ){
saida_ENa = 1;
saida_ENb = 0;
if (JX >= 0.6f){
saida_IN1a = 0;
saida_IN2a = 1;
}
else if (JX <= 0.4f){
saida_IN1a = 1;
saida_IN2a = 0;
}
}
else if (JY >= 0.6f || JY <= 0.4f ){
saida_ENb = 1;
saida_ENa = 0;
if (JY >= 0.6f){
saida_IN1b = 0;
saida_IN2b = 1;
}
else if (JY <= 0.4f){
saida_IN1b = 1;
saida_IN2b = 0;
}
}
else{
saida_ENa = 0;
saida_ENb = 0;
}
}
}