Hi there, I'm very new to programming and the Arduino, but so far, it's been great. But I've hit a snag. I'm creating a coaster that has two pressure sensors to weigh how much coffee is in a mug I place on top of it and a thermistor to determine how hot this coffee is. When all is done, I'll create some LED outputs to show when the coffee is getting too cold and the cup needs to be refilled. Fun!
My problem, I want to write the code so that when then coffee is lifted off the coaster, the program will pause the thermistor readings until the cup has been put back down. Even though I'm sure it's pretty simple, I just don't have the programming chops to figure out how to do it. Can anybody help? And if you have any ideas that could improve my coaster interaction, I'm very open to suggestions.
Here are the ranges I've gotten off my sensors:
Pressure sensor:
No Cup: 75
Empty Cup: 400
Full Cup: 550
Thermistor sensor:
No Cup: 90
Full Hot: 140
Half Full Medium: 110
Low Luke Warm: 105
Let me know if you'd like me to post my code. Thanks again!
-Jim
What do you mean by "the program will pause the thermistor readings" ?
Hold temp display at last valid reading?
Blank the temp display?
Lefty
It will hold the thermistor at the last value reading, and then continue once the mug has been put back onto the coaster.
Thanks for the help!
-Jim
Well it seems pretty straight forward. In pseudo code:
Loop:
read pressure_value
display pressure_value
read temp_value
if pressure_value > 75 then display temp_value
back to Loop
That make sense?
Lefty
Hi Lefty, it does sound easy and commonsensical to me, but for some bizarro reason, I'm having trouble conceiving the actual code for it. I've put the code I have below. The pressure sensors (forceValue1 and 2) are in analog pins 0 and 1, and I've set a variable, totalForceValue, which is:
totalForceValue = (forceValue1+forceValue2)/2.
I really appreciate all of your help. I think it's so easy that I'm overthinking it.
void loop() {
forceValue1 = analogRead(forcePin1);
forceValue2 = analogRead(forcePin2);
totalForceValue = (forceValue1+forceValue2)/2;
totalForceValue = constrain(totalForceValue,0,550);
Serial.println(totalForceValue);
thermValue = analogRead(thermPin);
thermValue = constrain(thermValue,90,140);
Serial.println(thermValue);
read pressure_value
display pressure_value
read temp_value
if pressure_value > 75 then display temp_value
//new, piping hot cup of coffee
else if(totalForceValue == 500 && thermValue == 140)
{
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
}
else if(totalForceValue >= 400 && thermvValue >= 130 && thermValue < 140)
{
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
}
else if(totalForceValue >= 400 & thermValue >= 116 && thermValue < 130)
{
digitalWrite(led3,HIGH);
}
When I stated my suggestion was in 'pseudo code' that meant it was not official C code statements, but rather just English logic steps to be taken. You seem to be missing the setup portion but I assume it's in your real sketch. Try these changes:
void loop() {
forceValue1 = analogRead(forcePin1);
forceValue2 = analogRead(forcePin2);
totalForceValue = (forceValue1+forceValue2)/2;
totalForceValue = constrain(totalForceValue,0,550);
Serial.println(totalForceValue);
thermValue = analogRead(thermPin);
thermValue = constrain(thermValue,90,140);
if(totalForceValue > 75)
{
Serial.println(thermValue);
}
//new, piping hot cup of coffee
if(totalForceValue == 500 && thermValue == 140)
{
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
}
if(totalForceValue >= 400 && thermvValue >= 130 && thermValue < 140)
{
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
}
if(totalForceValue >= 400 & thermValue >= 116 && thermValue < 130)
{
digitalWrite(led3,HIGH);
}
Thanks, Lefty. Absurdly simple, but I appreciate you taking the time to walk me through it.
Absurdly simple, but I appreciate you taking the time to walk me through it.
Your welcome, and simple is about all I can deliver when it comes to software advice/solutions 
Lefty