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.
Joystick.cpp
- Committer:
- kaiquedog
- Date:
- 2022-01-18
- Revision:
- 3:e4e890a46ff8
File content as of revision 3:e4e890a46ff8:
#include "Joystick.h"
Joystick::Joystick(PinName vrx, PinName vry, PinName Sw) : VRX(vrx), VRY(vry), Switch(Sw){
}
/*
***************
**** LER_X ****
***************
*/
int Joystick::ler_x(void){
int a = 2;
if (VRX.read()*1000 > 800){
a = 1;
}
if (VRX.read()*1000 < 200){
a = 0;
}
return a;
}
/*
***************
**** LER_Y ****
***************
*/
int Joystick::ler_y(void){
int a = 2;
if (VRY.read()*1000 > 800){
a = 1;
}
if (VRY.read()*1000 < 200){
a = 0;
}
return a;
}
/*
********************
**** BOT_SELECT ****
********************
*/
int Joystick::bot_select(void){
int a = 2;
switch(Switch){
case 1: a = 1; break; // Botão desapertado
case 0: a= 0; break; // Botão apertado
}
return a;
}