/*In programming, a "garbage value" refers to the undefined or indeterminate data contained
in a variable that has not been initialized. This value could be anything that was left in
the memory location designated for the variable, from previous operations or due to other factors.
Garbage values are problematic because they are unpredictable and can cause programs to behave
inconsistently or crash. They often lead to bugs that are hard to diagnose and fix.*/
void setup() {
Serial.begin(9600); // initialize serial communication at 9600 bits per second:
}
void loop() {
int sensorValue; // uninitialized variable
// print the garbage value to the serial monitor
Serial.print("Garbage value: ");
Serial.println(sensorValue);
// initialize the variable with a value from an analog input
sensorValue = analogRead(A0);
// print the initialized value to the serial monitor
Serial.print("Initialized value: ");
Serial.println(sensorValue);
delay(2000); // wait for 2 seconds before repeating the loop
}