Advice on Shrinking SRAM Requirement

Hi,

Right now, I have a project using an Arduino Uno to drive an RGB LED strip. The Uno is controlled using IR receiver from my IR remote control. So, far it runs well and has no significant problem. However, I've decided to make my project to be more permanent by using ATTINY85 that will be put into my custom PCB.

The problem is that the current Arduino sketch is too big to be flashed into ATTINY85. The micro has only 8KB of Flash memory and 512 bytes of SRAM, whereas my program uses 8000 bytes and 530 bytes of global variables. I'm looking for some tips on how to reduce the memory requirement of my sketch so it can fit into the ATTINY. Any help is appreciated.

The codes are attached.

If you can use one less library, that would save space, but it takes a lot of time to do this so is often not worth the effort for a one-off project. By writing numerous arduino test sketches to see hex values such as 0x80 on serial monitor, you can (with sneaky extra Serial.println(b) ) in a lot of different places find out what was being done by certain libraries in your program. If for example, the net result of the only two calls to a huge library turn out to be 0x80 and 0xA0 then you might do without that library and use something simpler to make those calls instead.

You have not written anything to define the complexity of "controlled", which symanticly could mean anything from "toggle a lamp ON/OFF" requiring one more byte on an arduino or an 85 to store the recieved state, to "change language of user interface and global dictionary to mandarin" which would use quite a lot more than that.

I'm looking for some tips on how to reduce the memory requirement of my sketch so it can fit into the ATTINY.

Why must you go from an Atmega328 to an Attiny85? Even if you trimmed 10%, you are still running critically close to the edge. The Atmega328 is only a couple of $$$ more. Now, if you are going to manufacture 25 or more, then I can understand the additional cost concerns.

If you purchase the Atmega328 in QFP32 packaging, the the pricing from China starts at $1.23 each /Qty 10.

BUT, for $1.26 you can purchase an Arduino mini 168 complete. (328 mini's are $1.63)

I'm fond of the tiny85 but I am personally not going to spend hours of time trying to optimize a perfectly good 328 UNO design just to squeeze it into a tiny85. It's poor engineering IMO to leave yourself no wiggle-room in the downport.

Ray