Read Part 2 First

Well, not all updates can show great achievement.

Right now I am working to change the same code that ran well on PC simulation to work on Arduino as well. Currently it is a struggle to fit all in the 2K memory footprint basically.

So after part 2 and the success on PC simulation, I moved my code to Arduino IDE, linked the LedControl library to drive the display. But when I compiled and uploaded to arduino, surprise-surprise I did not see it working. Some investigation pointed towards memory issues immediately. For example, if I decrease the number of balls considerably I can see the code working and 2-3 balls follow gravity and fall on the matrix display. But when I increase the count of balls, I see nothing and Serial prints junk non stop.

So I started trying to decrease footprint. Search what to get rid off and lessen dynamic memory usage by use of good old “#define CONSTANT value” type statements. There goes my attempt to have a nice/modern C++ code. Lessons learned, “Arduino C++” is really at most “C with classes”.

Main problem currently is the Ball class. Initially, each Ball object had a footprint of 21 bytes! I need 90-100 of them to represent sand particles in the hourglass. That by itself already takes me to the 2048 byte limit on Arduino. So now I am trying to use bit level flags to keep track of object state rather than nice big 1 byte bool flags, funny how fat 1 byte looks when you are fighting for Arduino memory :)

I brought down Ball object size to 15 bytes now and can see it display the hourglass fall on LED matrix with 20+ balls.

More work to do, very little spare time.