Show Posts
Pages: [1] 2
1  Using Arduino / LEDs and Multiplexing / Re: 16 x 8 single color LED matrix scroll using MAX7219 and Uno on: December 05, 2012, 11:42:04 am
This is awesome.  Thanks for sharing your code.  I am currently using a 8x8 single color with max7219 and just got a Conway's Game of Life working.  I'm wondering if you can try it on your 16x8 and see if it works.  I think you would only have to change the X or Y from 8 to 16 and 1 IC to 2.  I have been trying to make it so i can have it play the GOL for a short while then scroll a message, then back again.  Can you give it a shot?  Thanks for any help.
Matt
2  Using Arduino / Programming Questions / Re: How to change code to use different library? on: December 05, 2012, 11:25:35 am
i'll try.  I need a microphone first. 
Thanks,
Matt
3  Using Arduino / Programming Questions / How to change code to use different library? on: December 03, 2012, 02:28:56 pm
Hello, i have made a one color 8x8 LED matrix and am running it with a MAX7219 and Arduino UNO.  I want to add a microphone to make a real time spectrum analyzer with it.  I have found many on the web that use a PC with processing but I want a all-in-one.  The closest one i found was an Adafruit page http://learn.adafruit.com/piccolo.  It gives code that uses a different LED driver and a 2 color matrix.  I would like code for a single color LED 8x8 matrix and uses the MAX7219. Can someone help or give me tips?  Is this easy?  Did someone already write a sketch for this setup that can share it? 
The adafruit version code can be downloaded at https://github.com/adafruit/piccolo/archive/master.zip
Thank you for help and or tips.
Matt
4  Using Arduino / LEDs and Multiplexing / Re: Help with 8x8 LED matrix and MAX7219 code Conway's Game of Life (almost done) on: November 30, 2012, 11:31:09 am
Hi JohnWasser. I changed the int to unsigned char and that made the display work better. The corner led is now working.

I tried your "neighboring cells" code in place of the one I had but only one row blinked a bit. So it must be missing something, but I appreciated your time in writing it.

If there are any more recommendations to make the code better I'd be happy to hear them. This will be a walling hanging so if you have an idea to add something that is cool to look at and runs autonomously I'd love to hear about it.
Thanks
Matt
5  Using Arduino / LEDs and Multiplexing / Re: Help with 8x8 LED matrix and MAX7219 code Conway's Game of Life (almost done) on: November 29, 2012, 11:48:04 am
Wow, John that is awesome.  I'll test it out when I get home tonight.  Thank you so much for you help.
Matt
6  Using Arduino / LEDs and Multiplexing / Re: Help with 8x8 LED matrix and MAX7219 code Conway's Game of Life (almost done) on: November 29, 2012, 10:45:57 am
That is a good question.  I don't know why the 19s and 69s are there.  I got the code from the forum http://arduino.cc/forum/index.php/topic,7091.0.html.  It was the only example code for GOL with max7219 I could find. I tried to rework it the best I could to make more sense, but that whole section with 19s and 69s i don't understand.  I also tried to rework the GOL code on http://www.arduino.cc/playground/Main/DirectDriveLEDMatrix to work with max7219 and the ledcontrol.h library but could not get it working. I'm fairly new to the more complicated part of coding but i'm trying.  I would appreciate any tips or any help anyone can offer in doing this.
Much thanks,
Matt
7  Using Arduino / LEDs and Multiplexing / Re: Help with 8x8 LED matrix and MAX7219 code Conway's Game of Life (almost done) on: November 29, 2012, 08:54:07 am
Thanks for the tip John. I appreciate it.  I'll make the change.

Has anyone else written a Conway's Game of Life for 8x8 with MAX7219?  If someone else has a MAX7219 with a 8x8 set up, can you try my code and let me know what you think? What should be changed.  It's not a big deal but there is that one LED that doesn't seem to play by the same rules, and I don't know why. Dose someone else notice, or have the same issue? I think GOL is fun to watch and once it's working well I can post instructions for others. Thanks a bunch.
Matt
8  Using Arduino / LEDs and Multiplexing / Help with 8x8 LED matrix and MAX7219 code Conway's Game of Life (almost done) on: November 28, 2012, 02:18:28 pm
Hello.  I'm about half done with a project of making a 8x8 LED matrix and controlling it with a MAX7219 IC.  I want it to run Conway's Game of Life and I'll make it into a wall hanging.  I have tinkered with some code I found and got it mostly working.  Can someone look over the code and tell me if (and how) it can be improved.  I noticed that (in my video) the lower left LED if on, stays on till it starts over, when it looks as if it should be blinking with the others, and I don't know why.  So I'm just looking for some advice.  Much thanks.  Here is my code and a link to a short video.
http://youtu.be/tB7lS_1KeGI

