Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

(Solved)Again problem with matrix, this time 8x32

Status
Not open for further replies.
No errors, but nothing on serial or screen either....I did upload it :D
 
Code:
void setup() //setup runs once
{

signed char cntr;
noInterrupts(); // disable all interrupts during setup
  Wire.begin();
  RTC.begin();
//DDRD = DDRD | B11111100; //port registers used to set pin directions
DDRD = DDRD | B00011100;  //set pins as output
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 5; // compare match register 16MHz/256/2Hz -----------------------------------> delay time (lcd flicker/brightness)
TCCR1B |= (1 << WGM12); // CTC mode, free-running, clear on match
TCCR1B |= (1 << CS12); // 256 prescaler
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt

interrupts(); // enable all interrupts

} // End main

Code:
void loop() //just sitting here
{
byte secondBK = 0;
byte minuteBK = 0;
byte hourBK = 0;
byte secondLA = 0;
byte minuteLA = 0;
byte hourLA = 0;

unsigned char second, scrollctrHR= 0;
unsigned char minute, scrollctrMN = 0;
unsigned char hour, scrollctrSE = 0;

while (1){

DateTime now = RTC.now();

second = now.second();
minute = now.minute();
hour = now.hour();

clr();
charput(58,-3,0);
charput(58,2,0);
backbuffer[0] = second;
backbuffer[1] = minute;
backbuffer[2] = hour;
backbuffer[31] = second;
backbuffer[30] = minute;
backbuffer[29] = hour;


if (second != secondBK){secondLA = secondBK; secondBK=second;scrollctrSE=8;}
if (scrollctrSE > 0){scrollctrSE = Vscroll(second, secondLA,7 ,0,scrollctrSE);} else {charput((second/10),7,0);charput((second%10),15,0);}


//if (minute != minuteBK ){minuteLA = minuteBK; minuteBK =minute;scrollctrMN=8;}
//if (scrollctrMN > 0){scrollctrMN = Vscroll(minute, minuteLA, 19,0,scrollctrMN);} else {charput((minute/10),19,0);charput((minute%10),27,0);}


//if (hour != hourBK ){hourLA = hourBK; hourBK =hour;scrollctrHR=8;}
//if (scrollctrHR > 0){scrollctrHR = Vscroll(hour, hourLA, x,0,scrollctrHR);} else {charput((hour/10),x,0);charput((hour%10),x,0);}

Blit();
delay(100);

//if (virtual_timer > 0){virtual_timer--;}else{virtual_timer=10; second++;}


}
}
 
Hmm, nothing, all empty?
C:
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;

#include "FontMap.h"

int dataPin = 2; // ic: 14, ser_in Define which pins will be used for the Shift Register control
int latchPin = 3; // ic:12 silkscreen numbers!
int clockPin = 4;




unsigned char displayPointer=0; // for interrupt use...
unsigned char buffer1[32]; // buffer for screen
unsigned char backbuffer[32]; // Spare screen for drawing on
unsigned char power[8]={128,64,32,16,8,4,2,1};

ISR(TIMER1_COMPA_vect) // timer compare interrupt service routine
{
if(TIFR2) // Make sure its the timer interrupt.
{
setcolumn(displayPointer);
setdata(buffer1[displayPointer]);
digitalWrite(latchPin ,HIGH);digitalWrite(latchPin , LOW ); // STORECLOCK
if(++displayPointer==32) { displayPointer = 0; } // 32 LED row sections in total
}
TIFR2 = 0; // Clear timer 2 interrupt flag
}


