We love Arduino we want to make some fancy project  but in this beautiful playground we have some limitations.  32K Programming memory is quite enough but 2K SRAM is becoming insufficient  when we use  lot of variable, especially if we don’t use the variables in efficient way.

For example; if the variable will have a value between 0 and 255 ve use byte, uint8_t and with the same  approach for a variable which will have only 1 and 0 (true/false) we use Boolean right?

But Arduino use 1 byte of memory space for each Boolean variable. Do you know that?

So for 8 booleans 8 bytes of memory space, instead of only one byte! You can be careless about this but when you approach to the end of the medium/big size project sometimes we really need few bytes more and we go for hunting some bytes in the project. This is really happend to me, that’s why I had to find a solution to gain a little bit more memory space by hunting fat booleans who consumes 1 byte (8 bits)

With the macro, I’ve written I compress them in a space that they worth. So 8 booleans take 1 byte (8 bit) only! Means; %85 memory saving.

And this Macro Code for your projects, can be added in every project (like a library) because it is using zero byte of memory space.

Tiny space for tiny variable. End Of Fat Booleans!

Sketch below is using Real Bit Boolean utilisation.

 

boolPack is 1 byte only and contain 8 booleans. if I delete this variable, global variables use 200 bytes.

Proof: 201(with 1 byte boolean pack)   – 200(without any variable) = 1 byte used.

 


I added this second standard boolean example for you to compare.

Big space for what it is.

Sketch below is using standard Boolean.

 

Proof: 208 (with 8 booleans) – 200 (without any variable) = 8 byte used.