Code:
//Game of Life with MAX7219

/*

     * dataPin pin on the Arduino where data gets shifted out
     * clockPin pin for the clock
     * csPin pin for selecting the device
     * numDevices maximum number of devices that can be controled
LedControl(int dataPin, int clkPin, int csPin, int numDevices=1);
*/
/*******************************************************************************/

#include "LedControl.h"     //Imports the library

LedControl lc=LedControl(12,11,10,1);

#define SIZEX 8             //Sets the X axis size
#define SIZEY 8             //Sets the Y axis size
#define reseedrate 30       //Sets the rate the world is re-seeded
#define brightness 15       //Values from 1 to 15 to set the brightness
long density = 35;          //Sets density % during seeding
unsigned long delaytime=150;  //Sets the time each generation is shown
int generation = 0;         //Counter for re-seeding
int analogPin = 0;          //analogPin for the random seed data
int world1[8][8] = {{0, 0, 0, 1, 0, 0, 0, 0},
                    {0, 0, 1, 0, 1, 0, 0, 0},
                    {0, 1, 0, 1, 1, 0, 0, 0},
                    {1, 0, 1, 0, 0, 1, 1, 0},
                    {0, 1, 1, 0, 0, 1, 0, 1},
                    {0, 0, 0, 1, 1, 0, 1, 0},
                    {0, 0, 0, 1, 0, 1, 0, 0},
                    {0, 0, 0, 0, 1, 0, 0, 0}};
int world2[8][8];

/*******************************************************************************/
/* display cells */

void display_cells(int world1[8][8])
{
  int i,j;
  for(i=0;i<SIZEX;i++)
  {
    for(j=0;j<SIZEY;j++)
    {
      lc.setLed(0,i,j,world1[i][j]);

    }
  }
}

/*******************************************************************************/
/* compute previous generation*/

void previous_generation(int world1[8][8],int world2[8][8])
{
  int i,j;

  for(i=0;i<SIZEX;i++)
  {
    for(j=0;j<SIZEY;j++)
    {
      world2[i][j]=world1[i][j];
    }
  }
}

/*******************************************************************************/
/* compute next generation */

void next_generation(int world1[8][8],int world2[8][8])
{
  int i,j;

  for(i=0;i<SIZEX;i++)
  {
    for(j=0;j<SIZEY;j++)
    {
      world1[i][j]=world2[i][j];
    }
  }
}