void setcolumn(unsigned char col){
signed char pos;
for (pos = 32;pos>-1;pos--){
if (col == pos){digitalWrite(dataPin ,HIGH);}else {digitalWrite(dataPin ,LOW);} // PIN1 DATA pin
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}

void setdata(unsigned char dat){
unsigned char pos;
for (pos = 0;pos<8;pos++){
if (dat & 128){dat-=128;digitalWrite(dataPin ,HIGH);}else { digitalWrite(dataPin ,LOW);} // PIN1 DATA pin
dat = dat * 2;
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}
void clr() //clear
{
int addr;
for(addr=0;addr<32;addr++) // Empty display buffer
backbuffer[addr]= 0;
}

void Blit() //transfers data between display buffer to screen buffer
{
int addr=0;
noInterrupts(); // disable all interrupts during setup
for(addr=0;addr < 32;addr ++)
{
buffer1[addr] = backbuffer[addr]; // put all data from display buffer
} // to screen buffer
interrupts(); // enable all interrupts
}

void pixel(signed char x,signed char y,int cond)
{
unsigned char pix,msk;
if(x<0 || y<0) return; // outside drawing limits negative
if(x>31 || y>7) return; // outside drawing limits positive
pix = power[y];
msk = backbuffer[x]; // get exsisting data


if(cond == 2)
pix ^= msk; // XOR data to screen
if (cond == 1)
{
pix = ~pix;
pix &= msk; // AND data to screen
}
if(cond == 0)
pix |= msk; // OR data to screen
backbuffer[x] = pix; // apply changes
}

void charput(unsigned char ch, signed char x,signed char y)
{
signed char x1, y1;
unsigned char disp;
unsigned char disp2;
for( x1=0;x1<8;x1++) // eight rows
{
disp = font[x1+(ch * 8)];
for (y1 = 0; y1<8; y1++) // eight pixels
{
disp2 = disp & power[y1];
if(disp2 > 0)
{
pixel(x+x1,y+y1,0); // OR the pixel to the display buffer
}
}

}
}

void strput(const char* ch, signed char x,signed char y)
{
int addr;
while (*ch )
{
charput(*ch++,x,y); // write a string to the display buffer
x+=7;
}
}


unsigned char Vscroll(unsigned char value,unsigned char valueOL, signed char x,signed char y, unsigned char cntr1){ // Vscroll(hour, hourLA, x,y,scrollctrHR);}

charput((valueOL/10),x,(y + cntr1 - 8));
charput((valueOL%10),x+8,(y + cntr1 - 8));

charput((value/10),x,(y + cntr1 ));
charput((value%10),x+8,(y + cntr1 ));

if (cntr1 > 0){cntr1--;}
return cntr1;
}

void setup() //setup runs once
{

signed char cntr;
noInterrupts(); // disable all interrupts during setup
  Wire.begin();
  RTC.begin();
//DDRD = DDRD | B11111100; //port registers used to set pin directions
DDRD = DDRD | B00011100;  //set pins as output
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 5; // compare match register 16MHz/256/2Hz -----------------------------------> delay time (lcd flicker/brightness)
TCCR1B |= (1 << WGM12); // CTC mode, free-running, clear on match
TCCR1B |= (1 << CS12); // 256 prescaler
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt

interrupts(); // enable all interrupts

} // End main

void loop() //just sitting here
{
byte secondBK = 0;
byte minuteBK = 0;
byte hourBK = 0;
byte secondLA = 0;
byte minuteLA = 0;
byte hourLA = 0;

unsigned char second, scrollctrHR= 0;
unsigned char minute, scrollctrMN = 0;
unsigned char hour, scrollctrSE = 0;

while (1){

DateTime now = RTC.now();

second = now.second();
minute = now.minute();
hour = now.hour();

clr();
charput(58,-3,0);
charput(58,2,0);
backbuffer[0] = second;
backbuffer[1] = minute;
backbuffer[2] = hour;
backbuffer[31] = second;
backbuffer[30] = minute;
backbuffer[29] = hour;


if (second != secondBK){secondLA = secondBK; secondBK=second;scrollctrSE=8;}
if (scrollctrSE > 0){scrollctrSE = Vscroll(second, secondLA,7 ,0,scrollctrSE);} else {charput((second/10),7,0);charput((second%10),15,0);}


//if (minute != minuteBK ){minuteLA = minuteBK; minuteBK =minute;scrollctrMN=8;}
//if (scrollctrMN > 0){scrollctrMN = Vscroll(minute, minuteLA, 19,0,scrollctrMN);} else {charput((minute/10),19,0);charput((minute%10),27,0);}


//if (hour != hourBK ){hourLA = hourBK; hourBK =hour;scrollctrHR=8;}
//if (scrollctrHR > 0){scrollctrHR = Vscroll(hour, hourLA, x,0,scrollctrHR);} else {charput((hour/10),x,0);charput((hour%10),x,0);}

Blit();
delay(100);

//if (virtual_timer > 0){virtual_timer--;}else{virtual_timer=10; second++;}


}
}
 
hmm, this is puzzling to me, i cant see how there is anything different that would cause this, we know the main loop works to display seconds, but its not even displaying colons,here is a shot , all i can think of is conflict with interrupt, so i will bypass, but if this doesnt work we may need to sit back for extra help...

...dont worry about serial for now

Code:
#include <Wire.h>
#include "RTClib.h"
#include "FontMap.h"
RTC_DS1307 RTC;
int dataPin = 2; // ic: 14, ser_in Define which pins will be used for the Shift Register control
int latchPin = 3; // ic:12 silkscreen numbers!
int clockPin = 4;




unsigned char displayPointer=0; // for interrupt use...
unsigned char buffer1[32]; // buffer for screen
unsigned char backbuffer[32]; // Spare screen for drawing on
unsigned char power[8]={128,64,32,16,8,4,2,1};

ISR(TIMER1_COMPA_vect) // timer compare interrupt service routine
{
Interupt_Handler();}
}

void Interupt_Handler(void)
{
if(TIFR2) // Make sure its the timer interrupt.
{
setcolumn(displayPointer);
setdata(buffer1[displayPointer]);
digitalWrite(latchPin ,HIGH);digitalWrite(latchPin , LOW ); // STORECLOCK
if(++displayPointer==32) { displayPointer = 0; } // 32 LED row sections in total
}
TIFR2 = 0; // Clear timer 2 interrupt flag
}


void setcolumn(unsigned char col){
signed char pos;
for (pos = 32;pos>-1;pos--){
if (col == pos){digitalWrite(dataPin ,HIGH);}else {digitalWrite(dataPin ,LOW);} // PIN1 DATA pin
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}

void setdata(unsigned char dat){
unsigned char pos;
for (pos = 0;pos<8;pos++){
if (dat & 128){dat-=128;digitalWrite(dataPin ,HIGH);}else { digitalWrite(dataPin ,LOW);} // PIN1 DATA pin
dat = dat * 2;
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}
void clr() //clear
{
int addr;
for(addr=0;addr<32;addr++) // Empty display buffer
backbuffer[addr]= 0;
}

void Blit() //transfers data between display buffer to screen buffer
{
int addr=0;
//noInterrupts(); // disable all interrupts during setup
for(addr=0;addr < 32;addr ++)
{
buffer1[addr] = backbuffer[addr]; // put all data from display buffer
} // to screen buffer
//interrupts(); // enable all interrupts
}

void pixel(signed char x,signed char y,int cond)
{
unsigned char pix,msk;
if(x<0 || y<0) return; // outside drawing limits negative
if(x>31 || y>7) return; // outside drawing limits positive
pix = power[y];
msk = backbuffer[x]; // get exsisting data


if(cond == 2)
pix ^= msk; // XOR data to screen
if (cond == 1)
{
pix = ~pix;
pix &= msk; // AND data to screen
}
if(cond == 0)
pix |= msk; // OR data to screen
backbuffer[x] = pix; // apply changes
}

void charput(unsigned char ch, signed char x,signed char y)
{
signed char x1, y1;
unsigned char disp;
unsigned char disp2;
for( x1=0;x1<8;x1++) // eight rows
{
disp = font[x1+(ch * 8)];
for (y1 = 0; y1<8; y1++) // eight pixels
{
disp2 = disp & power[y1];
if(disp2 > 0)
{
pixel(x+x1,y+y1,0); // OR the pixel to the display buffer
}
}

}
}

void strput(const char* ch, signed char x,signed char y)
{
int addr;
while (*ch )
{
charput(*ch++,x,y); // write a string to the display buffer
x+=7;
}
}


unsigned char Vscroll(unsigned char value,unsigned char valueOL, signed char x,signed char y, unsigned char cntr1){ // Vscroll(hour, hourLA, x,y,scrollctrHR);}

charput((valueOL/10),x,(y + cntr1 - 8));
charput((valueOL%10),x+8,(y + cntr1 - 8));

charput((value/10),x,(y + cntr1 ));
charput((value%10),x+8,(y + cntr1 ));

if (cntr1 > 0){cntr1--;}
return cntr1;
}

void setup() //setup runs once
{

signed char cntr;
  Wire.begin();
  RTC.begin();
DDRD = DDRD | B00011100;  //set pins as output
/*
noInterrupts(); // disable all interrupts during setup
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 5; // compare match register 16MHz/256/2Hz -----------------------------------> delay time (lcd flicker/brightness)
TCCR1B |= (1 << WGM12); // CTC mode, free-running, clear on match
TCCR1B |= (1 << CS12); // 256 prescaler
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
interrupts(); // enable all interrupts
*/
} // End main

void loop() //just sitting here
{
byte secondBK = 0;
byte minuteBK = 0;
byte hourBK = 0;
byte secondLA = 0;
byte minuteLA = 0;
byte hourLA = 0;

unsigned char second, scrollctrHR= 0;
unsigned char minute, scrollctrMN = 0;
unsigned char hour, scrollctrSE = 0;

while (1){

DateTime now = RTC.now();

clr();
charput(58,-3,0);


second = now.second();
minute = now.minute();
hour = now.hour();


charput(58,2,0);
backbuffer[0] = second;
backbuffer[1] = minute;
backbuffer[2] = hour;
backbuffer[31] = second;
backbuffer[30] = minute;
backbuffer[29] = hour;


if (second != secondBK){secondLA = secondBK; secondBK=second;scrollctrSE=8;}
if (scrollctrSE > 0){scrollctrSE = Vscroll(second, secondLA,7 ,0,scrollctrSE);} else {charput((second/10),7,0);charput((second%10),15,0);}


//if (minute != minuteBK ){minuteLA = minuteBK; minuteBK =minute;scrollctrMN=8;}
//if (scrollctrMN > 0){scrollctrMN = Vscroll(minute, minuteLA, 19,0,scrollctrMN);} else {charput((minute/10),19,0);charput((minute%10),27,0);}


//if (hour != hourBK ){hourLA = hourBK; hourBK =hour;scrollctrHR=8;}
//if (scrollctrHR > 0){scrollctrHR = Vscroll(hour, hourLA, x,0,scrollctrHR);} else {charput((hour/10),x,0);charput((hour%10),x,0);}

Blit();
Interupt_Handler();

delay(100);

//if (virtual_timer > 0){virtual_timer--;}else{virtual_timer=10; second++;}


}
}
 
doggy, slight progress: (had to decrease delay() in loop() end to make it more readable)
IMG_1273.jpg
 
hmm, it seems we have 2 problems here, rtc doesnt like us using our interrupt, also I am not sure why its returning 85 for all the values, do you have it running on backup battery/ is it able to hold time yet? still 85 is a strange number, i suspect communication errror, still not too sure what to do about this...
 
Last edited:
yes, RTC is all the time with battery
 
thanks for input, thing is I don't have any 85's only arduinos and teensy's :/
 
Oops :D...
 
that is my debug view, instead of having breakpoints:


second = now.second();
minute = now.minute();
hour = now.hour();


charput(58,2,0); // indicate that we make it to this point
backbuffer[0] = second; // display rtc output
backbuffer[1] = minute;
backbuffer[2] = hour;
backbuffer[31] = second; //display rtc output symmetrically
backbuffer[30] = minute;
backbuffer[29] = hour;

85 is the seconds value, but as you can see in the corner columns on display, 85 is getting returned for the minute and hour vals too, 85 = 0b01010101

we need to get proper vals from rtc, before we can display them , then maybe we will fix that funny looking 5 & 8, and the spot they appear, last few tests prove that we are able to display and scroll what ever we pass in

personally iv never used RTC library , and dont use any library much, would rather learn the protocol and write my own instead of having to relearn the bugs to libraries every time i switch compilers, which is what i mite do if someone doesnt jump in!

Also i dont understand how dividing by m helps here when m=1:
pickNumber((now.minute() / m / 1) % 10); //ones
pickNumber((now.minute() / m / 10) % 10); //tens
 
Last edited:
k, lets try this, just a shot:

Code:
#include <Wire.h>
#include "RTClib.h"
#include "FontMap.h"
RTC_DS1307 RTC;
int dataPin = 2; // ic: 14, ser_in Define which pins will be used for the Shift Register control
int latchPin = 3; // ic:12 silkscreen numbers!
int clockPin = 4;




unsigned char displayPointer=0; // for interrupt use...
unsigned char buffer1[32]; // buffer for screen
unsigned char backbuffer[32]; // Spare screen for drawing on
unsigned char power[8]={128,64,32,16,8,4,2,1};

ISR(TIMER1_COMPA_vect) // timer compare interrupt service routine
{
Interupt_Handler(); 
}

void Interupt_Handler(void)
{
//if(TIFR1) // Make sure its the timer interrupt.
//{
setcolumn(displayPointer);
setdata(buffer1[displayPointer]);
digitalWrite(latchPin ,HIGH);digitalWrite(latchPin , LOW ); // STORECLOCK
if(++displayPointer==32) { displayPointer = 0; } // 32 LED row sections in total
//}
//TIFR1 = 0; // Clear timer 2 interrupt flag
}


void setcolumn(unsigned char col){
signed char pos;
for (pos = 32;pos>-1;pos--){
if (col == pos){digitalWrite(dataPin ,HIGH);}else {digitalWrite(dataPin ,LOW);} // PIN1 DATA pin
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}

void setdata(unsigned char dat){
unsigned char pos;
for (pos = 0;pos<8;pos++){
if (dat & 128){dat-=128;digitalWrite(dataPin ,HIGH);}else { digitalWrite(dataPin ,LOW);} // PIN1 DATA pin
dat = dat * 2;
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}
void clr() //clear
{
int addr;
for(addr=0;addr<32;addr++) // Empty display buffer
backbuffer[addr]= 0;
}

void Blit() //transfers data between display buffer to screen buffer
{
int addr=0;
//noInterrupts(); // disable all interrupts during setup
for(addr=0;addr < 32;addr ++)
{
buffer1[addr] = backbuffer[addr]; // put all data from display buffer
} // to screen buffer
//interrupts(); // enable all interrupts
}

void pixel(signed char x,signed char y,int cond)
{
unsigned char pix,msk;
if(x<0 || y<0) return; // outside drawing limits negative
if(x>31 || y>7) return; // outside drawing limits positive
pix = power[y];
msk = backbuffer[x]; // get exsisting data


if(cond == 2)
pix ^= msk; // XOR data to screen
if (cond == 1)
{
pix = ~pix;
pix &= msk; // AND data to screen
}
if(cond == 0)
pix |= msk; // OR data to screen
backbuffer[x] = pix; // apply changes
}

void charput(unsigned char ch, signed char x,signed char y)
{
signed char x1, y1;
unsigned char disp;
unsigned char disp2;
for( x1=0;x1<8;x1++) // eight rows
{
disp = font[x1+(ch * 8)];
for (y1 = 0; y1<8; y1++) // eight pixels
{
disp2 = disp & power[y1];
if(disp2 > 0)
{
pixel(x+x1,y+y1,0); // OR the pixel to the display buffer
}
}

}
}

void strput(const char* ch, signed char x,signed char y)
{
int addr;
while (*ch )
{
charput(*ch++,x,y); // write a string to the display buffer
x+=7;
}
}


unsigned char Vscroll(unsigned char value,unsigned char valueOL, signed char x,signed char y, unsigned char cntr1){ // Vscroll(hour, hourLA, x,y,scrollctrHR);}

charput((valueOL/10),x,(y + cntr1 - 8));
charput((valueOL%10),x+8,(y + cntr1 - 8));

charput((value/10),x,(y + cntr1 ));
charput((value%10),x+8,(y + cntr1 ));

if (cntr1 > 0){cntr1--;}
return cntr1;
}

void setup() //setup runs once
{

signed char cntr;
  Wire.begin();
  RTC.begin();
DDRD = DDRD | B00011100;  //set pins as output
/*
noInterrupts(); // disable all interrupts during setup
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 5; // compare match register 16MHz/256/2Hz -----------------------------------> delay time (lcd flicker/brightness)
TCCR1B |= (1 << WGM12); // CTC mode, free-running, clear on match
TCCR1B |= (1 << CS12); // 256 prescaler
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
interrupts(); // enable all interrupts
*/
} // End main

void loop() //just sitting here
{
byte secondBK = 0;
byte minuteBK = 0;
byte hourBK = 0;
byte secondLA = 0;
byte minuteLA = 0;
byte hourLA = 0;

unsigned char second, scrollctrHR= 0;
unsigned char minute, scrollctrMN = 0;
unsigned char hour, scrollctrSE = 0;

while (1){

DateTime now = RTC.now();

clr();
charput(58,-3,0);


second = now.second();
minute = now.minute();
hour = now.hour();


charput(58,2,0);
backbuffer[0] = second;
backbuffer[1] = minute;
backbuffer[2] = hour;
backbuffer[31] = now.second();
backbuffer[30] = now.minute();
backbuffer[29] = now.hour();


if (second != secondBK){secondLA = secondBK; secondBK=second;scrollctrSE=8;}
if (scrollctrSE > 0){scrollctrSE = Vscroll(second, secondLA,7 ,0,scrollctrSE);} else {charput((second/10),7,0);charput((second%10),15,0);}


//if (minute != minuteBK ){minuteLA = minuteBK; minuteBK =minute;scrollctrMN=8;}
//if (scrollctrMN > 0){scrollctrMN = Vscroll(minute, minuteLA, 19,0,scrollctrMN);} else {charput((minute/10),19,0);charput((minute%10),27,0);}


//if (hour != hourBK ){hourLA = hourBK; hourBK =hour;scrollctrHR=8;}
//if (scrollctrHR > 0){scrollctrHR = Vscroll(hour, hourLA, x,0,scrollctrHR);} else {charput((hour/10),x,0);charput((hour%10),x,0);}

Blit();
Interupt_Handler();

delay(100);

//if (virtual_timer > 0){virtual_timer--;}else{virtual_timer=10; second++;}


}
}
 
also try this one if the last one shows the 85's in the corners:

Code:
int dataPin = 2;  //IC 14  //Define which pins will be used for the Shift Register control
int latchPin = 3;  //IC 12
int clockPin = 4;  //IC 11
//OE-GND
//MR-VCC 
int m = 1;
  #include <Wire.h>
  #include "RTClib.h"
  RTC_DS1307 RTC;

void setcolumn(unsigned char col){
signed char pos;
for (pos = 32;pos>-1;pos--){
if (col == pos){digitalWrite(dataPin ,HIGH);}else {digitalWrite(dataPin ,LOW);} // PIN1 DATA pin
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}

void setdata(unsigned char dat){
unsigned char pos;
for (pos = 0;pos<8;pos++){
if (dat & 128){dat-=128;digitalWrite(dataPin ,HIGH);}else { digitalWrite(dataPin ,LOW);} // PIN1 DATA pin
dat = dat * 2;
digitalWrite(clockPin ,HIGH);digitalWrite(clockPin ,LOW);
}}


void clr() //clear
{
int addr;
for(addr=0;addr<32;addr++) // Empty display buffer
backbuffer[addr]= 0;
}

void setup()
{
  Wire.begin();
  RTC.begin();
  DDRD = DDRD | B00011100;  //set pins as output
}

void loop()
{


unsigned char second = 0;
unsigned char scrollctrHR= 0;
unsigned char minute = 0;
unsigned char scrollctrMN = 0;
unsigned char hour =0;
unsigned char scrollctrSE = 0;

 

unsigned int cntr2 = 0;



while (1){

  DateTime now = RTC.now(); 

clr();

second = now.second();
minute = now.minute();
hour = now.hour(); 



backbuffer[0] = second;
backbuffer[1] = minute;
backbuffer[2] = hour;

backbuffer[31] = now.second();
backbuffer[30] = now.minute() ;
backbuffer[29] = now.hour(); 

 Blit();


 for(cntr2=0;cntr2<100 ;cntr2++){ 
setcolumn(displayPointer);
setdata(buffer1[displayPointer]);
digitalWrite(latchPin ,HIGH);digitalWrite(latchPin , LOW ); // STORECLOCK
if(++displayPointer==32) { displayPointer = 0; } // 32 LED row sections in total
  
delay(10);
}


}}
 
85 is the seconds value, but as you can see in the corner columns on display, 85 is getting returned for the minute and hour vals too
As my previous post, this happens if you have not started the 1307 osc,, write 0 into reg 0.
seconds and CH
 
oh, sry, didn't get what you meant there, any chance you could write the line of how to do that? also should there be more than one occurrence?
 
doggy, tried you most up-date code and error (early one still showed 85):
C:
Arduino: 1.6.7 (Windows 7), TD: 1.27, Board: "Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"

C:\Users\Atte\AppData\Local\Temp\arduino_6d4799411362b184c1851ba8af345ff2\sketch_jan21a.ino: In function 'void clr()':

sketch_jan21a:31: error: 'backbuffer' was not declared in this scope

 backbuffer[addr]= 0;

 ^

C:\Users\Atte\AppData\Local\Temp\arduino_6d4799411362b184c1851ba8af345ff2\sketch_jan21a.ino: In function 'void loop()':

sketch_jan21a:70: error: 'backbuffer' was not declared in this scope

 backbuffer[0] = second;

 ^

sketch_jan21a:78: error: 'Blit' was not declared in this scope

  Blit();

  ^

sketch_jan21a:82: error: 'displayPointer' was not declared in this scope

 setcolumn(displayPointer);

  ^

sketch_jan21a:83: error: 'buffer1' was not declared in this scope

 setdata(buffer1[displayPointer]);

  ^

exit status 1
'backbuffer' was not declared in this scope

Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\LCD_Spectrum_Analyzer: C:\Users\Atte\Documents\Arduino\libraries\LCD_Spectrum_Analyzer
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\LCD_Spectrum_Analyzer: C:\Users\Atte\Documents\Arduino\libraries\LCD_Spectrum_Analyzer

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
 
OH! And i now remembered, my main idea back in the day was to use matrix as display for text, and that space you see above matrix is for 7-segments, I got them while ago, but will it make our (or should I say yours) job easier if we use 7-segments for time? It's not that big deal to expand controller board! :)
 
doesn't matter really, rite now its setup to display what we want, which we control in main loop, really its just the RTC plug that we need to figure out, which i think grandad is about to educate us both with...

once the time is able to plug in, a little alignment and we will be done, just cause i have never used a rtc clock, and any i2c i have ever done I have used my own library,
displaying text will work with this code too, after we complete the fontmap for letters.
hscroll would be easy to implement since its just a mod of vscroll, also we can set it up so you can choose which way it scrolls if you like.

for example you could add:


clr();
if (month = nov and day = 23) then strput("happy birthday!"); // which we could add a hscroll function for, to compensate for lack of space (just an exaple, has spelling mistake)
Blit();
 
Sorry Arduino not my thing, and I have not looked at all your posts ! , but if you have a call to write the seconds, ( h'00) mins, hours etc to the RTC, that should be enough , unless power is lost it will revert to the CH bit set = clock halt. ( Have some code to check the CH bit )
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top