Pages: [1]   Go Down
Author Topic: sparkfun serial lcd help pleasee !!!!!!!!!!!!!!!  (Read 460 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 << smiley-cool | LSB); //using two's compliment
  float TemperatureSum = tempRead / 16;
  
  return TemperatureSum;
  
}

                
« Last Edit: January 07, 2013, 07:01:00 am by supermotolew » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

Pages: [1]   Go Up
Jump to: