Countdown Timer doesn´t show numbers

Hi all!

I've been working on a project for a countdown counter that works with neopixel LEDs and an RTC DS3231, all this on an arduino nano.

The problem comes when I have tried to add the RTC to the new code, which works perfectly and in the serial monitor it does show what I want but when I look at the NEOPIXEL they don't show anything similar.

So I need some help if anyone can see or can help me with solving this problem.

I'll add the code that worked perfectly without RTC and the code that doesn't work with RTC so that you can compare it.

This is the code without RTC:

#include <Adafruit_NeoPixel.h>
#define PIN 10 // the pin your strip is connected to 
#define COUNT 396 // how many led's are on that strip  
Adafruit_NeoPixel strip = Adafruit_NeoPixel(COUNT, PIN, NEO_RGB + NEO_KHZ800); //defines the strips properties

void setColor(int Pixel, int R2, int G2, int B2) {
  uint32_t color = strip.Color(R2, G2, B2); // make a color
  strip.setPixelColor(Pixel, color); //set a single pixel color
  //update the colors
}
int col;
int A, M, D, H, m, s;
bool cuenta = 1;

bool digito[10][36] =
{
  { //0
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0, 0
  },
  { //1
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0
  },
  { //2
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1, 0
  },
  { //3
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1, 0
  },
  { //4
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //5
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //6
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //7
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0
  },
  { //8
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //9
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
};

void setup() {
  Serial.begin(9600);
  strip.begin();
  strip.show();
  strip.clear();
  A = 1;
  M = 0;
  D = 0;
  H = 0;
  m = 1;
  s = 10;
}

void loop() {
  if (cuenta = 1) {
    s--;
    if (s < 0) {
      s = 59;
      m--;
      if (m < 0) {
        m = 59;
        H--;
        if (H < 0) {
          H = 23;
          D--;
          if (D < 0) {
            D = 31;
            M--;
            if (M < 0) {
              M = 12;
              A--;
              if (A < 0) {
                A = 0;
                M = 0;
                D = 0;
                H = 0;
                m = 0;
                s = 0;
                cuenta = 0;
              }
            }
          }
        }
      }
    }
  }
  Serial.print(A);
  Serial.print("/");
  Serial.print(M);
  Serial.print("/");
  Serial.print(D);
  Serial.print("  // ");
  Serial.print(H);
  Serial.print(":");
  Serial.print(m);
  Serial.print(":");
  Serial.print(s);
  Serial.print("");
  Serial.println("");
  
  pd(0, A);
  pd(1, M / 10);
  pd(2, M % 10);
  pd(3, D / 10);
  pd(4, D % 10);
  pd(5, H / 10);
  pd(6, H % 10);
  pd(7, m / 10);
  pd(8, m % 10);
  pd(9, s / 10);
  pd(10, s % 10);

  delay(990);

}

void pd(int k, int j) {
  for (int i = 0 ; i < 36; i++ ) {
    col = digito[j][i] * 255;
    setColor(i + (k * 36), 0, col, 0);
  }
  strip.show();
}

And this is the code with RTC

#include <Wire.h>
#include <RTClib.h>
#include <Adafruit_NeoPixel.h>
#define PIN 10 // the pin your strip is connected to 
#define COUNT 396 // how many led's are on that strip

Adafruit_NeoPixel strip = Adafruit_NeoPixel(COUNT, PIN, NEO_RGB + NEO_KHZ800); //defines the strips properties
RTC_DS3231 rtc;


void setColor(int Pixel, int R2, int G2, int B2) {
  uint32_t color = strip.Color(R2, G2, B2); // make a color
  strip.setPixelColor(Pixel, color); //set a single pixel color
  //update the colors
}



int A, M, D, H, m, s;
bool cuenta = 1;
int col;
//DateTime now = rtc.now();
bool digito[10][37] =
{
  { //0
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0, 0
  },
  { //1
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0
  },
  { //2
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1, 0
  },
  { //3
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1, 0
  },
  { //4
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //5
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //6
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //7
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0
  },
  { //8
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //9
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
};

void setup() { 
  Serial.begin(9600);
  strip.begin();
  //strip.begin ();
 // strip.show();
 // strip.clear();
  rtc.begin();
  Wire.begin();
  // rtc.adjust(DateTime(F(__DATE__),F(__TIME__)));
  // delay(1000);
}

  
void loop() {
  
  strip.show();
  strip.clear();
  
   DateTime now = rtc.now();
  A = now.year() - 2021;
  M = - now.month() + 10;
  D = - now.day() + 31;
  H = 24 - now.hour();
  m = 60 - now.minute() ;
  s = 59 - now.second(); 

  if (cuenta = 1) {
    s--;
    if (s < 0) {
      s = 59;
      m--;
      if (m < 0) {
        m = 59;
        H--;
        if (H < 0) {
          H = 23;
          D--;
          if (D < 0) {
            D = 31;
            M--;
            if (M < 0) {
              M = - 12;
              A--;
               if (A < 0) {
                A = 0;
                M = 0;
                D = 0;
                H = 0;
                m = 0;
                s = 0;
                cuenta = 0;
                
               }
            }
          }
        }
      }
    }
  }
    pd(0, A);
  pd(1, M / 10);
  pd(2, M % 10);
  pd(3, D / 10);
  pd(4, D % 10);
  pd(5, H / 10);
  pd(6, H % 10);
  pd(7, m / 10);
  pd(8, m % 10);
  pd(9, s / 10);
  pd(10, s % 10); 
  
  Serial.print(A);
  Serial.print("/");
  Serial.print(M);
  Serial.print("/");
  Serial.print(D);
  Serial.print("  // ");
  Serial.print(H);
  Serial.print(":");
  Serial.print(m);
  Serial.print(":");
  Serial.print(s);
  Serial.print("");
  Serial.println("");
  
 // pd(0, A);
 // pd(1, M / 10);
 // pd(2, M % 10);
// pd(3, D / 10);
  //pd(4, D % 10);
  //pd(5, H / 10);
  //pd(6, H % 10);
 // pd(7, m / 10);
 // pd(8, m % 10);
  //pd(9, s / 10);
  //pd(10, s % 10); 
  
  delay (1000);
  
}
void pd(int k, int j) {
  for (int i = 0 ; i < 36; i++ ) {
   col = digito[j][i] * 255;
    setColor(i + (k * 36), 0, 0, 255);
   // strip.setPixelColor (i, 255, 255, 255);
  }
 strip.show();
 //strip.clear();
}

I doubt it

  if (cuenta = 1)

This sets cuenta to 1 every time through loop(). I expect you meant

  if (cuenta == 1)

Yesi meant that, i saw i have some errors , sorry

If you have made changes to the code then please post the new code here in a new post here. If you have errors when compiling then post the full error messages here in code tags

I changed it but it diddn´t solve it anything

HINT : we can't see the code that you changed

It didn´t solved nothing because the problem comes when i try to add the RTC module, before that it works.

But i have changed the code so you can see it better.

Thanks!

#include <Wire.h>
#include <RTClib.h>
#include <Adafruit_NeoPixel.h>
#define PIN 10 // the pin your strip is connected to 
#define COUNT 396 // how many led's are on that strip

Adafruit_NeoPixel strip = Adafruit_NeoPixel(COUNT, PIN, NEO_RGB + NEO_KHZ800); //defines the strips properties
RTC_DS3231 rtc;


void setColor(int Pixel, int R2, int G2, int B2) {
  uint32_t color = strip.Color(R2, G2, B2); // make a color
  strip.setPixelColor(Pixel, color); //set a single pixel color
  //update the colors
}



int A, M, D, H, m, s;
bool cuenta = 1;
int col;
//DateTime now = rtc.now();
bool digito[10][36] =
{
  { //0
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0, 0
  },
  { //1
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0
  },
  { //2
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1, 0
  },
  { //3
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1, 0
  },
  { //4
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //5
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //6
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //7
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0
  },
  { //8
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //9
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
};

void setup() { 
  Serial.begin(57600);
  strip.begin();
  //strip.begin ();
 // strip.show();
 // strip.clear();
  rtc.begin();
  Wire.begin();
  // rtc.adjust(DateTime(F(__DATE__),F(__TIME__)));
  // delay(1000);
}

  
void loop() {
  
  strip.show();
  strip.clear();
  
   DateTime now = rtc.now();
  A = now.year() - 2021;
  M = - now.month() + 10;
  D = - now.day() + 31;
  H = 24 - now.hour();
  m = 60 - now.minute() ;
  s = 59 - now.second(); 

  if (cuenta == 1) {
    s--;
    if (s < 0) {
      s = 59;
      m--;
      if (m < 0) {
        m = 59;
        H--;
        if (H < 0) {
          H = 23;
          D--;
          if (D < 0) {
            D = 31;
            M--;
            if (M < 0) {
              M = - 12;
              A--;
              if (A < 0) {
                A = 0;
                M = 0;
                D = 0;
                H = 0;
                m = 0;
                s = 0;
                cuenta == 0; 
                
              }
            }
          }
        }
      }
    }
  }
    pd(0, A);
  pd(1, P / 10);
  pd(2, P % 10);
  pd(3, P / 10);
  pd(4, P % 10);
  pd(5, H / 10);
  pd(6, H % 10);
  pd(7, m / 10);
  pd(8, m % 10);
  pd(9, s / 10);
  pd(10, s % 10); 
  
  Serial.print(A);
  Serial.print("/");
  Serial.print(M);
  Serial.print("/");
  Serial.print(D);
  Serial.print("  // ");
  Serial.print(H);
  Serial.print(":");
  Serial.print(m);
  Serial.print(":");
  Serial.print(s);
  Serial.print("");
  Serial.println("");
  
 // pd(0, A);
 // pd(1, M / 10);
 // pd(2, M % 10);
// pd(3, D / 10);
  //pd(4, D % 10);
  //pd(5, H / 10);
  //pd(6, H % 10);
 // pd(7, m / 10);
 // pd(8, m % 10);
  //pd(9, s / 10);
  //pd(10, s % 10); 
  
  delay (990);
  
}
void pd(int k, int j) {
  for (int i = 0 ; i < 36; i++ ) {
   col = digito[j][k] * 255;
    setColor(i + (k * 36), 0, col, 0);
   // strip.setPixelColor (i, 0, 255, 255);
  }
 strip.show();
 
}
                cuenta == 0;

Wrong

This does not set cuenta to zero. It compares cuenta to zero and throws away the result

                cuenta == 0;

This is still in the code and is still wrong

sorry i thought I changed it.

Heres the code right now:



#include <Wire.h>
#include <RTClib.h>
#include <Adafruit_NeoPixel.h>
#define PIN 10 // the pin your strip is connected to 
#define COUNT 396 // how many led's are on that strip

Adafruit_NeoPixel strip = Adafruit_NeoPixel(COUNT, PIN, NEO_RGB + NEO_KHZ800); //defines the strips properties
RTC_DS3231 rtc;


void setColor(int Pixel, int R2, int G2, int B2) {
  uint32_t color = strip.Color(R2, G2, B2); // make a color
  strip.setPixelColor(Pixel, color); //set a single pixel color
  //update the colors
}



int A, M, D, H, m, s;
bool cuenta = 1;
int col;
//DateTime now = rtc.now();
bool digito[10][36] =
{
  { //0
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0, 0
  },
  { //1
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0
  },
  { //2
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1, 0
  },
  { //3
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1, 0
  },
  { //4
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //5
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //6
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //7
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0
  },
  { //8
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
  { //9
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1,
    0, 0, 0, 0, 0,
    1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 0
  },
};

void setup() { 
  Serial.begin(57600);
  strip.begin();
  //strip.begin ();
 // strip.show();
 // strip.clear();
  rtc.begin();
  Wire.begin();
  // rtc.adjust(DateTime(F(__DATE__),F(__TIME__)));
  // delay(1000);
}

  
void loop() {
  
  strip.show();
  strip.clear();
  
   DateTime now = rtc.now();
  A = now.year() - 2021;
  M = - now.month() + 10;
  D = - now.day() + 31;
  H = 24 - now.hour();
  m = 60 - now.minute() ;
  s = 59 - now.second(); 

  if (cuenta == 1) {
    s--;
    if (s < 0) {
      s = 59;
      m--;
      if (m < 0) {
        m = 59;
        H--;
        if (H < 0) {
          H = 23;
          D--;
          if (D < 0) {
            D = 31;
            M--;
            if (M < 0) {
              M = - 12;
              A--;
              if (A < 0) {
                A = 0;
                M = 0;
                D = 0;
                H = 0;
                m = 0;
                s = 0;
                cuenta == 0; 
                
              }
            }
          }
        }
      }
    }
  }
    pd(0, A);
  pd(1, P / 10);
  pd(2, P % 10);
  pd(3, P / 10);
  pd(4, P % 10);
  pd(5, H / 10);
  pd(6, H % 10);
  pd(7, m / 10);
  pd(8, m % 10);
  pd(9, s / 10);
  pd(10, s % 10); 
  
  Serial.print(A);
  Serial.print("/");
  Serial.print(M);
  Serial.print("/");
  Serial.print(D);
  Serial.print("  // ");
  Serial.print(H);
  Serial.print(":");
  Serial.print(m);
  Serial.print(":");
  Serial.print(s);
  Serial.print("");
  Serial.println("");
  
 // pd(0, A);
 // pd(1, M / 10);
 // pd(2, M % 10);
// pd(3, D / 10);
  //pd(4, D % 10);
  //pd(5, H / 10);
  //pd(6, H % 10);
 // pd(7, m / 10);
 // pd(8, m % 10);
  //pd(9, s / 10);
  //pd(10, s % 10); 
  
  delay (990);
  
}
void pd(int k, int j) {
  for (int i = 0 ; i < 36; i++ ) {
   col = digito[j][k] * 255;
    setColor(i + (k * 36), 0, col, 0);
   // strip.setPixelColor (i, 0, 255, 255);
  }
 strip.show();
 
}

But the problem is that the neopixels doesn´t react to the code that has integrated the RTC module. Buf if i use the other without RTC it works

                cuenta == 0;

Please stop messing about and correct this

Please describe what the code is supposed to do and what it actually does