Arduino Object Array initialization I just got an Idea of trying to code rain simulation with arduino and Adafruit OLED display. When I finished it was quite messy code so I thought That maybe doing it Object Oriented would help. This code is just a sketch that MAYBE works. The thing is that I need to create an array of objects(drops) and then display them. I have tried to display just one drop and it does not seem to do anything, even Serial wont print the pos_y. I have never wrote an Arduino code with objects so I just made a quick research and tried. here is the code:

#include &lt;SPI.h&gt;
#include &lt;Wire.h&gt;
#include &lt;Adafruit_GFX.h&gt;
#include &lt;Adafruit_SSD1306.h&gt;

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

class Drop{
  private: 
  int pos_x = random(0, 128);
  int pos_y = random(-5, -20);
  int len = random(3, 7); 
  int speed = random(6, 13);
public: 
 void fall()
{
 display.drawFastVLine(pos_x, pos_y, len, 1);
 pos_y = pos_y + speed;
 delay(5);
 Serial.println(pos_y);
 display.display();
 display.clearDisplay();
}

};

Drop* drop = new Drop[50];


void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.display(); 
}

void loop() {
  drop[1].fall();
} 


I will appreciate any suggestion or solution, spent almost entire day doing this "simple thing"..
The code works without the display commands. A problem could be that you start with negative pos_y and use it as parameter for drawFastVLine.

Function random returns first parameter if it is a larger value then the second parameter. random(-5, -20) always returns -5.

To have more random random values, you should call randomSeed in setup().

And you can use global array Drop drop[50];.