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 Voltimetro_V2
main.cpp
- Committer:
- henriquer
- Date:
- 2020-03-31
- Revision:
- 0:fc0918bb465b
- Child:
- 1:056009a99b8c
File content as of revision 0:fc0918bb465b:
#include "TextLCD.h"
#include "mbed.h"
AnalogIn AXIS_X(A1);
AnalogIn AXIS_Y(A2);;
TextLCD lcd(D8, D9, D4, D5, D6, D7);
Serial pc(USBTX, USBRX);
int main()
{
float VAR_X = 0.0f, VAR_Y = 0.0f;
lcd.setBacklight(TextLCD::LightOn); // Habilita a função Backlight
while(1)
{
VAR_X = AXIS_X.read();
VAR_Y = AXIS_Y.read();
lcd.setAddress(2,0); // Informa a posição que a mensagem será exibida no display LCD
lcd.printf("!!JOYSTICK!!");
pc.printf("\n%1.2f ",VAR_X);
pc.printf("\n%1.2f ",VAR_Y);
if(VAL_X > 0.40f) {
lcd.setAddress(0,1);
lcd.printf("Posicao:");
lcd.setAddress(9,1);
lcd.printf("RIGHT");
pc.printf("\n%1.2f ",VAR_X);
wait(2);
lcd.cls();
}
if(VAL_X < 0.3f) {
lcd.setAddress(0,1);
lcd.printf("Posicao:");
lcd.setAddress(9,1);
lcd.printf("LEFT");
pc.printf("\n%1.2f ",VAR_X);
wait(2);
lcd.cls();
}
if(VAL_Y > 0.41f) {
lcd.setAddress(0,1);
lcd.printf("Posicao:");
lcd.setAddress(9,1);
lcd.printf("UP");
pc.printf("\n%1.2f ",VAR_Y);
wait(2);
lcd.cls();
}
if(VAL_Y < 0.3f) {
lcd.setAddress(0,1);
lcd.printf("Posicao:");
lcd.setAddress(9,1);
lcd.printf("DOWN");
pc.printf("\n%1.2f ",VAR_Y);
wait(2);
lcd.cls();
}
wait(0.5);
}
}