Need to find DMD with temp only

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
vrooms23
Posts:38
Joined:Sun Jun 30, 2013 9:23 am
Re: Need to find DMD with temp only

Post by vrooms23 » Mon Aug 05, 2013 1:49 pm

temp_dmd_try2.ino: In function 'void loop()':
temp_dmd_try2:492: error: expected primary-expression before '.' token

vrooms23
Posts:38
Joined:Sun Jun 30, 2013 9:23 am

Re: Need to find DMD with temp only

Post by vrooms23 » Mon Aug 05, 2013 1:52 pm

Code: Select all

float t; // holds temperature value
String finalString; // used to hold final sentence to display on DMD
//-----------------------------------
#include <OneWire.h>
#include <DallasTemperature.h>
//-----------------------------------

// for Freetronics DMD
#include <SPI.h>      
#include <DMD.h>      
#include <TimerOne.h> 
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#define DISPLAYS_ACROSS 1 // you could have more than one DMD in a row
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);

//--------------------------------------

#define ONE_WIRE_BUS 2     //-(Connect to Pin 2 )
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

//--------------------------------------


void ScanDMD() // required for DMD
{ 
  dmd.scanDisplayBySPI();
}

int round5(float n)
{
  float a;
  int b;
  a = ((n/0.50)+0.5);
  b = int (a);
  b = b * 0.50;
  return b;
}

void drawText(String oldString) 
{
  //Clear the panel
  dmd.clearScreen(true);
  //Select font
  //dmd.selectFont(System5x7);
  dmd.selectFont(Arial_Black_16);
  char newString[256];
  int sLength = oldString.length();
  oldString.toCharArray(newString, sLength+1);
  dmd.drawMarquee(newString,sLength,(32*DISPLAYS_ACROSS)-1,0);
  long start=millis();
  long timer=start;
  long timer2=start;
  boolean ret=false;
  while(!ret){
    if ((timer+25) < millis()) {  //Select speed
      ret=dmd.stepMarquee(-1,0);
      timer=millis();
    }
  }
}