/*******************************************************************************/
/* compute neighborough cells */
#
void neighbours(int world1[8][8],int world2[8][8])
{
  int i,j,a;

  for(i=0;i<SIZEX;i++)
  {
    for(j=0;j<SIZEY;j++)
    {
      if((i==0)&&(j==0))
      {
        a=world1[i][j+1]+world1[i+1][j]+world1[i+1][j+1]+world1[i][69]+world1[i+1][69]+world1[19][j]+world1[19][j+1]+world1[19][69];
      }

      if((i!=0)&&(j!=0)&&(i!=(SIZEX-1))&&(j!=(SIZEY-1)))
      {
        a=world1[i-1][j-1]+world1[i-1][j]+world1[i-1][j+1]+world1[i][j+1]+world1[i+1][j+1]+world1[i+1][j]+world1[i+1][j-1]+world1[i][j-1];
      }
     
      if((i==0)&&(j!=0)&&(j!=(SIZEY-1)))
      {
        a=world1[i][j-1]+world1[i+1][j-1]+world1[i+1][j]+world1[i+1][j+1]+world1[i][j+1]+world1[19][j-1]+world1[19][j]+world1[19][j+1];
      }

      if((i==0)&&(j==(SIZEY-1)))
      {
        a=world1[i][j-1]+world1[i+1][j-1]+world1[i+1][j]+world1[i][0]+world1[i+1][0]+world1[19][0]+world1[19][j]+world1[19][j-1];
      }
     
      if((i==(SIZEX-1))&&(j==0))
      {
        a=world1[i-1][j]+world1[i-1][j+1]+world1[i][j+1]+world1[i][69]+world1[i-1][69]+world1[0][j]+world1[0][j+1]+world1[0][69];
      }
     
      if((i==(SIZEX-1))&&(j!=0)&&(j!=(SIZEY-1)))
      {
        a=world1[i][j-1]+world1[i][j+1]+world1[i-1][j-1]+world1[i-1][j]+world1[i-1][j+1]+world1[0][j]+world1[0][j-1]+world1[0][j+1];
      }
     
      if((i==(SIZEX-1))&&(j==(SIZEY-1)))
      {
        a=world1[i][j-1]+world1[i-1][j-1]+world1[i-1][j]+world1[0][j]+world1[0][j-1]+world1[i][0]+world1[i-1][0]+world1[0][0];
      }

      if((i!=0)&&(i!=(SIZEX-1))&&(j==0))
      {
        a=world1[i-1][j]+world1[i-1][j+1]+world1[i][j+1]+world1[i+1][j+1]+world1[i+1][j]+world1[i][69]+world1[i-1][69]+world1[i+1][69];
      }

      if((i!=0)&&(i!=(SIZEX-1))&&(j==(SIZEY-1)))
      {
        a=world1[i-1][j]+world1[i-1][j-1]+world1[i][j-1]+world1[i+1][j-1]+world1[i+1][j]+world1[i][0]+world1[i-1][0]+world1[i+1][0];
      }

      if((world1[i][j]==0)&&(a==3)){world2[i][j]=1;}
      if((world1[i][j]==1)&&((a==2)||(a==3))){world2[i][j]=1;}
      if((world1[i][j]==1)&&((a==1)||(a==0)||(a>3))){world2[i][j]=0;}
    }
  }
}

/*******************************************************************************/
/* randomize */

void seedWorld(int world1[8][8])
{
  int i,j;
  randomSeed(analogRead(analogPin));
  for(i=0;i<SIZEX;i++)
  {
    for(j=0;j<SIZEY;j++)
    {
      if (random(100) < density); {
    world1[i][j]=random(2);
      }
  }
  }
}

/*******************************************************************************/

void setup() {
   lc.shutdown(0,false);
   lc.setIntensity(0,brightness);
   lc.clearDisplay(0);
   seedWorld(world1);
}

/*******************************************************************************/

void loop()
{

   if (generation++ > reseedrate)
   {
     seedWorld(world1);
     lc.clearDisplay(0);
     delay(300);
     generation=0;
   }
     
    previous_generation(world1,world2);
    neighbours(world1,world2);
    next_generation(world1,world2);
    display_cells(world1);
    delay(delaytime);
   
 
}

9  Using Arduino / LEDs and Multiplexing / 8x8x8 LED Cube with 74hc595 help please on: April 23, 2012, 02:31:27 pm
Hello,
I'm building an 8x8x8 LED Cube from www.instructables.com/id/Led-Cube-8x8x8/.  The author uses 8 74HC574 ICs and 1 74HC138 IC.  I would like to use 74hc595 shift registers for the multiplexing since I have plenty already, instead of the types the author used.  The instructions does give Arduino code which is great, but I don't know how it needs to be changed to use the 74hc595 ICs. 

Can someone who is more familiar with these ICs change the code for use with 74hc595 shift registers?  This would be a huge help and greatly appreciated.  Also does someone have a schematic of how the shift registers are connected and cascaded so I know I'm doing it right?

The Arduino code can easily be downloaded at
https://www.dropbox.com/s/u2xwny9ajyflg6l/arduinocube.pde

Thank you for your help.
Matt
10  Using Arduino / Programming Questions / Conway's Game of Life Code with auto restart? on: December 21, 2011, 03:43:54 pm
Does any one have code for Conway's Game of Life that will restart itself when it either dies out, gets stuck on a still image, or gets stuck in a repeating pattern?  I have tried for awhile but can't seem to make it work right and would like some help.

This is the original code I had and I know works, but only runs "one game."  It is from http://www.instructables.com/id/810-LED-Matrix-with-4017/

