blob: e6f02a0bdab68e16ae83007137e23feec0282a6b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/*
IntegerInput by m. Ray Burnette - PUBLIC DOMAIN EXAMPLE
Maple Mini: Compiled under Arduino 1.6.0rc1
Sketch uses 15,624 bytes (14%) of program storage space. Maximum is 108,000 bytes.
Global variables use 3,704 bytes of dynamic memory.
*/
#define BAUD 9600
#define timeoutPeriod 2147483647 // Long time... about 25 days
int a;
int b;
void setup()
{
// initialize the digital pin as an output.
pinMode(BOARD_LED_PIN, OUTPUT);
Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART
Serial.setTimeout(timeoutPeriod); // default is 1 second
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
}
void loop()
{
Serial.println("Enter first integer: ");
a = Serial.parseInt();
Serial.print("a = ");
Serial.println(a);
Serial.println("Enter second integer: ");
b = Serial.parseInt();
Serial.print("b = ");
Serial.println(b);
Serial.print("Sum a + b =");
Serial.println( a + b);
Serial.print("Dif a - b =");
Serial.println(a - b);
}
|