Upload
aditya-jabar
View
215
Download
0
Embed Size (px)
Citation preview
7/26/2019 TempMon333.Doc
1/1
/*
* AnalogInput
* by DojoDave
*
* Modified for raduate !tudent "or#$hop
* by David %oger$on & 'hy$i($ )le(troni($ %e$our(e enter+ ,niver$ity of -oro
nto
*
* -urn$ on and off a light eitting diode)D1 (onne(ted to digital
* pin 20. -he aount of tie the )D will be on and off depend$ on
* the value obtained by analog%ead1. In thi$ in$tan(e we are u$ing a M34
* teperature $en$or
*
*/
inttep'in 5 06 // $ele(t the input pin for the analog input
intled'in 5 206 // $ele(t the pin for the )D
floatval 5 06 // variable to $tore the value (oing fro the $en$or
floattep 5 06 // hold$ the (al(ulated (el$iu$ value for di$play
void$etup1 7 pinModeled'in+ 8,-',-16 // de(lare the led pin a$ an 8,-',-
!erial.begin90016
;
voidloop1 7
val 5 analog%eadtep'in16 // read the value fro the $en$or
digital"riteled'in+ I16 // turn the led pin on
delayval16 // $top the progra for $oe tie
digital"riteled'in+ 8"16 // turn the led pin off
delayval16 // $top the progra for $oe tie
/*
* =ull $(ale tep 2031 i$ ?0 degree$ and botto $(ale 01 i$ 20 degree$
* el$iu$ value i$ then the tep range 301 tie$ the a/d value divided
* by the full $(ale a/d value plu$ 20 degree$ a/d @ero value1
*/
tep 5 30 * val / 203 206 // onvert the reading to el$iu$ value
!erial.println BA/D val C -ep in B16 // 'rint the reading and the
el$iu$ value
!erial.println val+ 0 16 // 'rint the a/d val a$ an integer
!erial.println tep+ 2 16 // print the (el$iu$ value to 2
de(ial pt
!erial.printlnBB16
;
http://www.0j0.org/http://www.0j0.org/