Hi TrainMen:
Zu 1:
Die Grenzwerte 143 und 471 entsprechen 0,7 bzw. 2,3ms. Das ist die Spezifikation, die die meisten Servos einhalten.
Wenn du ein Servo hast, das nur einen Impuls am linken Anschlag von 0,44ms braucht, dann kannst du natürlich auch 90 nehmen.
Zu 2:
Ich habe mit meinem Sensor eine Tabelle (ADC-Werte <-> Entfernung) angelegt und die in Excel eingetragen. Excel hat mir dann die Formel errechnet.
Zu 3:
tint, cbat, vbat sind ja keine Integer-Variablen, sondern double.
Eine Ausgabefunktion für das LCD:
Code:
/**
* Write a floating point number to the LCD.
*
* Example:
*
* // Write a floating point number to the LCD (no exponent):
* writeDoubleLCD(1234567.890, 11, 3);
*
* The value of prec (precision) defines the number of decimal places.
* For 32 bit floating point variables (float, double ...) 6 is
* the max. value for prec (7 relevant digits).
* The value of width defines the overall number of characters in the
* floating point number including the decimal point. The number of
* pre-decimal positions is: (width - prec - 1).
*/
void writeDoubleLCD(double number, uint8_t width, uint8_t prec)
{char buffer[width + 1];
dtostrf(number, width, prec, &buffer[0]);
writeStringLCD(&buffer[0]);
}
Viel Erfolg!
Lesezeichen