Hello,
I have a weird problem with my Arduino Pro mIni, the reading for A6 pin connected to one of thump joystick pot's is reading maximum ~800 and at the middle position the value is 42, at the lower position is zero, I can't understand why it's not working correct. If I insert the same cable to another pin I get the correct reading max:1023, middle ~507, min:0
here is a sample code I made just to test the joystick
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20,20,4);
unsigned long currentmillis = 0;
long previousMillis = 0;
long LCDpreviousMillis = 0;
int lcd_refresh = 150;
// TESTED HW CONFIG
const int left_right_pin = A7;
const int up_down_pin = A0;
const int click_pin = 10;
int left_right_value;
int up_down_value;
int click_value ;
long int loop_count = 0;
String title = "XWD Tester: JOYSTICK";
void setup()
{
pinMode(left_right_pin, INPUT);
pinMode(up_down_pin, INPUT);
pinMode(click_pin, INPUT_PULLUP);
// initialize the lcd
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print(title);
delay(2000);
// initialize serial connection
Serial.begin(9600);
}
void loop()
{
left_right_value = analogRead(left_right_pin);
up_down_value = analogRead(up_down_pin);
click_value = digitalRead(click_pin);
loop_count++;
unsigned long currentMillis = millis();
if(currentMillis - LCDpreviousMillis > lcd_refresh ) // && stepper3.distanceToGo() == 0
{
LCDpreviousMillis = currentMillis;
lcd.setCursor(0,1);
lcd.print("Left Right ");
lcd.print(left_right_value);
lcd.print(" ");
lcd.setCursor(0,2);
lcd.print("Up Down ");
lcd.print(up_down_value);
lcd.print(" ");
lcd.setCursor(0,3);
lcd.print("Click ");
lcd.print(click_value);
lcd.print(" ");
// PRINT ON SERIAL
Serial.print("Left Right [");
Serial.print(left_right_value);
Serial.print("] ");
Serial.print("Up Down [");
Serial.print(up_down_value);
Serial.print("] ");
Serial.println("");
}
}