Pages: [1]   Go Down
Author Topic: temperature.. please answer  (Read 123 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what code can i use to check the temperature every 5 sec with lm35 ?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8821
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
const unsigned long interval = 5000;           // Interval between samples, in milliseconds

void setup() {   
}

void loop() {
    static unsigned long previousMillis = 0;
    unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval)  {
     previousMillis = currentMillis;
     // The code in this block is executed every 'interval' milliseconds

  }
}
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 216
Posts: 13663
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Great  that is "temperature reading without delay()"  smiley
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: