Chapter 9 – Digital Meets Analog – ADC and DAC
. When a table entry is found that is less
esult we break and i equals the temperature
in Fahrenheit. Pretty clever, huh? Wish I thought of it,
d it from the WinAVR version of the Butterfly
quit owning up to all this theft and from now on
if you see something clever (the good kind of clever) just
I stole it. */
1; i++)
ord(&TEMP_Fahrenheit_pos[i]))
}
/* Next we convert the integer ADCresult to a string that
rom the
ur file.
use the itoa() function, which converts and
ASCII character array terminated with '\0'.
0);
e temperature to the PC
("The temperature is ");
Fahrenheit.\r");
know where the “@#%#&*#!!!!” comes
0','0','0','\0'};
','0','0','\0'};
as in the table
than the ADC r
but I borrowe
code. I'll
assume that
for (i=0; i<=14
{
if (ADCresult > pgm_read_w
{
break;
}
we can transmit to the PC. Let’s use a function f
standard library. We add #include <stdlib.h> to o
Then we can
integer to an
*/
itoa(i, fahr, 1
// Send th
sendString
sendString(fahr);
sendString(" degrees
}
The @#%#&*#!!!! Volt Meter
If you read the debugging tale, you
from.
void getVolt()
{
char voltintpart[]= {'
char voltfractpart[]= {' 0
int intpart = 0;
int fractpart = 0;
int ADCresult = 0;