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 filesystem TextLCD
Fork of Projeto_Mecatronico by
analog.cpp
- Committer:
- ricardoparanhos
- Date:
- 2022-06-19
- Revision:
- 36:6e46a3e4df6c
- Parent:
- 31:6d0ecd1b2573
File content as of revision 36:6e46a3e4df6c:
/*************************************************************
* Programa EXE-02
* 22-09-2021
* Leitura do botão-do-usuário e envio de informação via serial
*************************************************************/
#include "analog.h"
AnalogIn xAxis(A4);
AnalogIn yAxis(A5);
int direcao_botao_analogico ()
{
int x,y;
x = xAxis.read() * 1000; //adquiri posição do joystick
y = yAxis.read() * 1000;
if (x > 800) {
return 1;
} else if (x < 200) {//determina que sinal será enviado
return 0;
} else if (y > 800) {
return 3;
} else if (y < 200) {
return 2;
} else {
return 4;
}
}