Code:
// 10*8 LED matrix with 4017 IC
// Made by Vadim S.
//On 25.06.2009
#define XSIZE 10
#define YSIZE 8
int DataPin = 9;
int LatchPin = 11;
int ClockPin = 10;
int clock = 13;
int Reset = 12;
int a;
byte world[10][8][2];
long density = 50; // The density of the population on the the screen
byte bank[] = {
  B00000001,B00000010,B00000100,B00001000,B00010000,B00100000,B01000000,B10000000}; // a pool of bytes
// set up
byte leds_1[10] = {
  B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000};
byte leds_2[10] = {
  B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000};
void setup(){
  pinMode(DataPin,OUTPUT);
  pinMode(ClockPin,OUTPUT);
  pinMode(LatchPin,OUTPUT);
  //simple stuff here
  pinMode(clock,OUTPUT);
  pinMode(Reset,OUTPUT);
  //reseting the 4017 IC, you have to do this
  digitalWrite(Reset,HIGH);
  delayMicroseconds(5);
  digitalWrite(Reset,LOW);
  randomSeed(analogRead(5));// a random seed for the random start pattern
  // random papulation of the screen
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 8; j++) {
      if (random(100) < density) {
        world[i][j][0] = 1;
        leds_1[i]+=bank[j];
        leds_2[i] = leds_1[i];
      }
      else {
        world[i][j][0] = 0;
      }
      world[i][j][1] = 0;
    }
  }
}


void loop(){
  display_pattern_1(50);
  // Birth and death cycle
  for (int x = 0; x < 10; x++) {
    for (int y = 0; y < 8; y++) {
      // Default is for cell to stay the same
      world[x][y][1] = world[x][y][0];
      int count = neighbours(x, y);
      if (count == 3 && world[x][y][0] == 0) {
        // A new cell is born
        world[x][y][1] = 1;
        leds_2[x] += bank[y];
      }
      if ((count < 2 || count > 3) && world[x][y][0] == 1) {
        // Cell dies
        world[x][y][1] = 0;
        leds_2[x] -= bank[y];
      }
    }
  }

  // Copy next generation into place
  for (int x = 0; x < 10; x++) {
    for (int y = 0; y < 8; y++) {
      world[x][y][0] = world[x][y][1];
      leds_1[x] = leds_2[x];
    }
  }
}

// This function is for the 4 laws in conway's game of life
int neighbours(int x, int y) {
  return world[(x + 1) % XSIZE][y][0] +
    world[x][(y + 1) % YSIZE][0] +
    world[(x + XSIZE - 1) % XSIZE][y][0] +
    world[x][(y + YSIZE - 1) % YSIZE][0] +
    world[(x + 1) % XSIZE][(y + 1) % YSIZE][0] +
    world[(x + XSIZE - 1) % XSIZE][(y + 1) % YSIZE][0] +
    world[(x + XSIZE - 1) % XSIZE][(y + YSIZE - 1) % YSIZE][0] +
    world[(x + 1) % XSIZE][(y + YSIZE - 1) % YSIZE][0];
}


void display_pattern_1(int loops){
  for(int t=0;t<loops;t++){
    for(a=0;a<10;a++){
      digitalWrite(LatchPin, 0);
      shiftOut(DataPin, ClockPin,MSBFIRST,leds_1[a]);
      digitalWrite(LatchPin, 1);
      delayMicroseconds(800);
      digitalWrite(LatchPin, 0);
      shiftOut(DataPin, ClockPin,MSBFIRST,0);
      digitalWrite(LatchPin, 1);
      digitalWrite(clock,HIGH);
      digitalWrite(clock,LOW);
    }
  }
}


Also I would like to make another LED matrix with a max7219 IC.  Is there a port of "Game of Life" for use with this IC?  Preferably one that also has an auto restart when it dies out. 
11  Using Arduino / LEDs and Multiplexing / Re: 8x10 LED Matrix with TMP36 and DS1307 Question on: December 08, 2011, 01:06:53 pm
Can someone look at this code and tell me if I'm on the right track?  I'm trying to scroll the temp. and time.  I don't know how to add the degress symbol and colon in their proper places.  Thanks and I appreciate your help.

Code:
int DataPin = 9;
int LatchPin = 11;
int ClockPin = 10;
int clock = 13;
int Reset = 12;
//x,y for the loop
int x;
int y;
int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
                      

int adjust = -11;

//Other Symbols

