Ardunio Mega and GLCD reading Dallas One Wire

First post and Ardunio project.
I used the KS0108 Lib and the DallasTempature Library for this project. Sorry but no pictures I am camera poor at the moment.

I did this same project with a PIC a year ago and wanted to compare.
I give this round to the Ardunio, alot less code and cussing. :slight_smile:

Still a work in progress, but here it is

/*
 * GLCD And Dallas One Wire Sketch for Ardunio Mega
 *
 * Test code for the Arduino KS0108 GLCD library and Dallas One Wire Libaray.
 * Very simple code to display the ouput of 2 DS18S20 sensors
 * My plan is to expand the code to allow for an unknown # of sensors and graph the average.
 * Ted Crafton 17-07-2010
 *  Fell free to use as you see fit. I borrowed code from the examples in the Libraries 
 */

#include <ArduinoIcon.h>
#include <Arial14.h>
#include <ks0108.h>
#include <ks0108_Arduino.h>
#include <ks0108_Mega.h>
#include <ks0108_Panel.h>
#include <ks0108_Sanguino.h>
#include <SystemFont5x7.h>
#include <DallasTemperature.h>
#include <OneWire.h>

// Data wire is plugged into port 42 on the Mega, if you use a different one change it here.
#define ONE_WIRE_BUS 42

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

unsigned int iSensor = 0;
unsigned int icount = 0;

void setup(){
 
  iSensor = 0;
  GLCD.Init(NON_INVERTED);   // initialise the library, non inverted writes pixels onto a clear screen
  GLCD.ClearScreen();  
  GLCD.DrawBitmap(ArduinoIcon, 32,0, BLACK); //draw the bitmap at the given x,y position
  GLCD.SelectFont(System5x7); // switch to fixed width system font 
  countdown(5); 
  GLCD.ClearScreen();
  Serial.begin(9600);
  //Start up the Dallas Lib
  sensors.begin();
  
  iSensor =  sensors.getDeviceCount(); //Get a count of the number of sensors on the wire
 
}

void countdown(int count){
    while(count--){  // do countdown  
     GLCD.CursorTo(0,1);   // first column, second row (offset is from 0)
     GLCD.PutChar(count + '0');
     delay(1000);  
  }  
}

void  loop(){   // run over and over again
  icount = 0;
  //Send a request to get the Temps on all Sensors
  sensors.requestTemperatures(); // Send the command to get temperatures
  
 
 
  GLCD.ClearScreen();               // clear the screen  
  for(icount = 0; icount < iSensor; icount++){
    GLCD.CursorTo(0,icount + 1);              // positon cursor  
    GLCD.Puts("Temperture= ");
     GLCD.PrintNumber(sensors.getTempFByIndex(icount));
  delay(2000);
  }
}

I wanted to be able to hook up a number DS18S20s to a bus and have the tempature read and then dispaly them on the GLCD. I could have done it with an LCD, but I plan on graphing it so GLCD. I decided to use a number of sensors to get an average Tempature. I have 4 sensors and they have a spread of +/- 5 degrees.

I found the forum here to be very helpful, if a little messy.

Hey the smoke stayed in so I must be on the right track.