Change the code in the last example sketch so that the user is asked not only
how many times he wants to blink the LED, but also how long he wants each blink to last.
Then adjust the
delay()function calls accordingly.
Use the final example on getting data input,
which includes statements to get integer, floating point, and String values,
to test what happens when the user enters “good” values and “bad” values.
For example, try the same “good” answer (say,
1) in response to the prompt for an
integer, the prompt for a floating point number, and the prompt for a String.
(You may be surprised at the results.) Then provide a different response (say,
to all 3 prompts. Provide a negative response (
-1). Finally, provide a simple text
response to each of the 3 Serial input functions and see how they respond to these different
Write a sketch which prompts the user for a value in some range, say 0 through 100.
Test that the data provided by the user actually falls in this range. Keep repeating
the request for valid input until the user provides an answer in the desired range.
Count how many tries it took him to get it right. When he finally inputs a valid value,
display the number of tries it took him, and start the process again.