#define degree {B00000000,B01110000,B01010000,B01110000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000}
#define slash {B00000000,B00000100,B00000100,B00001000,B00001000,B00010000,B00010000,B00100000,B00100000,B00000000}
#define dash {B00000000,B00000000,B00000000,B00000000,B01111110,B01111110,B00000000,B00000000,B00000000,B00000000}
#define colon {B00000000,B00000000,B00011000,B00011000,B00000000,B00000000,B00011000,B00011000,B00000000,B00000000}


byte digits [10] [10] = {
 {B00000000,B00111100,B01000110,B01001010,B01001010,B01001010,B01010010,B01100010,B00111100,B00000000},
 {B00000000,B00001000,B00011000,B00001000,B00001000,B00001000,B00001000,B00001000,B00011100,B00000000},
 {B00000000,B00111100,B01000010,B00000100,B00001000,B00010000,B00100000,B01000000,B01111110,B00000000},
 {B00000000,B01111110,B00000010,B00000010,B00011100,B00000010,B00000010,B01000010,B00111100,B00000000},
 {B00000000,B00000100,B00001100,B00010100,B00100100,B01000100,B01111110,B00000100,B00000100,B00000000},
 {B00000000,B01111110,B01000000,B01000000,B00111100,B00000010,B00000010,B00000010,B01111100,B00000000},
 {B00000000,B00111100,B01000000,B01000000,B01111100,B01000010,B01000010,B01000010,B00111100,B00000000},
 {B00000000,B01111110,B00000010,B00000100,B00001000,B00010000,B00010000,B00010000,B00010000,B00000000},
 {B00000000,B00111100,B01000010,B01000010,B00111100,B01000010,B01000010,B01000010,B00111100,B00000000},
 {B00000000,B00111100,B01000010,B01000010,B01000010,B00111110,B00000010,B00000010,B00111100,B00000000},
};

const int numPatterns = 4;//this is the number of patterns you want to display
byte patterns[numPatterns][10]={space, space, space, space,};// the patterns order

//For the Time
#include <Wire.h>
#include "RTClib.h"
 
RTC_DS1307 RTC;

void setup(){
  Wire.begin();
  RTC.begin();
  
  pinMode(DataPin,OUTPUT);
  pinMode(ClockPin,OUTPUT);
  pinMode(LatchPin,OUTPUT);
  //simple stuff here
 pinMode(clock,OUTPUT);
  pinMode(Reset,OUTPUT);
  //reseting the 4017 IC, you have to do this
 digitalWrite(Reset,HIGH);
  delayMicroseconds(5);
  digitalWrite(Reset,LOW);
  
}

void display_pattern(int loops)//int loop acts like a delay, it take 8 mSecands to scan all of the rows so int loops = 15 is a good time for it
{
  for(x=0;x<numPatterns-1;x++){ // loop over the patterns
   for (int z=0;z<8;z++){ //scrolls one bite at a time
    for(int t=0;t<loops;t++){// the delay we get with loops
     for(y=0;y<10;y++){// loops over the array of bytes
     byte temp = patterns[x][y];
     byte temp_2=patterns[x+1][y];
      digitalWrite(LatchPin, 0);
     shiftOut(DataPin, ClockPin,MSBFIRST,((temp<<z)+(temp_2>>7-z)));//writes digital outputs, Z is for how much bites it need to scroll
          digitalWrite(LatchPin, 1);
      delayMicroseconds(800);
      digitalWrite(LatchPin, 0);
     shiftOut(DataPin, ClockPin,MSBFIRST,0);
      digitalWrite(LatchPin, 1);
     digitalWrite(clock,HIGH);
     digitalWrite(clock,LOW);
   }
  }
 }
}
}

