arduino bt help


hello, everyone. new forum , arduino. looking guidance , newbie all. have arduino bt board , 2xlm national temperature sensors read designed read in fahrenheit. have example code arduino have uploaded , able stream data, data getting wrong. correct program print in f , time stamp each reading. thank in advance. post program in separate post.

// define analog input pin have connected temperature sensor
#define temp_sensor_pin 0

// if tie arduino's vref 3.3 volt supply, change 3.3
#define analog_votlage_reference 5

void setup() {
serial.begin(115200);
}

void loop() {
// prints currrent temperature 1 place after decimal point
printfloat(gettemperature(), 1);
// print carriage return
serial.println();
// rest 100 milliseconds
delay(100);
}

float ctof(float c) {
// optionally convert celsius farenheit if sorta thing
return c * 9.0 / 5.0 + 32.0;
}

float analogintodegreesc(int inputvalue) {
// divide 1023, maximum possible input value, scales input between 0 - 1
// multiply reference voltage, scales 0-1 0-vref (default 5v)
// lastly, multiply 100 scale 10s of millivolts or degrees
return inputvalue / 1023.0 * analog_votlage_reference * 100.0;
}
float gettemperature() {
// read analog input, convert degrees c, , covert f
return ctof(analogintodegreesc(analogread(temp_sensor_pin)));
}

// ---- last function, printfloat isn't necessary understand unless want to
// ---- feel free ignore now, , treat built-in utility,
// ---- prints out floating point point values

// printfloat prints out float 'value' rounded 'places' places after decimal point
void printfloat(float value, int places) {
// used cast digits
int digit;
float tens = 0.1;
int tenscount = 0;
int i;
float tempfloat = value;

// make sure round properly. use pow <math.h>, doesn't seem worth import
// if rounding step isn't here, value 54.321 prints 54.3209

// calculate rounding term d: 0.5/pow(10,places)
float d = 0.5;
if (value < 0)
d *= -1.0;
// divide ten each decimal place
for (i = 0; < places; i++)
d/= 10.0;
// small addition, combined truncation round our values properly
tempfloat += d;

// first value tens large power of ten less value
// tenscount isn't necessary useful if wanted know after how many chars number take


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > arduino bt help


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums