Hardware Reference
In-Depth Information
N 78 4E
O 79 4F
P 80 50
Q 81 51
R 82 52
S 83 53
T 84 54
U 85 55
V 86 56
W 87 57
X 88 58
Y 89 59
Z 90 5A
To run this sketch, simply upload it from the Arduino IDE. By pressing
Ctrl+Shift+M, or by going to Tools
Serial monitor menu item, you can access
the serial monitor that enables you to read the serial data and to input values.
Try this out and have fun with it.
This sketch is not perfect, there are a few l aws that were left in. For example,
when reading from the serial port, the sketch i rst waits 10 seconds. This is not
a particularly desirable interaction; the user doesn't know how long they have,
and they may not react in time. How would you change the sketch so that it
waits until data is available? The available() function might be useful. You
could also try to accomplish the same with peek() .
Secondly, the sketch does not check for any problems; it might not receive a
name, or it might not receive a correct age. This is also left as an exercise; try to
correct this, and re-ask the question if the sketch does not receive a good answer.
How could you add additional columns to display octal values? What about
binary?
SoftwareSerial
When no more serial ports are physically available, the SoftwareSerial library
can use software to emulate serial communications on other digital pins without
the need for a UART. This allows you to have multiple serial ports on a device
that would not normally allow it. Because transmission is handled by software
and not hardware, only one SoftwareSerial port can receive data at any time.
Also, speed is limited to 115,200 baud.
This introduces the concept of libraries. A library is software that can be added
as required. It provides functionality and is often not something that you would
need every time. If your sketch does not require a library, there is nothing else
to do. If your sketch does require a library, you must i rst import it, that is to
say tell the Arduino IDE that your sketch requires the functionality provided
by a library. To see the list of libraries available, look at the Arduino IDE in the
 
Search WWH ::




Custom Search