void loop(){
  
  
 //getting the voltage reading from the temperature sensor
 int reading = analogRead(sensorPin);  
 
 // converting that reading to voltage, for 3.3v arduino use 3.3
 float voltage = reading * 5.0;
 voltage /= 1024.0;
 
 float temperatureC = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset
                                               //to degrees ((volatge - 500mV) times 100)
 
 // now convert to Fahrenheight
 float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0 + adjust;
 
 delay(1000);                                     //waiting a second
  
 int temp = temperatureF;  // or whatever from the temperature sensor
 
 char tempa [4];  // holds 3 digits plus terminator
 
 sprintf (tempa, "%3i", temp);  // turn temperature into a string
 
 // copy the bit patterns for each digit (digit 0, 1, 2)

 for (byte i = 0; i < 3; i++)
   memcpy (&patterns [i], &digits [tempa [i] - '0'], 10);
  
  display_pattern(15);
  
////////////////////
  
DateTime now = RTC.now();

char hour [3];  // holds 3 digits plus terminator
 
 sprintf (hour, "%2i", (now.hour()));  // turn temperature into a string
 
 // copy the bit patterns for each digit (digit 0, 1, 2)

 for (byte i = 0; i < 2; i++)
   memcpy (&patterns [i], &digits [hour [i] - '0'], 10);
  
 display_pattern(15);

////////////////////////

char minute [3];  // holds 3 digits plus terminator
 
 sprintf (minute, "%2i", (now.minute()));  // turn temperature into a string
 
 // copy the bit patterns for each digit (digit 0, 1, 2)

 for (byte i = 0; i < 2; i++)
   memcpy (&patterns [i], &digits [minute [i] - '0'], 10);
  
 display_pattern(15);

}
12  Using Arduino / LEDs and Multiplexing / Re: 8x10 LED Matrix with TMP36 and DS1307 Question on: December 04, 2011, 08:16:00 pm
I know this is a lot to ask and I'm not sure how well I communicated this, but I would really appreciate some help with the code.

Ok, I know the DS1307 is working and programmed with the current time.  I have been able to scroll the hour or minute but for some reason they are followed by a digit like "8".  I don't know how to make it look normal like with a colon between the hour and minute, and change it to 12 hour with AM and PM and not 24 hour, then date in month/day.  I'm not sure if it is possible but I was also trying to make it play a round of "Conway's Game of Life" after the date.

So, this is my goal.  I want to have my display scroll the temperature with the degrees symbol followed by the time with colon between hour and min and in 12 hour format with AM/PM, followed by the date in month/day.  It would be cool to have it play a round of Game of Life.  Then start back to temperature.   example,  "68o  5:43PM  12/3"  Then "game of life" if possable and back to temp.

The display seems to be trying to display some random data before the temp., because there are random lit LEDs before it.

Specific questions are:
I have working code for "Conway's Game of Life."  How, or is it possible to add it to another program?
How to add things like to colon and dash or any symbol between the sensor's input?
This code makes things scroll.  If I wanted how could I change it to make switch between still images?

I have attached the code i was working with and "Game of Life" code.  It all looks really messy to me and i'm sure most of it needs to be changed or reworked, but it may be close. 

Thank you so much.
Matt
13  Using Arduino / LEDs and Multiplexing / Re: 8x10 LED Matrix with TMP36 and DS1307 Question on: December 01, 2011, 12:55:09 pm
Thanks, I'll give it a try and i was missing the 10K pull-ups.  If I can get this to work i may need help incorporating it into the code I already have.  I'll try it out and post how it goes.  Thanks, for your time.  And do you have any idea how to get rid of that lit LED that always goes before the temp in the display? 
14  Using Arduino / LEDs and Multiplexing / Re: 8x10 LED Matrix DS1307 Code Help Please on: November 30, 2011, 01:54:07 pm
Well I worked on my project some more.  I have 2 questions.

1. I made this so it can scroll the temperature across the matrix but I would like the time also.  I have attached a DS1307.  The SDA pin is attached to analog pin 4, and the SCL pin is attached to analog pin 5, the battery is on the back.  Can someone either add the time code for me or tell me exactly how to do it?  I have not worked with a RTC before but I'm told that it's easy.  I would like to to scroll the temp followed by the time. 

2. As I scroll the temperature across the matrix it is always proceeded with a lit LED on the top row.  I can not figure out why and how to get rid of it.  Any ideas?  I have added a pic.

Here is the code I have so far:

Code:
int DataPin = 9;
int LatchPin = 11;
int ClockPin = 10;
int clock = 13;
int Reset = 12;
//x,y for the loop
int x;
int y;
int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
                        //the resolution is 10 mV / degree centigrade with a
                        //500 mV offset to allow for negative temperatures

#define space {B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000}
#define degree {B00000000,B01110000,B01010000,B01110000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000}
#define F     {B00000000,B01111110,B01000000,B01000000,B01111100,B01000000,B01000000,B01000000,B01000000,B00000000}
#define smile {B00000000,B00000000,B01100110,B01100110,B00010000,B00011000,B01000010,B00100100,B00011000,B00000000}