void createTextTemp()
// this mashes up all the temprature data into text 
{
  Serial.println("createTextTime()"); // for debug

  finalString=" "; // wipe the sentence out for special cases (below)
  finalString=finalString+"It's ";

  // add the list of numbers from -10.50 to 55.50
  if (t<=-10.50) { 
    finalString=finalString+"COLD "; 
  } 
  if (t==-10.00) { 
    finalString=finalString+"-10 "; 
  } 
  if (t==-9.50) { 
    finalString=finalString+"-9.5 "; 
  } 
  if (t==-9.00) { 
    finalString=finalString+"-9.0 "; 
  } 
  if (t==-8.50) { 
    finalString=finalString+"-8.5 "; 
  } 
  if (t==-8.00) { 
    finalString=finalString+"-8 "; 
  } 
  if (t==-7.50) { 
    finalString=finalString+"-7.5 "; 
  } 
  if (t==-7.00) { 
    finalString=finalString+"-7 "; 
  } 
  if (t==-6.50) { 
    finalString=finalString+"-6.5 "; 
  } 
  if (t==-6.00) { 
    finalString=finalString+"-6 "; 
  } 
  if (t==-5.50) { 
    finalString=finalString+"-5.5 "; 
  } 
  if (t==-4.50) { 
    finalString=finalString+"-4.5 "; 
  } 
  if (t==-4.00) { 
    finalString=finalString+"-4 "; 
  } 
  if (t==-3.50) { 
    finalString=finalString+"-3.5 "; 
  } 
  if (t==-3.00) { 
    finalString=finalString+"-3 "; 
  } 
  if (t==-2.50) { 
    finalString=finalString+"-2.5 "; 
  } 
  if (t==-2.00) { 
    finalString=finalString+"-2 "; 
  } 
  if (t==-1.50) { 
    finalString=finalString+"-1.5 "; 
  } 
  if (t==-1.00) { 
    finalString=finalString+"-1 "; 
  } 
  if (t==0.00) { 
    finalString=finalString+"0 "; 
  } 
  if (t==0.50) { 
    finalString=finalString+"0.5 "; 
  } 
  if (t==1.00) { 
    finalString=finalString+"1 "; 
  } 
  if (t==1.50) { 
    finalString=finalString+"1.5 "; 
  } 
  if (t==2.00) { 
    finalString=finalString+"2 "; 
  } 
  if (t==2.50) { 
    finalString=finalString+"2.5 "; 
  } 
  if (t==3.00) { 
    finalString=finalString+"3 "; 
  } 
  if (t==3.50) { 
    finalString=finalString+"3.5 "; 
  } 
  if (t==4.00) { 
    finalString=finalString+"4 "; 
  } 
  if (t==4.50) { 
    finalString=finalString+"4.5 "; 
  } 
  if (t==5.00) { 
    finalString=finalString+"5 "; 
  } 
  if (t==5.50) { 
    finalString=finalString+"5.5 "; 
  } 
  if (t==6.00) { 
    finalString=finalString+"6 "; 
  } 
  if (t==6.50) { 
    finalString=finalString+"6.5 "; 
  } 
  if (t==7.00) { 
    finalString=finalString+"7 "; 
  } 
  if (t==7.50) { 
    finalString=finalString+"7.5 "; 
  } 
  if (t==8.00) { 
    finalString=finalString+"8 "; 
  } 
  if (t==8.50) { 
    finalString=finalString+"8.5 "; 
  } 
  if (t==9.00) { 
    finalString=finalString+"9 "; 
  } 
  if (t==9.50) { 
    finalString=finalString+"9.5 "; 
  } 
  if (t==10.00) { 
    finalString=finalString+"10 "; 
  } 
  if (t==10.50) { 
    finalString=finalString+"10.5 "; 
  } 
  if (t==11.00) { 
    finalString=finalString+"11 "; 
  } 
  if (t==11.50) { 
    finalString=finalString+"11.5 "; 
  } 
  if (t==12.00) { 
    finalString=finalString+"12 "; 
  } 
  if (t==12.50) { 
    finalString=finalString+"12.5 "; 
  } 
  if (t==13.00) { 
    finalString=finalString+"13 "; 
  } 
  if (t==13.50) { 
    finalString=finalString+"13.5 "; 
  } 
  if (t==14.00) { 
    finalString=finalString+"14 "; 
  } 
  if (t==14.50) { 
    finalString=finalString+"14.5 "; 
  } 
  if (t==15.00) { 
    finalString=finalString+"15 "; 
  } 
  if (t==15.50) { 
    finalString=finalString+"15.5 "; 
  } 
  if (t==16.00) { 
    finalString=finalString+"16 "; 
  } 
  if (t==16.50) { 
    finalString=finalString+"16.5 "; 
  } 
  if (t==17.00) { 
    finalString=finalString+"17 "; 
  } 
  if (t==17.50) { 
    finalString=finalString+"17.5 "; 
  } 
  if (t==18.00) { 
    finalString=finalString+"18 "; 
  } 
  if (t==18.50) { 
    finalString=finalString+"18.5 "; 
  } 
  if (t==19.00) { 
    finalString=finalString+"19 "; 
  } 
  if (t==19.50) { 
    finalString=finalString+"19.5 "; 
  } 
  if (t==20.00) { 
    finalString=finalString+"20 "; 
  } 
  if (t==20.50) { 
    finalString=finalString+"20.5 "; 
  } 
  if (t==21.00) { 
    finalString=finalString+"21 "; 
  } 
  if (t==21.50) { 
    finalString=finalString+"21.5 "; 
  } 
  if (t==22.00) { 
    finalString=finalString+"22 "; 
  }

  if (t==22.50) { 
    finalString=finalString+"22.5 "; 
  } 
  if (t==23.00) { 
    finalString=finalString+"23 "; 
  } 
  if (t==23.50) { 
    finalString=finalString+"23.5 "; 
  } 
  if (t==24.00) { 
    finalString=finalString+"24 "; 
  } 
  if (t==24.50) { 
    finalString=finalString+"24.5 "; 
  } 
  if (t==25.00) { 
    finalString=finalString+"25 "; 
  } 
  if (t==25.50) { 
    finalString=finalString+"25.5 "; 
  } 
  if (t==26.00) { 
    finalString=finalString+"26 "; 
  } 
  if (t==26.50) { 
    finalString=finalString+"26.5 "; 
  } 
  if (t==27.00) { 
    finalString=finalString+"27 "; 
  } 
  if (t==27.50) { 
    finalString=finalString+"27.5 "; 
  } 
  if (t==28.00) { 
    finalString=finalString+"28 "; 
  } 
  if (t==28.50) { 
    finalString=finalString+"28.5 "; 
  } 
  if (t==29.00) { 
    finalString=finalString+"29 "; 
  } 
  if (t==29.50) { 
    finalString=finalString+"29.5 "; 
  } 
  if (t==30.00) { 
    finalString=finalString+"30 "; 
  } 
  if (t==30.50) { 
    finalString=finalString+"30.5 "; 
  } 
  if (t==31.00) { 
    finalString=finalString+"31 "; 
  } 
  if (t==31.50) { 
    finalString=finalString+"31.5 "; 
  } 
  if (t==32.00) { 
    finalString=finalString+"32 "; 
  } 
  if (t==32.50) { 
    finalString=finalString+"32.5 "; 
  } 
  if (t==33.00) { 
    finalString=finalString+"33 "; 
  } 
  if (t==33.50) { 
    finalString=finalString+"33.5 "; 
  } 
  if (t==34.00) { 
    finalString=finalString+"34 "; 
  } 
  if (t==34.50) { 
    finalString=finalString+"34.5 "; 
  } 
  if (t==35.00) { 
    finalString=finalString+"35 "; 
  } 
  if (t==35.50) { 
    finalString=finalString+"35.5 "; 
  } 
  if (t==36.00) { 
    finalString=finalString+"36 "; 
  } 
  if (t==36.50) { 
    finalString=finalString+"36.5 "; 
  } 
  if (t==37.00) { 
    finalString=finalString+"37 "; 
  } 
  if (t==37.50) { 
    finalString=finalString+"37.5 "; 
  } 
  if (t==38.00) { 
    finalString=finalString+"38 "; 
  } 
  if (t==38.50) { 
    finalString=finalString+"38.5 "; 
  } 
  if (t==39.00) { 
    finalString=finalString+"39 "; 
  } 
  if (t==39.50) { 
    finalString=finalString+"39.5 "; 
  } 
  if (t==40.00) { 
    finalString=finalString+"40 "; 
  } 
  if (t==40.50) { 
    finalString=finalString+"40.5 "; 
  } 
  if (t==41.00) { 
    finalString=finalString+"41 "; 
  } 
  if (t==41.50) { 
    finalString=finalString+"41.5 "; 
  } 
  if (t==42.00) { 
    finalString=finalString+"42 "; 
  } 
  if (t==42.50) { 
    finalString=finalString+"42.5 "; 
  } 
  if (t==43.00) { 
    finalString=finalString+"43 "; 
  } 
  if (t==43.50) { 
    finalString=finalString+"43.5 "; 
  } 
  if (t==44.00) { 
    finalString=finalString+"44 "; 
  } 
  if (t==44.50) { 
    finalString=finalString+"44.5 "; 
  } 
  if (t==45.00) { 
    finalString=finalString+"45 "; 
  } 
  if (t==45.50) { 
    finalString=finalString+"45.5 "; 
  } 
  if (t==46.00) { 
    finalString=finalString+"46 "; 
  } 
  if (t==46.50) { 
    finalString=finalString+"46.5 "; 
  } 
  if (t==47.00) { 
    finalString=finalString+"47 "; 
  } 
  if (t==47.50) { 
    finalString=finalString+"47.5 "; 
  } 
  if (t==48.00) { 
    finalString=finalString+"48 "; 
  } 
  if (t==48.50) { 
    finalString=finalString+"48.5 "; 
  } 
  if (t==49.00) { 
    finalString=finalString+"49 "; 
  } 
  if (t==49.50) { 
    finalString=finalString+"49.5 "; 
  } 
  if (t==50.00) { 
    finalString=finalString+"50 "; 
  } 
  if (t==50.50) { 
    finalString=finalString+"50.5 "; 
  } 
  if (t==51.00) { 
    finalString=finalString+"51 "; 
  } 
  if (t==51.50) { 
    finalString=finalString+"51.5 "; 
  } 
  if (t==52.00) { 
    finalString=finalString+"52 "; 
  } 
  if (t==52.50) { 
    finalString=finalString+"52.5 "; 
  } 
  if (t==53.00) { 
    finalString=finalString+"53 "; 
  } 
  if (t==53.50) { 
    finalString=finalString+"53.5 "; 
  } 
  if (t==54.00) { 
    finalString=finalString+"54 "; 
  } 
  if (t==54.50) { 
    finalString=finalString+"54.5 "; 
  } 
  if (t==55.00) { 
    finalString=finalString+"55 "; 
  } 
  if (t==55.50) { 
    finalString=finalString+"55.5 "; 
  } 
  if (t>=55.50) { 
    finalString=finalString+"HOT "; 
  } 
  finalString=finalString+"*C ";
}

void setup()
{
  
  Serial.begin(9600);
  sensors.begin(); 
  //printSerialTemp();
  // for DMD
  Timer1.initialize( 5000 );
  Timer1.attachInterrupt( ScanDMD );   
  dmd.clearScreen(true);
}

void loop(void)
{
  // get the temperature and round it to nearest 5
  sensors.requestTemperatures();
  t=DallasTemperature.readTemperature(); 
  t=round5(t);

  // now create the text to display on the DMD
  createTextTemp();

  // now send the text to the DMD
  drawText(finalString);
}

User avatar
stryker
Posts:282
Joined:Sat Jan 14, 2012 2:44 pm

Re: Need to find DMD with temp only

Post by stryker » Mon Aug 05, 2013 2:29 pm

Hi
vrooms23 wrote:temp_dmd_try2.ino: In function 'void loop()':
temp_dmd_try2:492: error: expected primary-expression before '.' token
Your problem came from the function name you were using to get your temperature not being part of the Dallas library. You also still needed to declare a way of talking to your specific thermometer, so you were close. I've made a couple of minor changes and it compiles, but no guarantees...

Code: Select all

float t; // holds temperature value
String finalString; // used to hold final sentence to display on DMD
//-----------------------------------
#include <OneWire.h>
#include <DallasTemperature.h>
//-----------------------------------

// for Freetronics DMD
#include <SPI.h>      
#include <DMD.h>      
#include <TimerOne.h> 
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#define DISPLAYS_ACROSS 1 // you could have more than one DMD in a row
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);

//--------------------------------------

#define ONE_WIRE_BUS 2     //-(Connect to Pin 2 )
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress yourThermometer;

//--------------------------------------


void ScanDMD() // required for DMD
{ 
  dmd.scanDisplayBySPI();
}

int round5(float n)
{
  float a;
  int b;
  a = ((n/0.50)+0.5);
  b = int (a);
  b = b * 0.50;
  return b;
}

void drawText(String oldString) 
{
  //Clear the panel
  dmd.clearScreen(true);
  //Select font
  //dmd.selectFont(System5x7);
  dmd.selectFont(Arial_Black_16);
  char newString[256];
  int sLength = oldString.length();
  oldString.toCharArray(newString, sLength+1);
  dmd.drawMarquee(newString,sLength,(32*DISPLAYS_ACROSS)-1,0);
  long start=millis();
  long timer=start;
  long timer2=start;
  boolean ret=false;
  while(!ret){
    if ((timer+25) < millis()) {  //Select speed
      ret=dmd.stepMarquee(-1,0);
      timer=millis();
    }
  }
}

