Programming LED Matrix (Temp and Text)

Hi there! I'm very new to arduino as well as to LED Matrix. I'm a student at the University of West Florida. For my Interactive Design final, I am building a thermometer on an LED matrix using the 16 x 32 matrix I bought from adafruit as well as the temp sensors.

Alright, so, here's what I have. I have my LED matrix completely wired to an arduino Uno. I also have the temp sensor wired in as well. I've run both sets of code and both work. I was then able to combine two codes into one and they both still work.

The codes I have include the RGB Matrix library from adafruit and then a temp code I found as well as a processor code to display the temp in a graph.

I've gone over this with my teacher and we were trying to figure out how to get the scrolling text to display the temperature readout from tempC.

We've gotten it down to this line:

const char str[] PROGMEM = "Adafruit 16x32 RGB LED Matrix";

..as this is what shows the text in the animation. I've researched progMem but I'm not understanding it. He said somehow we need to get progMem or a different variable to read out tempC..but whenever I change any of that code I get errors. I'm still doing research, but I'm still very much confused about this. Is there another code I need to add in?

To summarize, I need the scrolling text to read the temperature data from tempC .

If necessary I can attach a copy of the combined code. Also, I'm not sure if it matters or not..but the combined code works well. I tested it out and the LED matrix will turn on and the Procssing program will read and display the temperature graph.

You probably looked at the scrolling text example from Adafruit.

// scrolltext demo for Adafruit RGBmatrixPanel library.
// Demonstrates double-buffered animation on our 16x32 RGB LED matrix:
// http://www.adafruit.com/products/420

// Written by Limor Fried/Ladyada & Phil Burgess/PaintYourDragon
// for Adafruit Industries.
// BSD license, all text above must be included in any redistribution.

#include <Adafruit_GFX.h>   // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library

// Similar to F(), but for PROGMEM string pointers rather than literals
#define F2(progmem_ptr) (const __FlashStringHelper *)progmem_ptr

#define CLK 8  // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define OE  9
#define A   A0
#define B   A1
#define C   A2
// Last parameter = 'true' enables double-buffering, for flicker-free,
// buttery smooth animation.  Note that NOTHING WILL SHOW ON THE DISPLAY
// until the first call to swapBuffers().  This is normal.
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, true);
// Double-buffered mode consumes nearly all the RAM available on the
// Arduino Uno -- only a handful of free bytes remain.  Even the
// following string needs to go in PROGMEM:

const char str[] PROGMEM = "Adafruit 16x32 RGB LED Matrix";
int    textX   = matrix.width(),
       textMin = sizeof(str) * -12,
       hue     = 0;
int8_t ball[3][4] = {
  {  3,  0,  1,  1 }, // Initial X,Y pos & velocity for 3 bouncy balls
  { 17, 15,  1, -1 },
  { 27,  4, -1,  1 }
};
static const uint16_t PROGMEM ballcolor[3] = {
  0x0080, // Green=1
  0x0002, // Blue=1
  0x1000  // Red=1
};

void setup() {
  matrix.begin();
  matrix.setTextWrap(false); // Allow text to run off right edge
  matrix.setTextSize(2);
}

void loop() {
  byte i;

  // Clear background
  matrix.fillScreen(0);

  // Bounce three balls around
  for(i=0; i<3; i++) {
    // Draw 'ball'
    matrix.fillCircle(ball[i][0], ball[i][1], 5, pgm_read_word(&ballcolor[i]));
    // Update X, Y position
    ball[i][0] += ball[i][2];
    ball[i][1] += ball[i][3];
    // Bounce off edges
    if((ball[i][0] == 0) || (ball[i][0] == (matrix.width() - 1)))
      ball[i][2] *= -1;
    if((ball[i][1] == 0) || (ball[i][1] == (matrix.height() - 1)))
      ball[i][3] *= -1;
  }

  // Draw big scrolly text on top
  matrix.setTextColor(matrix.ColorHSV(hue, 255, 255, true));
  matrix.setCursor(textX, 1);
  matrix.print(F2(str));

  // Move text left (w/wrap), increase hue
  if((--textX) < textMin) textX = matrix.width();
  hue += 7;
  if(hue >= 1536) hue -= 1536;

  // Update display
  matrix.swapBuffers(false);
}

I think the key elements are

  matrix.setTextWrap(false); // Allow text to run off right edge

  matrix.setCursor(textX, 1);
  matrix.print(F2(str)); // signals a PROGMEM string

So if you have a string buffer with your text, the following should work

  char message[] = "Temperature 20°, slowly rising";
  matrix.setTextWrap(false); // Allow text to run off right edge

  matrix.setCursor(textX, 1);
  matrix.print(message); // string from RAM

