Felipe Telles
/
Espelhinho
Espelhinho
Revision 0:8335b58dce7d, committed 2019-05-03
- Comitter:
- felipeto1
- Date:
- Fri May 03 01:03:18 2019 +0000
- Commit message:
- Espelhinho
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 03 01:03:18 2019 +0000 @@ -0,0 +1,106 @@ +#include "mbed.h" + +DigitalOut In1b(A0); +DigitalOut In2b(A1); +DigitalOut EnB(A4); + +DigitalOut In1a(D5); +DigitalOut In2a(D4); +DigitalOut EnA(D2); + +AnalogIn VJoyX(A3); +AnalogIn VJoyY(A5); + +DigitalIn Botao(PC_13); + + +int main () { + float JoyX = 1.6; + float JoyY = 1.6; + bool Re = 0; + + + while(1) { + + JoyX = 3.3*VJoyX; + JoyY = 3.3*VJoyY; + + printf("%1.2f, %1.2f\n\r",JoyX,JoyY); + printf("%B\n",Re); + + if (JoyX>2.0) { + //Mexer em X + EnA = 1; + In1a = 1; + In2a = 0; + wait(0.1); + + } + + if (JoyX<1.0) { + + //Inversão em X + EnA = 1; + In1a = 0; + In2a = 1; + wait(0.1); + + } + + if ((JoyX>1.0) and (JoyX <2.0)) { + + //Desligar X + EnA = 1; + In1a = 1; + In2a = 1; + wait(0.1); + + } + + if (JoyY>2.0) { + + //Mexer em Y + EnB = 1; + In1b = 1; + In2b = 0; + wait(0.1); + + } + + if (JoyY<1.0) { + + //Inversão em Y + EnB = 1; + In1b = 0; + In2b = 1; + wait(0.1); + + } + + if ((JoyY>1.0) and (JoyY <2.0)) { + + //Desligar Y + EnB = 1; + In1b = 1; + In2b = 1; + wait(0.1); + + } + Re=Botao; + + if (Re==0) { + //Mexer em X + EnB = 1; + In1b = 0; + In2b = 1; + wait(1); + + In1b = 1; + In2b = 0; + wait(1); + + } + + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri May 03 01:03:18 2019 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file