void createTextTemp()
// this mashes up all the temprature data into text 
{
  Serial.println("createTextTime()"); // for debug

  finalString=" "; // wipe the sentence out for special cases (below)
  finalString=finalString+"It's ";

  // add the list of numbers from -10.50 to 55.50
  if (t<=-10.50) { 
    finalString=finalString+"COLD "; 
  } 
  if (t==-10.00) { 
    finalString=finalString+"-10 "; 
  } 
  if (t==-9.50) { 
    finalString=finalString+"-9.5 "; 
  } 
  if (t==-9.00) { 
    finalString=finalString+"-9.0 "; 
  } 
  if (t==-8.50) { 
    finalString=finalString+"-8.5 "; 
  } 
  if (t==-8.00) { 
    finalString=finalString+"-8 "; 
  } 
  if (t==-7.50) { 
    finalString=finalString+"-7.5 "; 
  } 
  if (t==-7.00) { 
    finalString=finalString+"-7 "; 
  } 
  if (t==-6.50) { 
    finalString=finalString+"-6.5 "; 
  } 
  if (t==-6.00) { 
    finalString=finalString+"-6 "; 
  } 
  if (t==-5.50) { 
    finalString=finalString+"-5.5 "; 
  } 
  if (t==-4.50) { 
    finalString=finalString+"-4.5 "; 
  } 
  if (t==-4.00) { 
    finalString=finalString+"-4 "; 
  } 
  if (t==-3.50) { 
    finalString=finalString+"-3.5 "; 
  } 
  if (t==-3.00) { 
    finalString=finalString+"-3 "; 
  } 
  if (t==-2.50) { 
    finalString=finalString+"-2.5 "; 
  } 
  if (t==-2.00) { 
    finalString=finalString+"-2 "; 
  } 
  if (t==-1.50) { 
    finalString=finalString+"-1.5 "; 
  } 
  if (t==-1.00) { 
    finalString=finalString+"-1 "; 
  } 
  if (t==0.00) { 
    finalString=finalString+"0 "; 
  } 
  if (t==0.50) { 
    finalString=finalString+"0.5 "; 
  } 
  if (t==1.00) { 
    finalString=finalString+"1 "; 
  } 
  if (t==1.50) { 
    finalString=finalString+"1.5 "; 
  } 
  if (t==2.00) { 
    finalString=finalString+"2 "; 
  } 
  if (t==2.50) { 
    finalString=finalString+"2.5 "; 
  } 
  if (t==3.00) { 
    finalString=finalString+"3 "; 
  } 
  if (t==3.50) { 
    finalString=finalString+"3.5 "; 
  } 
  if (t==4.00) { 
    finalString=finalString+"4 "; 
  } 
  if (t==4.50) { 
    finalString=finalString+"4.5 "; 
  } 
  if (t==5.00) { 
    finalString=finalString+"5 "; 
  } 
  if (t==5.50) { 
    finalString=finalString+"5.5 "; 
  } 
  if (t==6.00) { 
    finalString=finalString+"6 "; 
  } 
  if (t==6.50) { 
    finalString=finalString+"6.5 "; 
  } 
  if (t==7.00) { 
    finalString=finalString+"7 "; 
  } 
  if (t==7.50) { 
    finalString=finalString+"7.5 "; 
  } 
  if (t==8.00) { 
    finalString=finalString+"8 "; 
  } 
  if (t==8.50) { 
    finalString=finalString+"8.5 "; 
  } 
  if (t==9.00) { 
    finalString=finalString+"9 "; 
  } 
  if (t==9.50) { 
    finalString=finalString+"9.5 "; 
  } 
  if (t==10.00) { 
    finalString=finalString+"10 "; 
  } 
  if (t==10.50) { 
    finalString=finalString+"10.5 "; 
  } 
  if (t==11.00) { 
    finalString=finalString+"11 "; 
  } 
  if (t==11.50) { 
    finalString=finalString+"11.5 "; 
  } 
  if (t==12.00) { 
    finalString=finalString+"12 "; 
  } 
  if (t==12.50) { 
    finalString=finalString+"12.5 "; 
  } 
  if (t==13.00) { 
    finalString=finalString+"13 "; 
  } 
  if (t==13.50) { 
    finalString=finalString+"13.5 "; 
  } 
  if (t==14.00) { 
    finalString=finalString+"14 "; 
  } 
  if (t==14.50) { 
    finalString=finalString+"14.5 "; 
  } 
  if (t==15.00) { 
    finalString=finalString+"15 "; 
  } 
  if (t==15.50) { 
    finalString=finalString+"15.5 "; 
  } 
  if (t==16.00) { 
    finalString=finalString+"16 "; 
  } 
  if (t==16.50) { 
    finalString=finalString+"16.5 "; 
  } 
  if (t==17.00) { 
    finalString=finalString+"17 "; 
  } 
  if (t==17.50) { 
    finalString=finalString+"17.5 "; 
  } 
  if (t==18.00) { 
    finalString=finalString+"18 "; 
  } 
  if (t==18.50) { 
    finalString=finalString+"18.5 "; 
  } 
  if (t==19.00) { 
    finalString=finalString+"19 "; 
  } 
  if (t==19.50) { 
    finalString=finalString+"19.5 "; 
  } 
  if (t==20.00) { 
    finalString=finalString+"20 "; 
  } 
  if (t==20.50) { 
    finalString=finalString+"20.5 "; 
  } 
  if (t==21.00) { 
    finalString=finalString+"21 "; 
  } 
  if (t==21.50) { 
    finalString=finalString+"21.5 "; 
  } 
  if (t==22.00) { 
    finalString=finalString+"22 "; 
  }

  if (t==22.50) { 
    finalString=finalString+"22.5 "; 
  } 
  if (t==23.00) { 
    finalString=finalString+"23 "; 
  } 
  if (t==23.50) { 
    finalString=finalString+"23.5 "; 
  } 
  if (t==24.00) { 
    finalString=finalString+"24 "; 
  } 
  if (t==24.50) { 
    finalString=finalString+"24.5 "; 
  } 
  if (t==25.00) { 
    finalString=finalString+"25 "; 
  } 
  if (t==25.50) { 
    finalString=finalString+"25.5 "; 
  } 
  if (t==26.00) { 
    finalString=finalString+"26 "; 
  } 
  if (t==26.50) { 
    finalString=finalString+"26.5 "; 
  } 
  if (t==27.00) { 
    finalString=finalString+"27 "; 
  } 
  if (t==27.50) { 
    finalString=finalString+"27.5 "; 
  } 
  if (t==28.00) { 
    finalString=finalString+"28 "; 
  } 
  if (t==28.50) { 
    finalString=finalString+"28.5 "; 
  } 
  if (t==29.00) { 
    finalString=finalString+"29 "; 
  } 
  if (t==29.50) { 
    finalString=finalString+"29.5 "; 
  } 
  if (t==30.00) { 
    finalString=finalString+"30 "; 
  } 
  if (t==30.50) { 
    finalString=finalString+"30.5 "; 
  } 
  if (t==31.00) { 
    finalString=finalString+"31 "; 
  } 
  if (t==31.50) { 
    finalString=finalString+"31.5 "; 
  } 
  if (t==32.00) { 
    finalString=finalString+"32 "; 
  } 
  if (t==32.50) { 
    finalString=finalString+"32.5 "; 
  } 
  if (t==33.00) { 
    finalString=finalString+"33 "; 
  } 
  if (t==33.50) { 
    finalString=finalString+"33.5 "; 
  } 
  if (t==34.00) { 
    finalString=finalString+"34 "; 
  } 
  if (t==34.50) { 
    finalString=finalString+"34.5 "; 
  } 
  if (t==35.00) { 
    finalString=finalString+"35 "; 
  } 
  if (t==35.50) { 
    finalString=finalString+"35.5 "; 
  } 
  if (t==36.00) { 
    finalString=finalString+"36 "; 
  } 
  if (t==36.50) { 
    finalString=finalString+"36.5 "; 
  } 
  if (t==37.00) { 
    finalString=finalString+"37 "; 
  } 
  if (t==37.50) { 
    finalString=finalString+"37.5 "; 
  } 
  if (t==38.00) { 
    finalString=finalString+"38 "; 
  } 
  if (t==38.50) { 
    finalString=finalString+"38.5 "; 
  } 
  if (t==39.00) { 
    finalString=finalString+"39 "; 
  } 
  if (t==39.50) { 
    finalString=finalString+"39.5 "; 
  } 
  if (t==40.00) { 
    finalString=finalString+"40 "; 
  } 
  if (t==40.50) { 
    finalString=finalString+"40.5 "; 
  } 
  if (t==41.00) { 
    finalString=finalString+"41 "; 
  } 
  if (t==41.50) { 
    finalString=finalString+"41.5 "; 
  } 
  if (t==42.00) { 
    finalString=finalString+"42 "; 
  } 
  if (t==42.50) { 
    finalString=finalString+"42.5 "; 
  } 
  if (t==43.00) { 
    finalString=finalString+"43 "; 
  } 
  if (t==43.50) { 
    finalString=finalString+"43.5 "; 
  } 
  if (t==44.00) { 
    finalString=finalString+"44 "; 
  } 
  if (t==44.50) { 
    finalString=finalString+"44.5 "; 
  } 
  if (t==45.00) { 
    finalString=finalString+"45 "; 
  } 
  if (t==45.50) { 
    finalString=finalString+"45.5 "; 
  } 
  if (t==46.00) { 
    finalString=finalString+"46 "; 
  } 
  if (t==46.50) { 
    finalString=finalString+"46.5 "; 
  } 
  if (t==47.00) { 
    finalString=finalString+"47 "; 
  } 
  if (t==47.50) { 
    finalString=finalString+"47.5 "; 
  } 
  if (t==48.00) { 
    finalString=finalString+"48 "; 
  } 
  if (t==48.50) { 
    finalString=finalString+"48.5 "; 
  } 
  if (t==49.00) { 
    finalString=finalString+"49 "; 
  } 
  if (t==49.50) { 
    finalString=finalString+"49.5 "; 
  } 
  if (t==50.00) { 
    finalString=finalString+"50 "; 
  } 
  if (t==50.50) { 
    finalString=finalString+"50.5 "; 
  } 
  if (t==51.00) { 
    finalString=finalString+"51 "; 
  } 
  if (t==51.50) { 
    finalString=finalString+"51.5 "; 
  } 
  if (t==52.00) { 
    finalString=finalString+"52 "; 
  } 
  if (t==52.50) { 
    finalString=finalString+"52.5 "; 
  } 
  if (t==53.00) { 
    finalString=finalString+"53 "; 
  } 
  if (t==53.50) { 
    finalString=finalString+"53.5 "; 
  } 
  if (t==54.00) { 
    finalString=finalString+"54 "; 
  } 
  if (t==54.50) { 
    finalString=finalString+"54.5 "; 
  } 
  if (t==55.00) { 
    finalString=finalString+"55 "; 
  } 
  if (t==55.50) { 
    finalString=finalString+"55.5 "; 
  } 
  if (t>=55.50) { 
    finalString=finalString+"HOT "; 
  } 
  finalString=finalString+"*C ";
}

