Well there's gotta be more to the story because if you look at the code size and not the dynamic memory usage things are a little different.
This code:
int buttonState1;
int buttonState2;
void setup() {
Serial.begin(19200);
delay(1000);
buttonState1 = digitalRead(2);
buttonState2 = digitalRead(3);
// Print so the compiler doesn't throw away my variables
Serial.println(buttonState1);
Serial.println(buttonState2);
}
void loop() {}
Sketch uses 2,690 bytes (8%) of program storage space. Maximum is 32,256 bytes.
Global variables use 186 bytes (9%) of dynamic memory, leaving 1,862 bytes for local variables. Maximum is 2,048 bytes.
bool buttonState1;
bool buttonState2;
void setup() {
Serial.begin(19200);
delay(1000);
buttonState1 = digitalRead(2);
buttonState2 = digitalRead(3);
// Print so the compiler doesn't throw away my variables
Serial.println(buttonState1);
Serial.println(buttonState2);
}
void loop() {}
Sketch uses 2,694 bytes (8%) of program storage space. Maximum is 32,256 bytes.
Global variables use 184 bytes (8%) of dynamic memory, leaving 1,864 bytes for local variables. Maximum is 2,048 bytes.
boolean buttonState1;
boolean buttonState2;
void setup() {
Serial.begin(19200);
delay(1000);
buttonState1 = digitalRead(2);
buttonState2 = digitalRead(3);
// Print so the compiler doesn't throw away my variables
Serial.println(buttonState1);
Serial.println(buttonState2);
}
void loop() {}
Sketch uses 2,550 bytes (7%) of program storage space. Maximum is 32,256 bytes.
Global variables use 184 bytes (8%) of dynamic memory, leaving 1,864 bytes for local variables. Maximum is 2,048 bytes.
So bool and boolean both reduce the dynamic memory usage by 2, obviously going from 2 bytes to 1.
But bool made the code size go UP by 4 bytes and boolean resulted in a significant reduction in code size over bool dropping the code size by 144 bytes over the code using bool.
So I wonder where those savings are coming from.