byte digits [10] [10] = {
 {B00000000,B00111100,B01000110,B01001010,B01001010,B01001010,B01010010,B01100010,B00111100,B00000000},
 {B00000000,B00001000,B00011000,B00001000,B00001000,B00001000,B00001000,B00001000,B00011100,B00000000},
 {B00000000,B00111100,B01000010,B00000100,B00001000,B00010000,B00100000,B01000000,B01111110,B00000000},
 {B00000000,B01111110,B00000010,B00000010,B00011100,B00000010,B00000010,B01000010,B00111100,B00000000},
 {B00000000,B00000100,B00001100,B00010100,B00100100,B01000100,B01111110,B00000100,B00000100,B00000000},
 {B00000000,B01111110,B01000000,B01000000,B00111100,B00000010,B00000010,B00000010,B01111100,B00000000},
 {B00000000,B00111100,B01000000,B01000000,B01111100,B01000010,B01000010,B01000010,B00111100,B00000000},
 {B00000000,B01111110,B00000010,B00000100,B00001000,B00010000,B00010000,B00010000,B00010000,B00000000},
 {B00000000,B00111100,B01000010,B01000010,B00111100,B01000010,B01000010,B01000010,B00111100,B00000000},
 {B00000000,B00111100,B01000010,B01000010,B01000010,B00111110,B00000010,B00000010,B00111100,B00000000},
};

const int numPatterns = 7;//this is the number of patterns you want to display
byte patterns[numPatterns][10]={space, space, space, degree, space};// the patterns order

void setup(){
  pinMode(DataPin,OUTPUT);
  pinMode(ClockPin,OUTPUT);
  pinMode(LatchPin,OUTPUT);
  //simple stuff here
 pinMode(clock,OUTPUT);
  pinMode(Reset,OUTPUT);
  //reseting the 4017 IC, you have to do this
 digitalWrite(Reset,HIGH);
  delayMicroseconds(5);
  digitalWrite(Reset,LOW);
}

void display_pattern(int loops)//int loop acts like a delay, it take 8 mSecands to scan all of the rows so int loops = 15 is a good time for it
{
  for(x=0;x<numPatterns-1;x++){ // loop over the patterns
   for (int z=0;z<8;z++){ //scrolls one bite at a time
    for(int t=0;t<loops;t++){// the delay we get with loops
     for(y=0;y<10;y++){// loops over the array of bytes
     byte temp = patterns[x][y];
     byte temp_2=patterns[x+1][y];
      digitalWrite(LatchPin, 0);
     shiftOut(DataPin, ClockPin,MSBFIRST,((temp<<z)+(temp_2>>7-z)));//writes digital outputs, Z is for how much bites it need to scroll
          digitalWrite(LatchPin, 1);
      delayMicroseconds(800);
      digitalWrite(LatchPin, 0);
     shiftOut(DataPin, ClockPin,MSBFIRST,0);
      digitalWrite(LatchPin, 1);
     digitalWrite(clock,HIGH);
     digitalWrite(clock,LOW);
   }
  }
 }
}
}

void loop(){
 
 
 //getting the voltage reading from the temperature sensor
 int reading = analogRead(sensorPin); 
 
 // converting that reading to voltage, for 3.3v arduino use 3.3
 float voltage = reading * 5.0;
 voltage /= 1024.0;
 
 float temperatureC = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset
                                               //to degrees ((volatge - 500mV) times 100)
 
 // now convert to Fahrenheight
 float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
 
 delay(1000);                                     //waiting a second
 
 int temp = temperatureF;  // or whatever from the temperature sensor
 
 char buf [4];  // holds 3 digits plus terminator
 
 sprintf (buf, "%3i", temp);  // turn temperature into a string
 
 // copy the bit patterns for each digit (digit 0, 1, 2)

 for (byte i = 0; i < 3; i++)
   memcpy (&patterns [i], &digits [buf [i] - '0'], 10);
   
 display_pattern(15);
}


Thanks
15  Using Arduino / LEDs and Multiplexing / Re: 8x10 LED Matrix with TMP36 and DS1307 Question on: October 10, 2011, 05:00:09 pm
Making it scroll the other way is still not working, sorry guys.  I just thought it would look better that way.
Pages: [1] 2