void setup() {
  Serial.begin(9600);
  sensors.begin(); 
  if (!sensors.getAddress(yourThermometer, 0)) {     // check your sensor is found
    Serial.println("Unable to find thermometer"); 
    for(;;);   // stop here if no thermometer found
  }
  sensors.setResolution(yourThermometer, 9);         // set the resolution to 9 bit
  // for DMD
  Timer1.initialize( 5000 );
  Timer1.attachInterrupt( ScanDMD );   
  dmd.clearScreen(true);
}

void loop(void) {
  // get the temperature and round it to nearest 5
  t=sensors.getTempC(yourThermometer); 
  t=round5(t);

  // now create the text to display on the DMD
  createTextTemp();

  // now send the text to the DMD
  drawText(finalString);
}
You'll find this method in the Dallas examples sketch single. I'm using the variable yourThermometer to store the device address of the first sensor located on the OneWire bus. This presumes there's only one sensor, so that's always going to be the first element of your array of sensors, sensors[0].

This might not entirely work, but it should get you nearer. Cheers ! Geoff

vrooms23
Posts:38
Joined:Sun Jun 30, 2013 9:23 am

Re: Need to find DMD with temp only

Post by vrooms23 » Mon Aug 05, 2013 3:08 pm

All right, I'm still trying figure out, if still no good so give up then better buy DHT HUMID: Humidity and Temperature Sensor Module. simple way as most work.
Thanks.

User avatar
stryker
Posts:282
Joined:Sat Jan 14, 2012 2:44 pm

Re: Need to find DMD with temp only

Post by stryker » Mon Aug 05, 2013 3:16 pm

Hi

I don't think you'll find it will save you any work. You're very near having this thing solved I'd say.

Geoff

vrooms23
Posts:38
Joined:Sun Jun 30, 2013 9:23 am

Re: Need to find DMD with temp only

Post by vrooms23 » Fri Aug 09, 2013 12:14 pm

Steyker, really, am I very near having that thing solved for DS18B20? I will still try doing, but I bought DHT temp, I copied your code for DHT, I played up and then still nothing screen, but found out not because of Dallas or DHT, because same happened DMD nothing running but start with finalString=finalString+"It's "; should be running show text start with "It's" first but no screen! I did test with DHT temp by DHTtester from libraries, its working with DHT use Serial Monitor looks fine I know sure connected D3, my DMD was fine by my own codes. Somehow reason what between versions, your code this; that old version? mine 1.0.5, nothing show text by finalString=finalString+"It's ";

Code: Select all

// DHT22>DMD temperature display
// John Boxall 2013 

float t; // holds temperature value
String finalString; // used to hold final sentence to display on DMD

// connect the HUMID: to 5V, GND and D3
#include "DHT.h"
DHT dht(3, DHT22);

// for Freetronics DMD
#include <SPI.h>      
#include <DMD.h>      
#include <TimerOne.h> 
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#define DISPLAYS_ACROSS 1 // you could have more than one DMD in a row
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);

void ScanDMD() // required for DMD
{ 
  dmd.scanDisplayBySPI();
}

int round5(float n)
{
  float a;
  int b;
  a = ((n/0.50)+0.5);
  b = int (a);
  b = b * 0.50;
  return b;
}

void drawText(String oldString) 
{
  //Clear the panel
  dmd.clearScreen(true);
  //Select font
  //dmd.selectFont(System5x7);
  dmd.selectFont(Arial_Black_16);
  char newString[256];
  int sLength = oldString.length();
  oldString.toCharArray(newString, sLength+1);
  dmd.drawMarquee(newString,sLength,(32*DISPLAYS_ACROSS)-1,0);
  long start=millis();
  long timer=start;
  long timer2=start;
  boolean ret=false;
  while(!ret){
    if ((timer+40) < millis()) {  //Select speed
      ret=dmd.stepMarquee(-1,0);
      timer=millis();
    }
  }
}

