/* Temperature proof of concept. Using a LM35 and Arduino to read Temp to LCD. Eventual use for weather station and/or home automation routines. Need to redesign to eliminate useage of delay() Author: Brutus */ #define ledPin 13 // LED connected to digital pin 13 #define lm35 0 // LM35 on Analog 0 //Defines will use less memory. Not as crucial here, but future sketches. void sendlcd(byte command) //Quick function to send LCD commands. { Serial.print(command, BYTE); } void setup() // run once, when the sketch starts { analogReference(INTERNAL); pinMode(ledPin, OUTPUT); // sets the digital pin as output pinMode(lm35, INPUT); digitalWrite(ledPin, HIGH); digitalWrite(lm35, LOW); delay(1000); Serial.begin(9600); delay(1000); //Let Ports Stabilize //Reset Command For LCD sendlcd(27); sendlcd(122); delay(500); //Full Reset takes a bit //Backlight Command For LCD sendlcd(27); sendlcd(42); sendlcd(75); delay(50); //Clear and Go Home on LCD sendlcd(254); sendlcd(1); digitalWrite(ledPin, LOW); delay(250); } void loop() // run over and over again { long temp; long temp1; long temp2; long temp_x; int lm35_val=0; digitalWrite(ledPin,HIGH); delay(500); //After digital write, delay to allow stabilized analog read lm35_val=analogRead(lm35); //temp = ((long)lm35_val*1100/1024); // Above changed.. using internal ref the read value seems closer to the truth temp = lm35_val; temp1=temp/10; temp2=temp%10; if (temp2 >= 5) { temp_x++; } //Clear LCD Screen sendlcd(254); sendlcd(1); //Print Obligitory Message Serial.println("brutusweb.com"); //Print Temp Serial.print(temp1); Serial.print("."); Serial.print(temp2); sendlcd(223); Serial.print("C"); digitalWrite(ledPin,LOW); delay(9500); }