Analogread no response

I am trying to create a led animation with potentiometers.While turning pot13 clockwise,arduino stops to respond at the half of the pot movement.It doesn’t respond anyway with three potentiometers.What is the problem?

void setup() {                

  pinMode(A1, OUTPUT);     
  pinMode(2, OUTPUT);  
  pinMode(3, OUTPUT); 
  pinMode(4, OUTPUT); 
  pinMode(5, OUTPUT); 
  pinMode(6, OUTPUT); 
  pinMode(7, OUTPUT); 
  pinMode(8, OUTPUT); 
  pinMode(9, OUTPUT); 
  pinMode(10, OUTPUT); 
  pinMode(11, OUTPUT); 
  pinMode(12, OUTPUT); 
  pinMode(13, OUTPUT); 
  pinMode(14, OUTPUT); 
  pinMode(15, OUTPUT); 
  pinMode(16, OUTPUT); 
  pinMode(17, OUTPUT); 
  pinMode(18, OUTPUT); 
  pinMode(19, OUTPUT); 
  pinMode(20, OUTPUT); 
  pinMode(21, OUTPUT); 
  pinMode(22, OUTPUT); 
  pinMode(23, OUTPUT); 
  pinMode(24, OUTPUT); 
  pinMode(25, OUTPUT); 
  pinMode(26, OUTPUT); 
  pinMode(27, OUTPUT); 
  pinMode(28, OUTPUT); 
  pinMode(29, OUTPUT); 
  pinMode(30, OUTPUT);  
  pinMode(31, OUTPUT);  
  pinMode(32, OUTPUT);  
  pinMode(33, OUTPUT);  
  pinMode(34, OUTPUT);  
  pinMode(35, OUTPUT);  
  pinMode(36, OUTPUT);  
  pinMode(37, OUTPUT);  
  pinMode(38, OUTPUT);  
  pinMode(39, OUTPUT);  
  pinMode(40, OUTPUT);  
  pinMode(41, OUTPUT);  
  pinMode(42, OUTPUT);
  pinMode(43, OUTPUT);  
  pinMode(44, OUTPUT);  
  pinMode(45, OUTPUT);  
  pinMode(46, OUTPUT);  
  pinMode(47, OUTPUT);  
  pinMode(48, OUTPUT);  
  pinMode(49, OUTPUT);  
  pinMode(50, OUTPUT);  
  pinMode(51, OUTPUT);  
  pinMode(52, OUTPUT);  
  pinMode(53, OUTPUT);  
  pinMode(A2, OUTPUT);  
  pinMode(A3, OUTPUT);  
  pinMode(A4, OUTPUT);  
  pinMode(A5, OUTPUT);  
  pinMode(A6, OUTPUT);  
  pinMode(A7, OUTPUT);  
  pinMode(A8, OUTPUT); 
  pinMode(A9, OUTPUT); 
  pinMode(A10, OUTPUT); 
  pinMode(A11, OUTPUT); 
  pinMode(A12, OUTPUT);        
void loop() {
  int analogread0 = analogRead(A0);

  int analogread13 = analogRead(A13);

  int analogread15 = analogRead(A15);

  if ((385<=analogread0 && analogread0<=415) && (385<=analogread15 && analogread15<=415) ) {
    digitalWrite(A4, HIGH);
    digitalWrite(A2, HIGH);
    digitalWrite(53, HIGH);
    digitalWrite(52, HIGH);
    digitalWrite(51, HIGH);


  if ((385<=analogread0 && analogread0<=415) && (762<=analogread13 && analogread13<=778) ) {     
    digitalWrite(A1, HIGH); 
    digitalWrite(17, HIGH); 
    digitalWrite(33, HIGH); 
    digitalWrite(49, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (742<=analogread13 && analogread13<=758) ) {     

    digitalWrite(2, HIGH); 
    digitalWrite(18, HIGH); 
    digitalWrite(34, HIGH); 
    digitalWrite(50, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (722<=analogread13 && analogread13<=738) ) {     

    digitalWrite(3, HIGH); 
    digitalWrite(19, HIGH); 
    digitalWrite(35, HIGH); 
    digitalWrite(51, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (702<=analogread13 && analogread13<=718) ) {     
    digitalWrite(4, HIGH); 
    digitalWrite(20, HIGH); 
    digitalWrite(36, HIGH); 
    digitalWrite(52, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (682<=analogread13 && analogread13<=698) ) {     

    digitalWrite(5, HIGH); 
    digitalWrite(21, HIGH); 
    digitalWrite(37, HIGH); 
    digitalWrite(53, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (662<=analogread13 && analogread13<=678) ) {     

    digitalWrite(6, HIGH); 
    digitalWrite(22, HIGH); 
    digitalWrite(38, HIGH); 
    digitalWrite(A2, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (642<=analogread13 && analogread13<=658) ) {     

    digitalWrite(7, HIGH); 
    digitalWrite(23, HIGH); 
    digitalWrite(39, HIGH); 
    digitalWrite(A3, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (622<=analogread13 && analogread13<=638) ) {     

    digitalWrite(8, HIGH); 
    digitalWrite(24, HIGH); 
    digitalWrite(40, HIGH); 
    digitalWrite(A4, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (602<=analogread13 && analogread13<=618) ) {     

    digitalWrite(9, HIGH); 
    digitalWrite(25, HIGH); 
    digitalWrite(41, HIGH); 
    digitalWrite(A5, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (582<=analogread13 && analogread13<=598) ) {     

    digitalWrite(10, HIGH); 
    digitalWrite(26, HIGH); 
    digitalWrite(42, HIGH); 
    digitalWrite(A6, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (562<=analogread13 && analogread13<=578) ) {     

    digitalWrite(11, HIGH); 
    digitalWrite(27, HIGH); 
    digitalWrite(43, HIGH); 
    digitalWrite(A7, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (542<=analogread13 && analogread13<=558) ) {     

    digitalWrite(12, HIGH); 
    digitalWrite(28, HIGH); 
    digitalWrite(44, HIGH); 
    digitalWrite(A8, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (522<=analogread13 && analogread13<=538) ) {     

    digitalWrite(13, HIGH); 
    digitalWrite(29, HIGH); 
    digitalWrite(45, HIGH); 
    digitalWrite(A9, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (502<=analogread13 && analogread13<=518) ) {     

    digitalWrite(14, HIGH); 
    digitalWrite(30, HIGH); 
    digitalWrite(46, HIGH); 
    digitalWrite(A10, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (482<=analogread13 && analogread13<=498) ) {     

    digitalWrite(15, HIGH); 
    digitalWrite(31, HIGH); 
    digitalWrite(47, HIGH); 
    digitalWrite(A11, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (462<=analogread13 && analogread13<=478) ) {     

    digitalWrite(16, HIGH); 
    digitalWrite(32, HIGH); 
    digitalWrite(48, HIGH); 
    digitalWrite(A12, HIGH); 

  if ((385<=analogread0 && analogread0<=415) && (435<=analogread15 && analogread15<=465) ) {     

    digitalWrite(A1, LOW); 
    digitalWrite(2, LOW); 
    digitalWrite(3, LOW); 
    digitalWrite(4, LOW); 
    digitalWrite(5, LOW); 
    digitalWrite(6, LOW); 
    digitalWrite(7, LOW); 
    digitalWrite(8, LOW); 
    digitalWrite(9, LOW); 
    digitalWrite(10, LOW); 
    digitalWrite(11, LOW); 
    digitalWrite(21, LOW);
    digitalWrite(22, LOW);
    digitalWrite(23, LOW);
    digitalWrite(24, LOW);
    digitalWrite(25, LOW);
    digitalWrite(26, LOW);
    digitalWrite(27, LOW);
    digitalWrite(28, LOW);
    digitalWrite(29, LOW);
    digitalWrite(30, LOW);
    digitalWrite(31, LOW);



I assume you are using an arduino Mega, according to your numerous pins. I didn't go deep into your code, but I think your problem is that you are trying to read data from non existing pins (A13 and A15). From what I remember, there are only 12 analog inputs on the Mega, and their numbers should go from 0 to 11. Moreover, you are declaring all analog pins as outputs with the pinMode function, except the A0 one.

You should try to use for example A0, A1 and A2 to wire your pots in, and declare these three analog inputs as inputs (even if this must be their default state, as your first pot is already working as an input) :

pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);

And the rest as outputs, as in your code. And then get the data as you already do in your code, but with something like :

void loop() {
  int analogread0 = analogRead(A0);
  int analogread1 = analogRead(A1);
  int analogread2 = analogRead(A2);
  etc ...

I think this should work.


I didn't go deep into your code, but I think your problem is that you are trying to read data from non existing pins (A13 and A15). From what I remember, there are only 12 analog inputs on the Mega, and their numbers should go from 0 to 11.

It's easy to check

Solved it.It was a power supply problem.