void createTextTemp()
// this mashes up all the temprature data into text 
{
  Serial.println("createTextTime()"); // for debug

  finalString=" "; // wipe the sentence out for special cases (below)
  finalString=finalString+"It's ";

  // add the list of numbers from -10.50 to 55.50
  if (t<=-10.50) { 
    finalString=finalString+"COLD "; 
  } 
  if (t==-10.00) { 
    finalString=finalString+"-10 "; 
  } 
  if (t==-9.50) { 
    finalString=finalString+"-9.5 "; 
  } 
  if (t==-9.00) { 
    finalString=finalString+"-9.0 "; 
  } 
  if (t==-8.50) { 
    finalString=finalString+"-8.5 "; 
  } 
  if (t==-8.00) { 
    finalString=finalString+"-8 "; 
  } 
  if (t==-7.50) { 
    finalString=finalString+"-7.5 "; 
  } 
  if (t==-7.00) { 
    finalString=finalString+"-7 "; 
  } 
  if (t==-6.50) { 
    finalString=finalString+"-6.5 "; 
  } 
  if (t==-6.00) { 
    finalString=finalString+"-6 "; 
  } 
  if (t==-5.50) { 
    finalString=finalString+"-5.5 "; 
  } 
  if (t==-4.50) { 
    finalString=finalString+"-4.5 "; 
  } 
  if (t==-4.00) { 
    finalString=finalString+"-4 "; 
  } 
  if (t==-3.50) { 
    finalString=finalString+"-3.5 "; 
  } 
  if (t==-3.00) { 
    finalString=finalString+"-3 "; 
  } 
  if (t==-2.50) { 
    finalString=finalString+"-2.5 "; 
  } 
  if (t==-2.00) { 
    finalString=finalString+"-2 "; 
  } 
  if (t==-1.50) { 
    finalString=finalString+"-1.5 "; 
  } 
  if (t==-1.00) { 
    finalString=finalString+"-1 "; 
  } 
  if (t==0.00) { 
    finalString=finalString+"0 "; 
  } 
  if (t==0.50) { 
    finalString=finalString+"0.5 "; 
  } 
  if (t==1.00) { 
    finalString=finalString+"1 "; 
  } 
  if (t==1.50) { 
    finalString=finalString+"1.5 "; 
  } 
  if (t==2.00) { 
    finalString=finalString+"2 "; 
  } 
  if (t==2.50) { 
    finalString=finalString+"2.5 "; 
  } 
  if (t==3.00) { 
    finalString=finalString+"3 "; 
  } 
  if (t==3.50) { 
    finalString=finalString+"3.5 "; 
  } 
  if (t==4.00) { 
    finalString=finalString+"4 "; 
  } 
  if (t==4.50) { 
    finalString=finalString+"4.5 "; 
  } 
  if (t==5.00) { 
    finalString=finalString+"5 "; 
  } 
  if (t==5.50) { 
    finalString=finalString+"5.5 "; 
  } 
  if (t==6.00) { 
    finalString=finalString+"6 "; 
  } 
  if (t==6.50) { 
    finalString=finalString+"6.5 "; 
  } 
  if (t==7.00) { 
    finalString=finalString+"7 "; 
  } 
  if (t==7.50) { 
    finalString=finalString+"7.5 "; 
  } 
  if (t==8.00) { 
    finalString=finalString+"8 "; 
  } 
  if (t==8.50) { 
    finalString=finalString+"8.5 "; 
  } 
  if (t==9.00) { 
    finalString=finalString+"9 "; 
  } 
  if (t==9.50) { 
    finalString=finalString+"9.5 "; 
  } 
  if (t==10.00) { 
    finalString=finalString+"10 "; 
  } 
  if (t==10.50) { 
    finalString=finalString+"10.5 "; 
  } 
  if (t==11.00) { 
    finalString=finalString+"11 "; 
  } 
  if (t==11.50) { 
    finalString=finalString+"11.5 "; 
  } 
  if (t==12.00) { 
    finalString=finalString+"12 "; 
  } 
  if (t==12.50) { 
    finalString=finalString+"12.5 "; 
  } 
  if (t==13.00) { 
    finalString=finalString+"13 "; 
  } 
  if (t==13.50) { 
    finalString=finalString+"13.5 "; 
  } 
  if (t==14.00) { 
    finalString=finalString+"14 "; 
  } 
  if (t==14.50) { 
    finalString=finalString+"14.5 "; 
  } 
  if (t==15.00) { 
    finalString=finalString+"15 "; 
  } 
  if (t==15.50) { 
    finalString=finalString+"15.5 "; 
  } 
  if (t==16.00) { 
    finalString=finalString+"16 "; 
  } 
  if (t==16.50) { 
    finalString=finalString+"16.5 "; 
  } 
  if (t==17.00) { 
    finalString=finalString+"17 "; 
  } 
  if (t==17.50) { 
    finalString=finalString+"17.5 "; 
  } 
  if (t==18.00) { 
    finalString=finalString+"18 "; 
  } 
  if (t==18.50) { 
    finalString=finalString+"18.5 "; 
  } 
  if (t==19.00) { 
    finalString=finalString+"19 "; 
  } 
  if (t==19.50) { 
    finalString=finalString+"19.5 "; 
  } 
  if (t==20.00) { 
    finalString=finalString+"20 "; 
  } 
  if (t==20.50) { 
    finalString=finalString+"20.5 "; 
  } 
  if (t==21.00) { 
    finalString=finalString+"21 "; 
  } 
  if (t==21.50) { 
    finalString=finalString+"21.5 "; 
  } 
  if (t==22.00) { 
    finalString=finalString+"22 "; 
  }

  if (t==22.50) { 
    finalString=finalString+"22.5 "; 
  } 
  if (t==23.00) { 
    finalString=finalString+"23 "; 
  } 
  if (t==23.50) { 
    finalString=finalString+"23.5 "; 
  } 
  if (t==24.00) { 
    finalString=finalString+"24 "; 
  } 
  if (t==24.50) { 
    finalString=finalString+"24.5 "; 
  } 
  if (t==25.00) { 
    finalString=finalString+"25 "; 
  } 
  if (t==25.50) { 
    finalString=finalString+"25.5 "; 
  } 
  if (t==26.00) { 
    finalString=finalString+"26 "; 
  } 
  if (t==26.50) { 
    finalString=finalString+"26.5 "; 
  } 
  if (t==27.00) { 
    finalString=finalString+"27 "; 
  } 
  if (t==27.50) { 
    finalString=finalString+"27.5 "; 
  } 
  if (t==28.00) { 
    finalString=finalString+"28 "; 
  } 
  if (t==28.50) { 
    finalString=finalString+"28.5 "; 
  } 
  if (t==29.00) { 
    finalString=finalString+"29 "; 
  } 
  if (t==29.50) { 
    finalString=finalString+"29.5 "; 
  } 
  if (t==30.00) { 
    finalString=finalString+"30 "; 
  } 
  if (t==30.50) { 
    finalString=finalString+"30.5 "; 
  } 
  if (t==31.00) { 
    finalString=finalString+"31 "; 
  } 
  if (t==31.50) { 
    finalString=finalString+"31.5 "; 
  } 
  if (t==32.00) { 
    finalString=finalString+"32 "; 
  } 
  if (t==32.50) { 
    finalString=finalString+"32.5 "; 
  } 
  if (t==33.00) { 
    finalString=finalString+"33 "; 
  } 
  if (t==33.50) { 
    finalString=finalString+"33.5 "; 
  } 
  if (t==34.00) { 
    finalString=finalString+"34 "; 
  } 
  if (t==34.50) { 
    finalString=finalString+"34.5 "; 
  } 
  if (t==35.00) { 
    finalString=finalString+"35 "; 
  } 
  if (t==35.50) { 
    finalString=finalString+"35.5 "; 
  } 
  if (t==36.00) { 
    finalString=finalString+"36 "; 
  } 
  if (t==36.50) { 
    finalString=finalString+"36.5 "; 
  } 
  if (t==37.00) { 
    finalString=finalString+"37 "; 
  } 
  if (t==37.50) { 
    finalString=finalString+"37.5 "; 
  } 
  if (t==38.00) { 
    finalString=finalString+"38 "; 
  } 
  if (t==38.50) { 
    finalString=finalString+"38.5 "; 
  } 
  if (t==39.00) { 
    finalString=finalString+"39 "; 
  } 
  if (t==39.50) { 
    finalString=finalString+"39.5 "; 
  } 
  if (t==40.00) { 
    finalString=finalString+"40 "; 
  } 
  if (t==40.50) { 
    finalString=finalString+"40.5 "; 
  } 
  if (t==41.00) { 
    finalString=finalString+"41 "; 
  } 
  if (t==41.50) { 
    finalString=finalString+"41.5 "; 
  } 
  if (t==42.00) { 
    finalString=finalString+"42 "; 
  } 
  if (t==42.50) { 
    finalString=finalString+"42.5 "; 
  } 
  if (t==43.00) { 
    finalString=finalString+"43 "; 
  } 
  if (t==43.50) { 
    finalString=finalString+"43.5 "; 
  } 
  if (t==44.00) { 
    finalString=finalString+"44 "; 
  } 
  if (t==44.50) { 
    finalString=finalString+"44.5 "; 
  } 
  if (t==45.00) { 
    finalString=finalString+"45 "; 
  } 
  if (t==45.50) { 
    finalString=finalString+"45.5 "; 
  } 
  if (t==46.00) { 
    finalString=finalString+"46 "; 
  } 
  if (t==46.50) { 
    finalString=finalString+"46.5 "; 
  } 
  if (t==47.00) { 
    finalString=finalString+"47 "; 
  } 
  if (t==47.50) { 
    finalString=finalString+"47.5 "; 
  } 
  if (t==48.00) { 
    finalString=finalString+"48 "; 
  } 
  if (t==48.50) { 
    finalString=finalString+"48.5 "; 
  } 
  if (t==49.00) { 
    finalString=finalString+"49 "; 
  } 
  if (t==49.50) { 
    finalString=finalString+"49.5 "; 
  } 
  if (t==50.00) { 
    finalString=finalString+"50 "; 
  } 
  if (t==50.50) { 
    finalString=finalString+"50.5 "; 
  } 
  if (t==51.00) { 
    finalString=finalString+"51 "; 
  } 
  if (t==51.50) { 
    finalString=finalString+"51.5 "; 
  } 
  if (t==52.00) { 
    finalString=finalString+"52 "; 
  } 
  if (t==52.50) { 
    finalString=finalString+"52.5 "; 
  } 
  if (t==53.00) { 
    finalString=finalString+"53 "; 
  } 
  if (t==53.50) { 
    finalString=finalString+"53.5 "; 
  } 
  if (t==54.00) { 
    finalString=finalString+"54 "; 
  } 
  if (t==54.50) { 
    finalString=finalString+"54.5 "; 
  } 
  if (t==55.00) { 
    finalString=finalString+"55 "; 
  } 
  if (t==55.50) { 
    finalString=finalString+"55.5 "; 
  } 
  if (t>=55.50) { 
    finalString=finalString+"HOT "; 
  } 
  finalString=finalString+"*C ";
}

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

  // for DMD
  Timer1.initialize( 5000 );
  Timer1.attachInterrupt( ScanDMD );   
  dmd.clearScreen(true);
}

