18.11.2014 Views

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Displays<br />

Listing 8-5. Displays key presses on the host computer’s screen and on an<br />

LCD module.<br />

1 REM reserve space for 1 string variable,<br />

2 REM 1 character in length<br />

3 STRING 3,1<br />

4 REM You must add lines 10 through 380 of listing 8-4<br />

5 REM to this program<br />

400 Z=0<br />

410 DO<br />

420 INPUT “Press a key: ”,$(0)<br />

430 PRINT $(0)<br />

440 REM reset display after 8 characters<br />

450 IF Z=8 THEN Z=0:RW=0:I=1:GOSUB 900<br />

460 REM keep track of how many characters are displayed<br />

470 Z=Z+1<br />

480 REM display the character matching the key press<br />

490 D=ASC($(0),1):GOSUB 800<br />

500 WHILE 1=1<br />

600 END<br />

790 REM write data to the display<br />

800 XBY(X)=RS+1<br />

810 XBY(X)=RW<br />

820 XBY(A)=D<br />

830 XBY(X)=E+1:XBY(X)=E<br />

840 RETURN<br />

890 REM write an instruction to the display<br />

900 XBY(X)=RS<br />

910 XBY(A)=I<br />

920 XBY(X)=E+1:XBY(X)=E<br />

930 RETURN<br />

<strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong> 149

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!