pull/11/head
Sergio Pernas 12 months ago
parent b3617f831a
commit c3de7cecb2

@ -7,25 +7,25 @@ int inQuery;
double getData() {
int getData() {
int sensorValue = analogRead(A2);
return (sensorValue * (5.0 / 1024.0));
return (map(sensorValue, 0, 700, 100, 0));
}
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.write("\n");
delay(1000);
if ( Serial.available() > 0) {
inQuery = Serial.read();
if ( inQuery == devID) {
Serial.write(itoa(devID, devIDstr, 10));
@ -33,9 +33,10 @@ void loop() {
Serial.write("Tur");
Serial.write(" ");
char lecturaStr[6]; // Buffer big enough for 7-character float
dtostrf(getData(), 2, 4, lecturaStr); // Leave room for too large numbers!
//char lecturaStr[6]; // Buffer big enough for 7-character float
//dtostrf(getData(), 2, 4, lecturaStr); // Leave room for too large numbers!
char lecturaStr[5]; // Buffer big enough for 7-character float
dtostrf(getData(), 3, 2, lecturaStr); // Leave room for too large numbers!
Serial.write(lecturaStr);
Serial.write(" ");
@ -43,7 +44,6 @@ void loop() {
Serial.write(" ");
Serial.write("99");
}
}

Loading…
Cancel
Save