char buffer;// ...sprintf(buffer,"The temperature is %f degrees C", temperature);Serial.println(buffer);
QuoteSo why, 'const int tempPin = 1;' instead of the old 'int tempPin = 1;'?The "const" tells the compiler the value will never change. Therefore, instead of allocating a variable and taking up valuable RAM space, and slowing the system down reading and writing from RAM, it just uses the number "1".It's functionally the same asCode: [Select]#define tempPin 1but has the advantage that it is typecast to an int.
So why, 'const int tempPin = 1;' instead of the old 'int tempPin = 1;'?
#define tempPin 1
are there any other ways to reduce the program size
const int tempPin = 1; // defines the LM35 input into analogue pin 1int valFan = 0; // creates an integer used for temperature mapping, this being mapped fan speed - default to 0const int fanPin = 9; // defines the fan output connected to digital pin 5const int onboardLED = 13;long previousMillis = 0;const unsigned long interval = 500;
long previousMillis = 0;
unsigned long previousMillis = 0;