All values of analog sensors are getting max value!

GuillermoBastian94
Posts: 2
Joined: Thu Dec 24, 2020 5:34 pm

All values of analog sensors are getting max value!

Postby GuillermoBastian94 » Thu Dec 24, 2020 6:03 pm

Hi all,
Hope you´re fine,
It´s my 1st post, sorry if I missing some policy.
Well, hope you can help me. The problem is that Im using 2 analog sensors (as playstation analogs), and I´m making 4 simple analog reads and print in Serial screen of Arduino IDE.
The problem is that when the program is running when Im move the any analog to max value (X or Y), the 4 values are getting 4095 value, here an example.

Example:
1st.- The proram is running without touch any analog
X1 = 2075 Y1 = 2075 X2 = 2075 X2 = 2075

2nd.- When I turned an analog to min value works properly, for example gonna move X1 to 0
X1 = 0 Y1 = 2075 X2 = 2075 X2 = 2075

3rd.- But when I moved any analog to max value (for example X1), the for values get 4095
X1 = 4095 Y1 = 4095 X2 = 4095 X2 = 4095

Someone knows what could be the reason of this? Maybe my board is broaken?

Below Im attaching my code:

Thanks in advance,

Additional Details:

-Each analog has 4 pins, GND, VCC, X and Y. So I have 2 analogs, I have 4 Analog reads (X1, Y1, X2, Y2)
- Code :

Code: Select all

int a1 = 25;
int a2 = 26;
int a3 = 32;
int a4 = 33;

int v1;
int v2;
int v3;
int v4;

void setup() {
  // put your setup code here, to run once:
Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:

v1 = analogRead(a1);
delay(50);
v2 = analogRead(a2);
delay(50);
v3 = analogRead(a3);
delay(50);
v4 = analogRead(a4);
delay(50);

Serial.print(v1);
Serial.print("\t");
Serial.print(v2);
Serial.print("\t");
Serial.print(v3);
Serial.print("\t");
Serial.print(v4);
Serial.println();
}
- The schematic is very simple, only Im connecting both analogs to pings 25, 26, 32 and 33

Who is online

Users browsing this forum: No registered users and 121 guests