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.

Chapter 9<br />

Figure 9-6. <strong>The</strong> LM34 and LM35 temperature sensors have outputs of 10<br />

millivolts per degree, and need no calibration.<br />

Listing 9-3. Measures and displays temperature reading at ADC0848’s<br />

Channel 2.<br />

10 REM set A to address of ADC<br />

20 A=0C000H<br />

30 REM use single-ended mode<br />

40 REM set C to channel to read (1-8)<br />

50 C=2<br />

60 XBY(A)=8+C-1<br />

70 VREF=2.5<br />

80 B=XBY(A)<br />

90 T=INT(VREF*B*100/255+.5)<br />

100 PRINT “Temperature = ”,T<br />

110 PRINT “Press any key to take another measurement”<br />

120 D=GET : IF D=0 THEN GOTO 120<br />

130 GOTO 60<br />

140 END<br />

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

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

Saved successfully!

Ooh no, something went wrong!