Thanks Nick, that worked great. But now I have 2 questions:
-
i have a 8x10 matrix and the words scroll across the rows (8 wide). I want to have the matrix on its side (10x8) How do I change the code to make the words (temp) scroll across the long ways (10 wide)?
-
With this code I have just the temperature scrolling. How can I add "degree symbol" and "F" after the temp?
Thanks
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}
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 = 3;//this is the number of patterns you want to display
byte patterns[numPatterns][10]={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 [3]; // holds 3 digits plus terminator
sprintf (buf, "%02i", temp); // 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 [buf [i] - '0'], 10);
display_pattern(15);
}