Pages: 1 2 [3]   Go Down
Author Topic: 8x10 LED Matrix with TMP36 and DS1307 Question  (Read 4388 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

  And do you have any idea how to get rid of that lit LED that always goes before the temp in the display? 

I can't spot the problem, but if you put in some debugging prints you will probably see where it is.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

* Game of Life (with a shift register).txt (3.04 KB - downloaded 9 times.)
* _8x10_Matrix_Temp_and_Time.pde (9.53 KB - downloaded 8 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);

}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so how did your project went..? all done..?
i also wana do the same thing but with the 24X8 led matrix.if u finished the project...can you share the code with me..?
thanks.
Logged

Pages: 1 2 [3]   Go Up
Jump to: