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