element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino Projects
  • Products
  • Arduino
  • Arduino Projects
  • More
  • Cancel
Arduino Projects
Blog Arduino Starter Kit - Love Meter with faster Reset
  • Blog
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino Projects to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: gam3t3ch
  • Date Created: 11 Jan 2018 1:34 AM Date Created
  • Views 1890 views
  • Likes 4 likes
  • Comments 3 comments
  • ardbeginner
  • arduino_starter_kit_projects
  • arduino_classic
  • arduino
Related
Recommended

Arduino Starter Kit - Love Meter with faster Reset

gam3t3ch
gam3t3ch
11 Jan 2018


So I was trying to figure out a decent way to speed up the time it took to reset I ended up taking another instance of the low being +2
and then adding the first high-low-low as being 2.25 degrees I have added a few video's so you can see the results I am by far no means
any good when it comes to messing with the arduino besides using other people code but since I got that kit let me tell you its be a great
adventure in the arduino land.image


//LOVE METER WITH FASTER RESET.
const int sensorPin = A0;const float baselineTemp = 22.0;
void setup(){   Serial.begin(9600);
  for(int pinNumber = 2; pinNumber<5; pinNumber++){    
pinMode(pinNumber,OUTPUT);   
digitalWrite(pinNumber, LOW); 
}
}
void
loop(){ 
int sensorVal = analogRead(sensorPin);  
Serial.print("Sensor Value: ");  
Serial
.print(sensorVal);  
float voltage = (sensorVal/1024.0) * 5.0;  
Serial
.print(", Volts: ");  
Serial
.print(voltage); 
Serial.print(", degrees C: "); 
float temperature = (voltage - .5) * 100;  
Serial
.println(temperature);    
if
(temperature < baselineTemp){    
digitalWrite
(2, LOW);    
digitalWrite
(3, LOW);    
digitalWrite
(4, LOW); 
}  
else
if(temperature >= baselineTemp+2.25 && temperature < baselineTemp+4){    
digitalWrite(2, HIGH);    
digitalWrite
(3, LOW);    
digitalWrite(4, LOW);   }  
else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6){    
digitalWrite
(2, HIGH);    
digitalWrite
(3, HIGH);    
digitalWrite(4, LOW);   }  
else
if(temperature >= baselineTemp+6){    
digitalWrite(2, HIGH);    
digitalWrite
(3, HIGH);     digitalWrite(4, HIGH);  
}  
else if(temperature >= baselineTemp+2){    
digitalWrite(2, LOW);    
digitalWrite
(3, LOW);    
digitalWrite
(4, LOW);  
}  
delay(.25);
} 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image



This code seemed to output the following for me which I didn't think to be ideal the above code tho
Produced the below video here which I felt was better.  (was a bit cooler in the room when I did this bottom one
so test didn't light up all 3 but will give you a example of the drop at the end)

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image


PLEASE POST BELOW IF THERE IS A BETTER CODE TO TRY.
Will play with this more but more info is always appreciated.
  • Sign in to reply

Top Comments

  • mcb1
    mcb1 over 7 years ago +1
    They are addictive aren't they. //LOVE METER WITH FASTER RESET. const int sensorPin = A0;const float baselineTemp = 22.0; void setup(){ Serial.begin(9600); for(int pinNumber = 2; pinNumber<5; pinNumber…
  • gam3t3ch
    gam3t3ch over 7 years ago in reply to mcb1 +1
    Thanks for the info, guess I gotta go shopping now...lol
  • genebren
    genebren over 7 years ago

    It is fun to solve problems in software, but the truth here is that the problem exists in physics.  The 'reset' time has more to do with the heat that you have applied to the sensor and the time it takes for that heat to dissipate. To speed up your reset time you could use a small fan to blow ambient air across the sensor.  To do this you will need some code.  While the temperature is near ambient the fan needs to be off.  When the temperature is rising or holding the fan also needs to be off.  When the temperature is above ambient and is falling then the fan is turned on.  (Be careful to get a tiny fan that can be driven safely by the arduino and one that will no attack your fingers)

     

    Have fun, but be safe.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • gam3t3ch
    gam3t3ch over 7 years ago in reply to mcb1

    Thanks for the info, guess I gotta go shopping now...lol

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 7 years ago

    They are addictive aren't they.

     

    //LOVE METER WITH FASTER RESET.
    const int sensorPin = A0;const float baselineTemp = 22.0;
    void setup(){   Serial.begin(9600); 
      for(int pinNumber = 2; pinNumber<5; pinNumber++){     
    pinMode(pinNumber,OUTPUT);    
     digitalWrite(pinNumber, LOW);  
     }
    } 
    void loop(){  
     int sensorVal = analogRead(sensorPin);   
    Serial.print("Sensor Value: ");   
    Serial.print(sensorVal);   
    float voltage = (sensorVal/1024.0) * 5.0;   
    Serial.print(", Volts: ");   
    Serial.print(voltage);  
    Serial.print(", degrees C: ");  
    float temperature = (voltage - .5) * 100;   
    Serial.println(temperature);     
    if(temperature < baselineTemp){     
    digitalWrite(2, LOW);     
    digitalWrite(3, LOW);     
    digitalWrite(4, LOW);  
     }   
    else if(temperature >= baselineTemp+2.25 && temperature < baselineTemp+4){     
    digitalWrite(2, HIGH);     
    digitalWrite(3, LOW);     
    digitalWrite(4, LOW);   }   
    else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6){     
    digitalWrite(2, HIGH);     
    digitalWrite(3, HIGH);     
    digitalWrite(4, LOW);   }   
    else if(temperature >= baselineTemp+6){     
    digitalWrite(2, HIGH);     
    digitalWrite(3, HIGH);     digitalWrite(4, HIGH);   
    }   
    else if(temperature >= baselineTemp+2){     
    digitalWrite(2, LOW);     
    digitalWrite(3, LOW);     
    digitalWrite(4, LOW);   
    }   
    delay(.25); 
    }

     

    In your elseif statements, you are basically driving

    Pin 2 = + 2.25 deg

    Pin 3 = +4

    Pin 4 =+ 6

     

    You could seperate these into an if statement to just control that Pin based on the baseline +xx.

    eg High is it's above or low if it isn't.

     

    You could also do some averaging for achieving the baseline temperature, rather than the fixed 22 degs.

    You could read the temperature 5 or 10 times during the setup and then average it.

     

    I can see that you're wanting to work out the actual temperature from the ADC value.

    Correct me if my algebra is wrong, but I thought voltage = sensorVal * 5/1024, based on the fullscale ADC is 1024 which represents 5 volts (default value)

     

    Good example and explanantion is here.

    https://learn.adafruit.com/tmp36-temperature-sensor/using-a-temp-sensor

     

     

    There is another very useful command called Map, that allows translation from one set of values into a range.

     

     

    Personally I use the DS18B20's for temperature measurement ...

    I'd add a couple of the waterproof versions on your next buying trip.

     

    Mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube