int counter = 0;
void setup() {
pinMode(10, OUTPUT);
digitalWrite(10, LOW);
Serial.begin(9600);
Serial.println("Enter the first number you would like to multiply:");
while (Serial.available() == 0) {}
String teststr = Serial.readString();
int a = teststr.toInt();
Serial.println("Enter the second number you would like to multiply:");
while (Serial.available() == 0) {}
String teststr2 = Serial.readString();
int b = teststr2.toInt();
Serial.println("Your two numbers multiplied together are:");
int ans = multiply(a,b);
}
int multiply(int a, int b) {
const int answer = a * b;
Serial.println(answer);
blink(answer);
}
void blink(int number){ //blinks led number of times answer gives
if (counter < 1) {
for (int i = 0; i < number; i++) {
digitalWrite(10, HIGH);
delay(500);
digitalWrite(10, LOW);
delay(500);
}
counter++;
}
else {
digitalWrite(10, LOW);
}
}
void loop() {
}