Shop OBEX P1 Docs P2 Docs Learn Events
A/D converter on Activity board — Parallax Forums

A/D converter on Activity board

Howdy!
I run the code on the bottom and it seems to give accurate values when I connect to the 3.3V and 5V pins, however, if I connect to an LM34 (temperature sensor) it doesn't seem to give an accurate value, it jumps between 1 and 2 volts all over the place, what could be wrong, I have 2 Activity boards and both do the same...



/*
Measure Volts.c

Make voltmeter-style measurements with the Propeller Activity Board.
*/

#include "simpletools.h" // Include simpletools
#include "adcDCpropab.h" // Include adcDCpropab

int main() // main function
{
adc_init(21, 20, 19, 18); // CS=21, SCL=20, DO=19, DI=18

float v2, v3; // Voltage variables

while(1) // Loop repeats indefinitely
{
v2 = adc_volts(2); // Check A/D 2
v3 = adc_volts(3); // Check A/D 3

putChar(HOME); // Cursor -> top-left "home"
print("A/D2 = %f V%c\n", v2, CLREOL); // Display volts
print("A/D3 = %f V%c\n", v3, CLREOL); // Display volts

pause(100); // Wait 1/10 s
}
}

Comments

Sign In or Register to comment.