Go Down

Topic: sparkfun serial lcd help pleasee !!!!!!!!!!!!!!! (Read 534 times) previous topic - next topic

Jan 07, 2013, 10:51 am Last Edit: Jan 07, 2013, 01:01 pm by supermotolew Reason: 1
sorry all again  ! im really over my head with this !! soo please help ! so my sparkfun serial lcd arrived today for my thermometer project my sketch wich i will post below works correctly to display temperature in serial monitor and when i first connected the lcd displayed on the LCD like this

19.76IIII19.78IIII19.45IIII
III18.99IIII19.45IIII20.0III


what im trying to acheive is a normal refreshing reading like you would expect to see like this

19.76°C      

my sketch as follows


#include <OneWire.h>

int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2

//Temperature chip i/o
OneWire ds(DS18S20_Pin);  // on digital pin 2

void setup(void) {
 Serial.begin(9600);
}

void loop(void) {
 float temperature = getTemp();
 Serial.println(temperature);
 
 delay(2000); // delay between output
 
}


float getTemp(){
 //returns the temperature from main DS18S20 in DEG Celsius!

 byte data[12];
 byte addr[8];

 if ( !ds.search(addr)) {
     //no more sensors on chain, reset search
     ds.reset_search();
     return -1000;
 }

 if ( OneWire::crc8( addr, 7) != addr[7]) {
     Serial.println("Sensor not valid see lewis!");
     return -1000;
 }

 if ( addr[0] != 0x10 && addr[0] != 0x28) {
     Serial.print("Device is not recognized");
     return -1000;
 }

 ds.reset();
 ds.select(addr);
 ds.write(0x44,1); // start conversion, with parasite power on at the end

 byte present = ds.reset();
 ds.select(addr);    
 ds.write(0xBE); // Read Scratchpad

 
 for (int i = 0; i < 9; i++) { // need 9 bytes
   data = ds.read();
 }
 
 ds.reset_search();
 
 byte MSB = data[1];
 byte LSB = data[0];

 float tempRead = ((MSB << 8) | LSB); //using two's compliment
 float TemperatureSum = tempRead / 16;
 
 return TemperatureSum;
 
}

               

johnwasser

Perhaps this article will help:

http://playground.arduino.cc/Learning/SparkFunSerLCD

It shows how to send commands to position the cursor and clear the screen.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy