Go Down

### Topic: 8x10 LED Matrix with TMP36 and DS1307 Question (Read 10911 times)previous topic - next topic

#### GeekGuyMJ

#15
##### Oct 08, 2011, 10:13 pm

Quote
How can I add "degree symbol" and "F" after the temp?

Define them exactly like you did the numbers.

I tried that, but i must have done it wrong.  This is what i tried:

Code: [Select]
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,B00001110,B00001010,B00001110,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000}
#define F          {B00000000,B01111110,B01000000,B01000000,B01111100,B01000000,B01000000,B01000000,B01000000,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 = 5;//this is the number of patterns you want to display
byte patterns[numPatterns][10]={space,degree,F};// 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

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

#### nickgammon

#16
##### Oct 08, 2011, 10:53 pm
Quote
Code: [Select]
byte patterns[numPatterns][10]={space,degree,F};// the patterns order

I see you have changed it to 2 digits (let's hope it doesn't get over 99 F eh?).

You need to allow for the two digits, eg.

Code: [Select]
byte patterns[numPatterns][10]={space, space, degree, F};// the patterns order

Quote
Here is the schematic I used:

Thats an incredibly large image file (2.25Mb). It took about 5 minutes to download for me. Haven't Instructables heard of PNG files? That was a BMP file which isn't compressed at all.
Please post technical questions on the forum, not by personal message. Thanks!

#### Grumpy_Mike

#17
##### Oct 08, 2011, 11:11 pm
Quote
I tried that, but i must have done it wrong.  This is what i tried:

So what did it look like?

#18
##### Oct 08, 2011, 11:52 pmLast Edit: Oct 08, 2011, 11:59 pm by CrossRoads Reason: 1
Ok, and you want to  move the  bytes down the page now, vs across the page.
You need to flip your loop around so that happens, and rotate the pattern with it.

Try this:
make z go up 10
make y go up to 8
swap x & y in these two

byte temp = patterns [ x ] [ y ];
byte temp_2=patterns [ x+1 ] [ y ];

What you to end up with is writing a byte (which you need as the vertical column of a letter now vs the horizontal row)
to the shift register, make it show with a low bit from the 4017, turn it off, put out the next column and make it show with the next bit low from the 4017, ...
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### GeekGuyMJ

#19
##### Oct 09, 2011, 12:55 am
Has anyone worked with a DS1307 RTC before?  I would also like to scroll the time with the temp and add some buttons to fix the time so a computer is not needed.  How can I add a clock code to the code i have?  Can this easily be done?

Quote
Code: [Select]
byte patterns[numPatterns][10]={space,degree,F};// the patterns order

I see you have changed it to 2 digits (let's hope it doesn't get over 99 F eh?).

You need to allow for the two digits, eg.

Code: [Select]
byte patterns[numPatterns][10]={space, space, degree, F};// the patterns order

sorry that image was so big.  Your idea worked though, I didn't allow for the 2 digits.  I did change the temp to 2 digits because the display always had a "0" before the 2 digit temp.  I can now display the "degrees F."  So, I'm understanding better now.  Thanks guys

#20
##### Oct 09, 2011, 01:49 am
Yes, DS1307 is easy to work with.
Talk to it via I2C commands.
There is a library for it - just as easy to send it commands directly to set its time and then read the time  back later.

Series of commands like this to set up the time:

Wire.send(new_data);                  // queue data
Wire.endTransmission();            // send it

And then this to read the time information back:

// Reset the register pointer
Wire.send(0x00);
Wire.endTransmission();

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### nickgammon

#21
##### Oct 09, 2011, 04:30 am

Your idea worked though, I didn't allow for the 2 digits.  I did change the temp to 2 digits because the display always had a "0" before the 2 digit temp.  I can now display the "degrees F."  So, I'm understanding better now.  Thanks guys

That was my fault a bit. Change:

Code: [Select]
sprintf (buf, "%03i", temp);

to:

Code: [Select]
sprintf (buf, "%3i", temp);

That still gives you 3 digits but not zero-filled.
Please post technical questions on the forum, not by personal message. Thanks!

#### GeekGuyMJ

#22
##### Oct 09, 2011, 04:55 am

Ok, and you want to  move the  bytes down the page now, vs across the page.
You need to flip your loop around so that happens, and rotate the pattern with it.

Try this:
make z go up 10
make y go up to 8
swap x & y in these two

byte temp = patterns [ x ] [ y ];
byte temp_2=patterns [ x+1 ] [ y ];

What you to end up with is writing a byte (which you need as the vertical column of a letter now vs the horizontal row)
to the shift register, make it show with a low bit from the 4017, turn it off, put out the next column and make it show with the next bit low from the 4017, ...

