#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
const int pinSEL = 2;
const int pinHORZ = A2;
const int pinVERT = A1;
// Valeurs pour les positions du joystick
int valSEL = 0;
int valHORZ = 0;
int valVERT = 0;
int valPWM = 0;
int valPWMlinks = 0;
int valPWMrechts = 0;
void setup() {
lcd.init(); lcd.backlight();
lcd.setCursor(6,0); lcd.print("Joystick");delay(2000);
lcd.clear();
pinMode(pinSEL, INPUT_PULLUP);
}
void loop() {
valSEL = digitalRead(pinSEL);
lcd.setCursor(0,0);
lcd.print("SEL: ");
lcd.print(valSEL);
valHORZ = analogRead(pinHORZ);
lcd.setCursor(0,1);
lcd.print("HORZ: ");
lcd.print(valHORZ);
lcd.print(" ");
valVERT = analogRead(pinVERT);
lcd.setCursor(0,2);
lcd.print("VERT: ");
lcd.print(valVERT);
lcd.print(" ");
/*
if(valVERT > 512)
{
if(valPWM<180)
{
valPWM++;
valPWMlinks=valPWMrechts=valPWM;
}
}
if(valVERT < 512)
{
if(valPWM>0)
{
valPWM--;
valPWMlinks=valPWMrechts=valPWM;
}
}
if (valHORZ < 512)
{
if(valPWMrechts>0)valPWMrechts--;
}
else if (valHORZ > 512)
{
if(valPWMlinks>0)valPWMlinks--;
}
else valPWMlinks=valPWMrechts=valPWM;
lcd.setCursor(0,1);
lcd.print("PWMl: ");
lcd.print(valPWMlinks);
lcd.print(" ");
lcd.print("PWMr: ");
lcd.print(valPWMrechts);
lcd.print(" ");
*/
}