void loop()
{
  // get the temperature and round it to nearest 5
  t=dht.readTemperature(); 
  t=round5(t);

  // now create the text to display on the DMD
  createTextTemp();

  // now send the text to the DMD
  drawText(finalString);
}

vrooms23
Posts:38
Joined:Sun Jun 30, 2013 9:23 am

Re: Need to find DMD with temp only

Post by vrooms23 » Fri Aug 09, 2013 12:24 pm

I changed code for test only, example I picked few code, only show this;

Code: Select all

String finalString="test";

void loop()
{
  // get the temperature and round it to nearest 5
  t=dht.readTemperature(); 
  t=round5(t);

  //now create the text to display on the DMD
  //createTextTemp();

  // now send the text to the DMD
  drawText(finalString);
  
}
DMD running text "test" that DMD looks fine! something problem with void createTextTemp() and drawText(finalString); not surely what reason.

User avatar
stryker
Posts:282
Joined:Sat Jan 14, 2012 2:44 pm

Re: Need to find DMD with temp only

Post by stryker » Fri Aug 09, 2013 3:19 pm

Hi,

To understand what's going on inside your code more, add some Serial prints. Something like this:

Code: Select all

  // get the temperature and round it to nearest 5
  t=dht.readTemperature(); 
// debugging
  Serial.print("DHT output: "); 
  Serial.print(t);
//
  t=round5(t);
// debugging
  Serial.print("\tAfter rounding: ");
  Serial.print(t);
  Serial.print("\tfinalString: ");

  // now create the text to display on the DMD
  createTextTemp();
  Serial.println(finalString);            // debugging
Run your code and you'll get a better idea where things are going wrong.

Cheers!
Geoff

vrooms23
Posts:38
Joined:Sun Jun 30, 2013 9:23 am

Re: Need to find DMD with temp only

Post by vrooms23 » Fri Aug 09, 2013 6:01 pm

Hi, yeah I think to understand, I added code from yours, serial monitor show funny something this;

DHT oRea¤DHT oRea¤DHT ouReadDHT ouReadDHT ou

So I removed createTextTemp(), then running its working show monitor this;

DHT output: 22.40 After rounding: 22.00 finalString:
DHT output: 22.40 After rounding: 22.00 finalString:
DHT output: 22.30 After rounding: 22.00 finalString:
DHT output: 22.30 After rounding: 22.00 finalString:

but seen third is finalString: no show number temp from void createTextTemp() because removed createTextTemp() nothing through, if leave createTextTemp() so not working through void createTextTemp() no show monitor weird why, yes I know I'll get a better idea where things are going wrong like that, reason is void createTextTemp() no running while no DMD!

vrooms23
Posts:38
Joined:Sun Jun 30, 2013 9:23 am

Re: Need to find DMD with temp only

Post by vrooms23 » Sat Aug 10, 2013 3:52 am

vrooms23 wrote:Hi, yeah I think to understand, I added code from yours, serial monitor show funny something this;

DHT oRea¤DHT oRea¤DHT ouReadDHT ouReadDHT ou

So I removed createTextTemp(), then running its working show monitor this;

DHT output: 22.40 After rounding: 22.00 finalString:
DHT output: 22.40 After rounding: 22.00 finalString:
DHT output: 22.30 After rounding: 22.00 finalString:
DHT output: 22.30 After rounding: 22.00 finalString:

but seen third is finalString: no show number temp from void createTextTemp() because removed createTextTemp() nothing through, if leave createTextTemp() so not working through void createTextTemp() no show monitor weird why, yes I know I'll get a better idea where things are going wrong like that, reason is void createTextTemp() no running while no DMD!
Something reason that who created a code for DHT past from last April maybe used old 1.0.4 or down, but Arduino 1.0.5 since only 15th May, maybe updated changes libraries etc. Should I update 1.5.2 BETA? or not need required?

Post Reply