Ok, If I'm doing what you said right it's not working.  It makes the leds flash very fast with no discernible pattern.  I'll show the code to make sure.  And thanks for the word on the RTC.  And thanks Nick, I'll try that change.

Code: [Select]
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,B00001110,B00001010,B00001110,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000}
#define F          {B00000000,B01111110,B01000000,B01000000,B01111100,B01000000,B01000000,B01000000,B01000000,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 = 5;//this is the number of patterns you want to display
byte patterns[numPatterns][10]={space,space,degree,F};// 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<10;z++){ //scrolls one bite at a time
for(int t=0;t<loops;t++){// the delay we get with loops
for(y=0;y<8;y++){// loops over the array of bytes
byte temp = patterns[y][x];
byte temp_2=patterns[y+1][x];
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

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

#23
##### Oct 09, 2011, 05:17 am
Could be the fonts need  to be turned then also.
From this way

0xx00xx0
0xx00xx0
00x00x00
00x00x00
000xx000
000xx000
000xx000
000xx000
for example, to

00000000
xx000000
xxxx0000
0000xxxx
0000xxxx
xxxx0000
xx000000
00000000

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### nickgammon

1. 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)?

Can't you turn it sideways? Seriously.

I see from the video that it only appears to use 8 out of the 10 pixels anyway. Apart from turning it 90 degrees, having it scroll the other way is basically just going to give you two more pixels (each pixel will be on for 10 positions rather than .

I'm not sure you can easily do it otherwise. A bit more reading of the circuit indicates it is using a decade counter (hence the 10 rows) and a shift register (hence the 8 columns). I suppose it could be done but I can't quite get my head around it right now, and without the hardware to hand, any suggestions I make might be plain wrong.

Although, thinking about it, I think CrossRoads is probably right. The scrolling is really just an artifact of the way the loops are constructed. The thing is basically a multiplexed display, effectively displaying an 8 x 10 matrix of bits, the matrix changing every 15 loops (hence the scroll).

Even without rewriting the font definitions, you should be able to take what it is doing now, and shifting that into 10 bytes (ie. 80 bits) of an array. Then just read the array back "the other way". Something like that anyway.
Please post technical questions on the forum, not by personal message. Thanks!

#### GeekGuyMJ

#25
##### Oct 11, 2011, 12:00 am
Making it scroll the other way is still not working, sorry guys.  I just thought it would look better that way.

#### GeekGuyMJ

#26
##### Nov 30, 2011, 07:54 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: [Select]
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

// 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

#27
##### Dec 01, 2011, 05:34 am
Sure, see if you can follow this.
Make sure you have 10K pullups on the SDA,SCL.
Code: [Select]

/*
Test of RTC DS1307 via I2C.
Counts
Seconds,
Minutes,
Hours,
Date of the Month,
Month,
Day of the week, and
Year with Leap-Year

56 bytes battery backed RAM
Square Wave Output

Modified to Run thru IDE Serial port
*/
#include <Wire.h>

//variables
byte seconds; // bit 7 = Clock Halt, Enabled = 0, Halt = 1
// bits 6-5-3 = tens of seconds 0-6,  bits 3-2-1-0 = units of seconds, 0-9

byte minutes;  // bits 6-5-4 = tens of minutes, bits 3-2-1-0 = units of minutes

byte hours;  // 7=0. 6 = 1 for 12 hr, 0 for 24 hr.
// bit 5: 12 hr mode = AM(0)/PM(1). 24 hr mode = upper tens of hrs
// bit 4 =  lower tens of hrs, bits 3-2-1-0 = units of hours (0-9)

byte day_week = 0; // range 01-07

byte date_month = 0; // range 01-31

byte month = 0; // range 01-12

int year = 0; // upper byte 0-9, lower byte 0-9

byte sqwe = 0;  // square wave enable
// Out-0-0-Sqwe-0-0-RS1-RS0
// Out, Sqwe = 0/0 - Square wave output = 0
// Out, Sqwe = 1/0 - Square wave output = 1
// Out, Sqwe = 0/1 or 1/1 - Square wave output per RS1/RS0
// RS1/RS0 = 00 = 1 Hz
// RS1/RS0 = 01 = 4 KHz
// RS1/RS0 = 10 = 8 KHz
// RS1/RS0 = 11 = 32 KHz

byte RTC_ram_address = 0x08; //range = 08-63, 0x08-0x3F

int RTC_address = 0x68; // 1101 000

byte incomingCommand = 0;
byte RTC_write_command = 0;
byte RTC_ram_command = 0;

// use F0xx, F1xx,F2xx, F3xx, F4xx, F5xx, F6xx, F7xx
// to send one register write commands
// use E0xx to read registers back - not coded yet
// use C0xx to read RAM back - not coded yet

byte incomingRegister = 0;
byte RTC_register = 0;
byte incomingData1 = 0;
byte incomingData2 = 0;
byte new_data = 0;
byte outgoingData = 0;
int delay_time = 100;

unsigned long currentMillis = 0;
unsigned long previousMillis = 0;
unsigned long duration = 5000;

void setup() {
Wire.begin(); // no address, we are master
Serial.begin (57600);
Serial.flush();
currentMillis = millis();
}

void loop() {

if (Serial.available() >3){
incomingData1 = incomingData1 - 0x30; // convert ASCII to HEX
incomingData2 = incomingData2 - 0x30;  // convert ASCII to HEX
new_data = (incomingData1 << 4) + incomingData2;  // put the Upper/Lower nibbles together
Serial.print ("command ");
Serial.println (incomingCommand);
Serial.print ("register ");
Serial.println(incomingRegister);
Serial.print ("data1 ");
Serial.println (incomingData1, HEX);
Serial.print ("data2 ");
Serial.println (incomingData2, HEX);
Serial.print ("combined data ");
Serial.println (new_data, HEX);

}
// *******************************************
//  RTC_write_command = incomingCommand & 0xF0;  // mask off high byte
//  if (RTC_write_command == 0xF0){  // check for Write command
if ((incomingCommand == 'F') | (incomingCommand == 'f')){
incomingCommand = 0;  // reset for next pass
//    RTC_register = incomingCommand & 0x0F;  // mask off low btye
//    incomingCommand = 0;
//    new_data = incomingData;
Serial.println (" Sending a command ");
//    switch (RTC_register){
switch (incomingRegister){
case '0': // write seconds
Serial.println ("Seconds ");
Wire.send(new_data);                  // queue data
Wire.endTransmission();            // send it
delay (delay_time);
break;
case '1': // write minutes
Serial.println ("Minutes ");
Wire.send(new_data);                  // queue data
Wire.endTransmission();            // send it
delay (delay_time);
break;
case '2': // write hours
Serial.println ("Hours ");
Wire.send(new_data);                  // queue data
Wire.endTransmission();            // send it
delay (delay_time);
break;
case '3': // write day
Serial.println ("Day ");
Wire.send(new_data);                  // queue data
Wire.endTransmission();            // send it
delay (delay_time);
break;
case '4': // write date of month
Serial.println ("Day of Month ");
Wire.send(new_data);                  // queue data
Wire.endTransmission();            // send it
delay (delay_time);
break;
case '5': // write month
Serial.println ("Month ");
Wire.send(new_data);                  // queue data
Wire.endTransmission();            // send it
delay (delay_time);
break;
case '6': // write year
Serial.println ("Year ");
Wire.send(new_data);                  // queue data
Wire.endTransmission();            // send it
delay (delay_time);
break;
case '7': // write square wave
Serial.println ("Square Wave ");
Serial.println (RTC_register, HEX);
Wire.send(new_data);                  // queue data
Wire.endTransmission();            // send it
delay (delay_time);
break;
case '8': // write RAM
Serial.print ("RAM ");
Serial.println (RTC_register, HEX);
Wire.send(new_data);                  // queue data
Wire.endTransmission();            // send it
delay (delay_time);
break;
// all others,do nothing
Serial.println ("Invalid command ");
}  // end Switch
} // end if command == 'F'
// ************************************

currentMillis = millis();
if ( (currentMillis - previousMillis) >= duration){
previousMillis = currentMillis;
// Reset the register pointer
Wire.send(0x00);
Wire.endTransmission();

// Seconds
// bit 7 = Clock Halt, Enabled = 0, Halt = 1
// bits 6-5-3 = tens of seconds 0-6,  bits 3-2-1-0 = units of seconds, 0-9

// Hours
// 7=0. 6 = 1 for 12 hr, 0 for 24 hr.
// bit 5: 12 hr mode = AM(0)/PM(1). 24 hr mode = upper tens of hrs
// bit 4 =  lower tens of hrs, bits 3-2-1-0 = units of hours (0-9)

Serial.print ("Hrs " );
Serial.print (hours, HEX);
Serial.print (" Mins ");
Serial.print (minutes, HEX);
Serial.print (" Secs ");
Serial.print (seconds, HEX);
Serial.print (" Day ");
Serial.print (day_week, HEX);
Serial.print (" Date ");
Serial.print (date_month, HEX);
Serial.print (" Month ");
Serial.print (month, HEX);
Serial.print (" Year 20");
Serial.print (year, HEX);
Serial.print (" Square Wave ");
Serial.println (sqwe, HEX);

}
}
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

#### GeekGuyMJ

#28
##### Dec 01, 2011, 06:55 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?