So I tried to input the code you gave me and it isn't working. Where do I input it? Perhaps its the location. I tried to match with the examples you listed. At first, though the code said it compiled, nothing was coming up on my LED matrix. It wouldn't even turn on. I tried again and I got the matrix to come back on but it still was not quite displaying the temperature.
This is my code below.

// scrolltext demo for Adafruit RGBmatrixPanel library.
// Demonstrates double-buffered animation on our 16x32 RGB LED matrix:
// http://www.adafruit.com/products/420

// Written by Limor Fried/Ladyada & Phil Burgess/PaintYourDragon
// for Adafruit Industries.
// BSD license, all text above must be included in any redistribution.

float tempC;
int tempPin = 5;



#include <Adafruit_GFX.h>   // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library

// Similar to F(), but for PROGMEM string pointers rather than literals
#define F2(progmem_ptr) (const __FlashStringHelper *)progmem_ptr

#define CLK 8  // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define OE  9
#define A   A0
#define B   A1
#define C   A2
// Last parameter = 'true' enables double-buffering, for flicker-free,
// buttery smooth animation.  Note that NOTHING WILL SHOW ON THE DISPLAY
// until the first call to swapBuffers().  This is normal.
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, true);
// Double-buffered mode consumes nearly all the RAM available on the
// Arduino Uno -- only a handful of free bytes remain.  Even the
// following string needs to go in PROGMEM:

const char str[] PROGMEM = "Adafruit 16x32 RGB LED Matrix";
int    textX   = matrix.width(),
       textMin = sizeof(str) * -12,
       hue     = 0;
int8_t ball[3][4] = {
  {  3,  0,  1,  1 }, // Initial X,Y pos & velocity for 3 bouncy balls
  { 17, 15,  1, -1 },
  { 27,  4, -1,  1 }
};
static const uint16_t PROGMEM ballcolor[3] = {
  0x0080, // Green=1
  0x0002, // Blue=1
  0x1000  // Red=1
};

  void setup() {
 matrix.begin();
  matrix.setTextWrap(false); // Allow text to run off right edge
  matrix.setTextSize(2);




  Serial.begin(9600); //opens serial port, sets data rate to 9600 bps

  
}

void loop() {
  byte i;

tempC = analogRead(tempPin);           //read the value from the sensor
tempC = (5.0 * tempC * 100.0)/1024.0;  //convert the analog data to temperature
Serial.print((byte)tempC);             //send the data to the computer
//delay(1000); 

  // Clear background
  matrix.fillScreen(0);

  // Bounce three balls around
  for(i=0; i<3; i++) {
    // Draw 'ball'
    matrix.fillCircle(ball[i][0], ball[i][1], 5, pgm_read_word(&ballcolor[i]));
    // Update X, Y position
    ball[i][0] += ball[i][2];
    ball[i][1] += ball[i][3];
    // Bounce off edges
    if((ball[i][0] == 0) || (ball[i][0] == (matrix.width() - 1)))
      ball[i][2] *= -1;
    if((ball[i][1] == 0) || (ball[i][1] == (matrix.height() - 1)))
      ball[i][3] *= -1;
  }

  // Draw big scrolly text on top
  matrix.setTextColor(matrix.ColorHSV(hue, 255, 255, true));
 matrix.setCursor(textX, 1);
 matrix.print(F2(str));





  // Move text left (w/wrap), increase hue
  if((--textX) < textMin) textX = matrix.width();
  hue += 7;
  if(hue >= 1536) hue -= 1536;

  // Update display
  matrix.swapBuffers(false);
}

Hi there! I'm very new to arduino as well as to LED Matrix. I'm a student at the University . For my Interactive Design final, I am building a thermometer on an LED matrix using the 16 x 32 matrix RGB I bought from adafruit as well as the temp sensors.

Alright, so, here's what I have. I have my LED matrix completely wired to an arduino Uno. I also have the temp sensor wired in as well. I've run both sets of code and both work. I was then able to combine two codes into one and they both still work.

The codes I have include the RGB Matrix library from adafruit and then a temp code I found as well as a processor code to display the temp in a graph.

I've gone over this with my teacher and we were trying to figure out how to get the scrolling text to display the temperature readout from tempC.To summarize, I need the scrolling text to read the temperature data from tempC .

If necessary I can attach a copy of the combined code. Also, I'm not sure if it matters or not..but the combined code works well. I tested it out and the LED matrix will turn on and the Procssing program will read and display the temperature graph.

Your problem description has an uncanny resemblance to the three year old post you resurrected.
Anyway, include any new code you have in the thread.