Trying to code a calculator that takes the answer of the sum and inputs the answer as the time for the LED to be On. Program seems to be in working order until i get above 42 seconds. Any ideas?
// a very simple addition calculator
int a;
int b;
int c;
int led=13;
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
}
void loop() {
Serial.println("Enter a number"); // the println adds a new line to he output window
while(!Serial.available()); // wait till a number has been entered
a = Serial.parseInt(); // treat as an Integer and read the whole number
Serial.println("Enter another number");
while(!Serial.available());
b = Serial.parseInt();
Serial.println("Enter another number");
while(!Serial.available());
c = Serial.parseInt();
Serial.println((a+b*c)); // Print the sum of a and b and c
Serial.print("You typed in "); // Echo what the user has typed in
Serial.print("The LED should stay on for ");
Serial.println(a+b*c);
Serial.println("seconds");
digitalWrite(led, HIGH);
delay((a+b*c)*1000);
digitalWrite(led, LOW);
delay(1000);
}