Download User Manual

Transcript
Before the Arduino can communicate with the ATS-1, the serial port must be set up. Be sure the Serial.begin(4800);
statement is in the setup function at the start of your program.
void setup()
{
Serial.begin(4800); // opens serial port, sets data rate to 4800 bps
}
Sending data to be displayed on the LCD display is very simple. You use the standard Serial.print() functions. If you are
using a software UART, there will be a similar function. The first program written by programmers is the “Hello, world!”
program. Printing this only requires the following line of code: Serial.print(“Hello, world!”);
When a character is sent to the ATS-1 to be displayed, it will show up at the position indicated by the cursor, just like
when typing on a PC. After a reset, the ATS-1 will have the visible cursor turned off. You can optionally display a cursor
in the form of a blinking box or an underline. See Appendix 1 for instructions on controlling the cursor display.
Serial.write() is used to issue commands to the LCD. Some of the commands allow the program to clear the display,
position the cursor, select the cursor type and turn it on or off, etc. These are described in Appendix 1. Note that the
commands use non-printable characters, requiring the Serial.write(n); statement. Note that the Serial.print(n,BYTE);
statement, which was an alternative way to send non-printable characters is not supported starting with the Arduino 1.0
development environment.
The buzzer and LED are also controlled with Serial.write(n); commands. There is a command to turn the LED ON and
another to turn it OFF. The LED will stay in its current state until it gets another LED command. Sending the Beep
command turns the buzzer on for 1/3 of a second after which it will stop. If a second Beep command is sent before the
first one is completed, an internal timer will be reset for an additional 1/3 second of the buzzer running from the time the
second command is sent. Sending a series of Beep commands will not accumulate the amount of time the buzzer operates.
For example sending the command 3 times in succession with no delays between them will only play a few milliseconds
longer than the normal 1/3 second.
Pressing a switch sends a serial byte of data to the Arduino. The switches are numbered 1-6 and have labels shown
below. Pressing switch 1 (^) will send an ASCII ‘1’ to the Arduino. Pressing switch 2 (>) sends an ASCII ‘2’, etc.
Switches 1-4 are arranged in a cross pattern with arrow legends for UP, DOWN, LEFT, and RIGHT. Your software can
use them for moving the LCD cursor around, selecting options in a menu, or whatever you want your program to use them
for. Switches 5 and 6 are labeled F1 and F2 and can be used for any purpose you define them for.
Switch Label
Character Returned
^
1
>
2
<
3
V
4
F1
5
F2
6
Pressing a switch will send a single ASCII character. The switch must be released before it or another switch closure will
be recognized by the ATS-1 microcontroller.
The RESET switch does not send commands, but rather does a hard reset on the ATS-1 and the Arduino host board.
The Serial.read() function is used to catch switch press characters. Example:
char Key; //define the variable to hold the byte send back
Key = Serial.read();
// wait until the user presses a switch, Key will get the value of the switch pressed (1-6)