SensorTouch now is really funny^^
Code: Select all
SensorValue SensorMSPressure SensorMSPressureRaw Matt's PSI
0 1 995 6.7
0 3 943 9.3
0 6 869 12.2
0 9 790 15.5
0 12 723 18.9
0 15 646 22.0
0 18 568 25.2
_1000 (limit) 21 482 29.2
Code: Select all
/************************************************************************/
#define printf1( _x, _y, _format1, _value1) { \
string sval1 = FormatNum(_format1, _value1); \
TextOut(_x, _y, sval1); \
}
float ScaleRange(float Value, float ValueMin, float ValueMax, float DesiredMin, float DesiredMax)
{
return (DesiredMax - DesiredMin) * (Value - ValueMin) / (ValueMax - ValueMin) + DesiredMin;
}
float PPS35_PSI (byte port){
return ScaleRange(SensorRaw(port), 400, 1000, 32.7, 6.7);
}
task main()
{
string msg;
int v,w,r, hPa;
float PSI, f;
//SetSensorType(S1, SENSOR_TYPE_LIGHT);
SetSensorTouch(S1);
while (true) {
msg = "Attach PPS35-Nx ";
TextOut(0, LCD_LINE1, msg, false);
//***************************************************************
v = SensorValue(S1);
w = SensorMSPressure(S1);
r = SensorRaw(S1);
f = PPS35_PSI (S1);
hPa = w * 68.95;
PSI = (0.043 * SensorRaw(S1)) - 38;
if (hPa < 1200) OnFwd(OUT_A,100); // air pressure pump
else Off(OUT_A);
//***************************************************************
printf1(0,40, "RAW=%5d", v);
printf1(0,32, "MSP=%5d", w);
printf1(0,24, "MSR=%5d", r);
printf1(0,16, "MSF=%5.1f", f);
printf1(0,08, "PSI=%5.1f", PSI);
Wait (200);
}
}