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

Status
Not open for further replies.
Sorry for delay, got OLED screens and couple LCD's too, played with them and managed to place RTC clock to 0.96" OLED hehe...
But,as for this subject, errors popped out. I haven't yet touched RTC library for this project.

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 setTime()':

sketch_jan21a:55: error: 'months' was not declared in this scope

 Serial.println(months[month-1]);

  ^

sketch_jan21a:62: error: 'days' was not declared in this scope

 Serial.println(days[weekday-1]);

  ^

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

Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\Ardumoto: C:\Users\Atte\Documents\Arduino\libraries\Ardumoto
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\Bluetooth: C:\Users\Atte\Documents\Arduino\libraries\Bluetooth
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\OBD-II_UART: C:\Users\Atte\Documents\Arduino\libraries\OBD-II_UART
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\reorder_table_creator: C:\Users\Atte\Documents\Arduino\libraries\reorder_table_creator
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\Serial7SegmentDisplay: C:\Users\Atte\Documents\Arduino\libraries\Serial7SegmentDisplay
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\sevenseg: C:\Users\Atte\Documents\Arduino\libraries\sevenseg
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\Ardumoto: C:\Users\Atte\Documents\Arduino\libraries\Ardumoto
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\Bluetooth: C:\Users\Atte\Documents\Arduino\libraries\Bluetooth
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\OBD-II_UART: C:\Users\Atte\Documents\Arduino\libraries\OBD-II_UART
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\reorder_table_creator: C:\Users\Atte\Documents\Arduino\libraries\reorder_table_creator
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\Serial7SegmentDisplay: C:\Users\Atte\Documents\Arduino\libraries\Serial7SegmentDisplay
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\sevenseg: C:\Users\Atte\Documents\Arduino\libraries\sevenseg
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\Ardumoto: C:\Users\Atte\Documents\Arduino\libraries\Ardumoto
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\Bluetooth: C:\Users\Atte\Documents\Arduino\libraries\Bluetooth
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\OBD-II_UART: C:\Users\Atte\Documents\Arduino\libraries\OBD-II_UART
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\reorder_table_creator: C:\Users\Atte\Documents\Arduino\libraries\reorder_table_creator
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\Serial7SegmentDisplay: C:\Users\Atte\Documents\Arduino\libraries\Serial7SegmentDisplay
Invalid library found in C:\Users\Atte\Documents\Arduino\libraries\sevenseg: C:\Users\Atte\Documents\Arduino\libraries\sevenseg

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
 
Hmm, when entering serial mode, all leds are lit and says only "Th" trying to say thank you?
 
ya, or Thursday, but i deleted both of those, could be cause of our clock settings, serial port may have bad timing, lets try to cut programming time/serial functions completely


Code:
#include <Wire.h>
#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;


const int DS1307 = 0x68; // Address of DS1307 see data sheets

// Initializes all values:
byte second = 1;
byte minute = 1;
byte hour = 1;
byte weekday = 0;
byte monthday = 0;
byte month = 0;
byte year = 0;


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
}



byte decToBcd(byte val) {
return ((val/10*16) + (val%10));
}
byte bcdToDec(byte val) {
return ((val/16*10) + (val%16));
}


// This set of codes is allows input of data
void setTime() {
Serial.print("Please enter the current year, 00-99. - ");
year = readByte();
Serial.println(year);
Serial.print("Please enter the current month, 1-12. - ");
month = readByte();
Serial.println(month);
Serial.print("Please enter the current day of the month, 1-31. - ");
monthday = readByte();
Serial.println(monthday);
Serial.println("Please enter the current day of the week, 1-7.");
Serial.print("1 Sun | 2 Mon | 3 Tues | 4 Weds | 5 Thu | 6 Fri | 7 Sat - ");
weekday = readByte();
Serial.println(weekday]);
Serial.print("Please enter the current hour in 24hr format, 0-23. - ");
hour = readByte();
Serial.println(hour);
Serial.print("Please enter the current minute, 0-59. - ");
minute = readByte();
Serial.println(minute);
second = 0;
Serial.println("The data has been entered.");
// The following codes transmits the data to the RTC
Wire.beginTransmission(DS1307);
Wire.write(byte(0));
Wire.write(decToBcd(second));
Wire.write(decToBcd(minute));
Wire.write(decToBcd(hour));
Wire.write(decToBcd(weekday));
Wire.write(decToBcd(monthday));
Wire.write(decToBcd(month));
Wire.write(decToBcd(year));
Wire.write(byte(0));
Wire.endTransmission();
// Ends transmission of data
}


byte readByte() {
while (!Serial.available()) delay(10);
byte reading = 0;
byte incomingByte = Serial.read();
while (incomingByte != '\n') {
if (incomingByte >= '0' && incomingByte <= '9')
reading = reading * 10 + (incomingByte - '0');
else;
incomingByte = Serial.read();
}
Serial.flush();
return reading;
}


void printTime() {
char buffer[3];
const char* AMPM = 0;
readTime();
Serial.print(weekday);
Serial.print(" ");
Serial.print(month);
Serial.print(" ");
Serial.print(monthday);
Serial.print(", 20");
Serial.print(year);
Serial.print(" ");
if (hour > 12) {
hour -= 12;
AMPM = " PM";
}
else AMPM = " AM";
Serial.print(hour);
Serial.print(":");
sprintf(buffer, "%02d", minute);
Serial.print(buffer);
Serial.println(AMPM);
}


void readTime() {
Wire.beginTransmission(DS1307);
Wire.write(byte(0));
Wire.endTransmission();
Wire.requestFrom(DS1307, 7);
second = bcdToDec(Wire.read());
minute = bcdToDec(Wire.read());
hour = bcdToDec(Wire.read());
weekday = bcdToDec(Wire.read());
monthday = bcdToDec(Wire.read());
month = bcdToDec(Wire.read());
year = bcdToDec(Wire.read());
}


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
DDRD = DDRD | B11111100; //port registers used to set pin directions
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


Wire.begin();

delay(2000); // This delay allows the MCU to read the current date and time.



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 RTCsim = 16;

unsigned char scrollctrHR= 0;
unsigned char scrollctrMN = 0;
unsigned char scrollctrSE = 0;

clr();
charput(58,0,0);
charput(58,2,0);

Blit();
delay(300);

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


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


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

Blit();
delay(300);


if (RTCsim != 0){RTCsim --;}else {
RTCsim =16;
if (second <60){second++;}else{second = 0;}


}

}
 
Last edited:
...maybe not!
Code:
#include <Wire.h>
#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;


const int DS1307 = 0x68; // Address of DS1307 see data sheets

// Initializes all values:
byte second = 1;
byte minute = 1;
byte hour = 1;
byte weekday = 0;
byte monthday = 0;
byte month = 0;
byte year = 0;


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
}



byte decToBcd(byte val) {
return ((val/10*16) + (val%10));
}
byte bcdToDec(byte val) {
return ((val/16*10) + (val%16));
}


// This set of codes is allows input of data
void setTime() {
Serial.print("Please enter the current year, 00-99. - ");
year = readByte();
Serial.println(year);
Serial.print("Please enter the current month, 1-12. - ");
month = readByte();
Serial.println(month);
Serial.print("Please enter the current day of the month, 1-31. - ");
monthday = readByte();
Serial.println(monthday);
Serial.println("Please enter the current day of the week, 1-7.");
Serial.print("1 Sun | 2 Mon | 3 Tues | 4 Weds | 5 Thu | 6 Fri | 7 Sat - ");
weekday = readByte();
Serial.println(weekday]);
Serial.print("Please enter the current hour in 24hr format, 0-23. - ");
hour = readByte();
Serial.println(hour);
Serial.print("Please enter the current minute, 0-59. - ");
minute = readByte();
Serial.println(minute);
second = 0;
Serial.println("The data has been entered.");
// The following codes transmits the data to the RTC
Wire.beginTransmission(DS1307);
Wire.write(byte(0));
Wire.write(decToBcd(second));
Wire.write(decToBcd(minute));
Wire.write(decToBcd(hour));
Wire.write(decToBcd(weekday));
Wire.write(decToBcd(monthday));
Wire.write(decToBcd(month));
Wire.write(decToBcd(year));
Wire.write(byte(0));
Wire.endTransmission();
// Ends transmission of data
}


byte readByte() {
while (!Serial.available()) delay(10);
byte reading = 0;
byte incomingByte = Serial.read();
while (incomingByte != '\n') {
if (incomingByte >= '0' && incomingByte <= '9')
reading = reading * 10 + (incomingByte - '0');
else;
incomingByte = Serial.read();
}
Serial.flush();
return reading;
}


void printTime() {
char buffer[3];
const char* AMPM = 0;
readTime();
Serial.print(weekday);
Serial.print(" ");
Serial.print(month);
Serial.print(" ");
Serial.print(monthday);
Serial.print(", 20");
Serial.print(year);
Serial.print(" ");
if (hour > 12) {
hour -= 12;
AMPM = " PM";
}
else AMPM = " AM";
Serial.print(hour);
Serial.print(":");
sprintf(buffer, "%02d", minute);
Serial.print(buffer);
Serial.println(AMPM);
}


void readTime() {
Wire.beginTransmission(DS1307);
Wire.write(byte(0));
Wire.endTransmission();
Wire.requestFrom(DS1307, 7);
second = bcdToDec(Wire.read());
minute = bcdToDec(Wire.read());
hour = bcdToDec(Wire.read());
weekday = bcdToDec(Wire.read());
monthday = bcdToDec(Wire.read());
month = bcdToDec(Wire.read());
year = bcdToDec(Wire.read());
}


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
DDRD = DDRD | B11111100; //port registers used to set pin directions
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 scrollctrHR= 0;
unsigned char scrollctrMN = 0;
unsigned char scrollctrSE = 0;

clr();
charput(58,0,0);
charput(58,2,0);

Blit();
delay(300);

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


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


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

Blit();
delay(300);
}
 
Last edited:
Serial is empty, but every now and then couple zeroes pop to quite middle of matrix
 
I cut out serial port for now, lets double check to see if scroll still works
Code:
#include <Wire.h>
#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;


const int DS1307 = 0x68; // Address of DS1307 see data sheets

// Initializes all values:
byte second = 1;
byte minute = 1;
byte hour = 1;
byte weekday = 0;
byte monthday = 0;
byte month = 0;
byte year = 0;


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
}



byte decToBcd(byte val) {
return ((val/10*16) + (val%10));
}
byte bcdToDec(byte val) {
return ((val/16*10) + (val%16));
}


// This set of codes is allows input of data
void setTime() {
Serial.print("Please enter the current year, 00-99. - ");
year = readByte();
Serial.println(year);
Serial.print("Please enter the current month, 1-12. - ");
month = readByte();
Serial.println(month);
Serial.print("Please enter the current day of the month, 1-31. - ");
monthday = readByte();
Serial.println(monthday);
Serial.println("Please enter the current day of the week, 1-7.");
Serial.print("1 Sun | 2 Mon | 3 Tues | 4 Weds | 5 Thu | 6 Fri | 7 Sat - ");
weekday = readByte();
Serial.println(weekday]);
Serial.print("Please enter the current hour in 24hr format, 0-23. - ");
hour = readByte();
Serial.println(hour);
Serial.print("Please enter the current minute, 0-59. - ");
minute = readByte();
Serial.println(minute);
second = 0;
Serial.println("The data has been entered.");
// The following codes transmits the data to the RTC
Wire.beginTransmission(DS1307);
Wire.write(byte(0));
Wire.write(decToBcd(second));
Wire.write(decToBcd(minute));
Wire.write(decToBcd(hour));
Wire.write(decToBcd(weekday));
Wire.write(decToBcd(monthday));
Wire.write(decToBcd(month));
Wire.write(decToBcd(year));
Wire.write(byte(0));
Wire.endTransmission();
// Ends transmission of data
}


byte readByte() {
while (!Serial.available()) delay(10);
byte reading = 0;
byte incomingByte = Serial.read();
while (incomingByte != '\n') {
if (incomingByte >= '0' && incomingByte <= '9')
reading = reading * 10 + (incomingByte - '0');
else;
incomingByte = Serial.read();
}
Serial.flush();
return reading;
}


void printTime() {
char buffer[3];
const char* AMPM = 0;
readTime();
Serial.print(weekday);
Serial.print(" ");
Serial.print(month);
Serial.print(" ");
Serial.print(monthday);
Serial.print(", 20");
Serial.print(year);
Serial.print(" ");
if (hour > 12) {
hour -= 12;
AMPM = " PM";
}
else AMPM = " AM";
Serial.print(hour);
Serial.print(":");
sprintf(buffer, "%02d", minute);
Serial.print(buffer);
Serial.println(AMPM);
}


void readTime() {
Wire.beginTransmission(DS1307);
Wire.write(byte(0));
Wire.endTransmission();
Wire.requestFrom(DS1307, 7);
second = bcdToDec(Wire.read());
minute = bcdToDec(Wire.read());
hour = bcdToDec(Wire.read());
weekday = bcdToDec(Wire.read());
monthday = bcdToDec(Wire.read());
month = bcdToDec(Wire.read());
year = bcdToDec(Wire.read());
}


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
DDRD = DDRD | B11111100; //port registers used to set pin directions
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 scrollctrHR= 0;
unsigned char scrollctrMN = 0;
unsigned char scrollctrSE = 0;


unsigned char virtual_timer = 10;


while (1){

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

if (second != secondBK){secondLA = secondBK; secondBK=second;scrollctrSE=8;}
if (scrollctrSE > 0){scrollctrSE = Vscroll(second, secondLA, 3,0,scrollctrSE);} else {charput((second/10),3,0);charput((second%10),11,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(300);

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


}
}
 
Last edited:
Serial is empty, both of those earlier dots and zeros are now visible , slightly shifted to left.
 
remember where there were two zeroes? those now scroll, counting up, 00, 01, 02, 03 etc....but very slowly, would take too long video to upload :/ and, serial is empty
 
doggy, with this I got hours & minutes on screen, only bit flickery, is there any help on this?
C:
//counts from 9999 seconds down

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
unsigned long previousMillis = 0;  // will store last time LED was updated
const long interval = 1000;  // interval at which to blink (milliseconds)
int del = 10;
int columns = 0;
int counter = 10000;
int m = 1;
  #include <Wire.h>
  #include "RTClib.h"
  RTC_DS1307 RTC;

static uint8_t  numbers [80] =  //numbers stored here
{
  0x00, 0x7c, 0xa2, 0x92, 0x8a, 0x7c, 0x00, 0x00, // 0
  0x00, 0x42, 0xfe, 0x02, 0x00, 0x00, 0x00, 0x00, // 1
  0x00, 0x42, 0x86, 0x8a, 0x92, 0x62, 0x00, 0x00, // 2
  0x00, 0x84, 0x82, 0xa2, 0xd2, 0x8c, 0x00, 0x00, // 3
  0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 4
  0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 5
  0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 6
  0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 7
  0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 8
  0x00, 0x60, 0x92, 0x92, 0x94, 0x78, 0x00, 0x00, // 9
};




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

void loop()
{
  DateTime now = RTC.now();  
  unsigned long currentMillis = millis();  //take value from millis() each loop
  if (currentMillis - previousMillis >= interval)
  {
  previousMillis = currentMillis;
  if (counter == 0)
  {
  counter = 10000; //reset to start
  }
  else
  counter--;  //if not 0, keep on counting
  }
 
  columns++; //at each loop run, increment by one
  if (columns > 8)
  {
  columns = 0;  //if counter exceeds 8, reset it
  }
  PORTD = B00000000;  //turn latch low
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << columns);  //Send the data #2  (what columns to power)
  shiftOut(dataPin, clockPin, MSBFIRST, B00000000);  //Send the data #2  (what columns to power)
  shiftOut(dataPin, clockPin, MSBFIRST, B00000000);  //Send the data #2  (what columns to power)
  shiftOut(dataPin, clockPin, MSBFIRST, B00000000);  //Send the data #2  (what columns to power)
  pickNumber((now.minute() / m / 1) % 10);  //ones
  PORTD = B00001000;  //turn latch on->show screen
 
  PORTD = B00000000;  //turn latch low
  shiftOut(dataPin, clockPin, MSBFIRST, B00000000);  //Send the data #2  (what columns to power)
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << columns);  //Send the data #2  (what columns to power)
  shiftOut(dataPin, clockPin, MSBFIRST, B00000000);  //Send the data #2  (what columns to power)
  shiftOut(dataPin, clockPin, MSBFIRST, B00000000);  //Send the data #2  (what columns to power)
  pickNumber((now.minute() / m / 10) % 10);  //tens
  PORTD = B00001000;  //turn latch on->show screen
 
  PORTD = B00000000;  //turn latch low
  shiftOut(dataPin, clockPin, MSBFIRST, B00000000);  //Send the data #2  (what columns to power)
  shiftOut(dataPin, clockPin, MSBFIRST, B00000000);  //Send the data #2  (what columns to power)
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << columns);  //Send the data #2  (what columns to power)
  shiftOut(dataPin, clockPin, MSBFIRST, B00000000);  //Send the data #2  (what columns to power)
  pickNumber((now.hour() / m / 1) % 10);  //hundreds
  PORTD = B00001000;  //turn latch on->show screen
 
  PORTD = B00000000;  //turn latch low
  shiftOut(dataPin, clockPin, MSBFIRST, B00000000);  //Send the data #2  (what columns to power)
  shiftOut(dataPin, clockPin, MSBFIRST, B00000000);  //Send the data #2  (what columns to power)
  shiftOut(dataPin, clockPin, MSBFIRST, B00000000);  //Send the data #2  (what columns to power)
  shiftOut(dataPin, clockPin, MSBFIRST, 1 << columns);  //Send the data #2  (what columns to power)
  pickNumber((now.hour() / m / 10) % 10);  //thousands
  PORTD = B00001000;  //turn latch on->show screen
}

void pickNumber( int count)  //pick numbers from array, at start of whole code
{
  switch (count)
  {
  case 1: shiftOut(dataPin, clockPin, LSBFIRST, numbers[columns + 8]); break;  //0
  case 2: shiftOut(dataPin, clockPin, LSBFIRST, numbers[columns + 16]); break;  //1
  case 3: shiftOut(dataPin, clockPin, LSBFIRST, numbers[columns + 24]); break;  //2
  case 4: shiftOut(dataPin, clockPin, LSBFIRST, numbers[columns + 32]); break;  //3
  case 5: shiftOut(dataPin, clockPin, LSBFIRST, numbers[columns + 40]); break;  //4
  case 6: shiftOut(dataPin, clockPin, LSBFIRST, numbers[columns + 48]); break;  //5
  case 7: shiftOut(dataPin, clockPin, LSBFIRST, numbers[columns + 56]); break;  //6
  case 8: shiftOut(dataPin, clockPin, LSBFIRST, numbers[columns + 64]); break;  //7
  case 9: shiftOut(dataPin, clockPin, LSBFIRST, numbers[columns + 72]); break;  //8
  case 10: shiftOut(dataPin, clockPin, LSBFIRST, numbers[columns + 80]); break;  //9
  default: shiftOut(dataPin, clockPin, LSBFIRST, numbers[columns + 0]); break;  //9
  }
}
 
is that original code? working with RTC library?
adding a delay at the end of main code will help flicker...

also if you add RTC library to my code, will work , all you would need to do is add lines to put second = now.second; or change all the "second" to now.second
 
Yes, this code is original before ian's , (although he helped with that too!)
Library indeed helped, will try to implement it to your code also!
Had to ''repair'' code in my cube, it has LCD screen showing RTC and there wasn't any leading zeroes and placed also date & month as characters (Wednesday, February)
 
this code is ready for you to include RTC library function, i rem-ed out the minute and hour so we can align the seconds and colons first, i figure you want it to show like this: HH:MM:SS



Code:
#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
DDRD = DDRD | B11111100; //port registers used to set pin directions
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 scrollctrHR= 0;
unsigned char scrollctrMN = 0;
unsigned char scrollctrSE = 0;


//unsigned char virtual_timer = 10;


while (1){

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

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

if (second != secondBK){secondLA = secondBK; secondBK=second;scrollctrSE=8;}
if (scrollctrSE > 0){scrollctrSE = Vscroll(second, secondLA, 14,0,scrollctrSE);} else {charput((second/10),14,0);charput((second%10),23,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(300);

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


}
}
 
Last edited:
hmm, here i tried to implement RTC, but still get errors
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
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 scrollctrHR= 0;
unsigned char scrollctrMN = 0;
unsigned char scrollctrSE = 0;


//unsigned char virtual_timer = 10;


while (1){

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

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

if (second != secondBK){secondLA = secondBK; secondBK=second;scrollctrSE=8;}
if (scrollctrSE > 0){scrollctrSE = Vscroll(second, secondLA, 3,0,scrollctrSE);} else {charput((second/10),3,0);charput((second%10),11,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(300);

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


}
}
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 loop()':

sketch_jan21a:172: error: 'second' was not declared in this scope

 second() = now.second();

  ^

sketch_jan21a:172: error: 'now' was not declared in this scope

 second() = now.second();

  ^

sketch_jan21a:173: error: 'minute' was not declared in this scope

 minute() = now.minute();

  ^

sketch_jan21a:174: error: 'hour' was not declared in this scope

 hour() = now.hour();

  ^

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

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
 
oops deleted too much:

if you still get error on second, we may not be able to use it and may need to stick with this screen format: HH:MM
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){

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

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

if (second != secondBK){secondLA = secondBK; secondBK=second;scrollctrSE=8;}
if (scrollctrSE > 0){scrollctrSE = Vscroll(second, secondLA, 3,0,scrollctrSE);} else {charput((second/10),3,0);charput((second%10),11,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(300);

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


}
}
 
still getting erros :/?
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
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){

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

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

if (second != secondBK){secondLA = secondBK; secondBK=second;scrollctrSE=8;}
if (scrollctrSE > 0){scrollctrSE = Vscroll(second, secondLA, 3,0,scrollctrSE);} else {charput((second/10),3,0);charput((second%10),11,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(300);

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


}
}
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 loop()':

sketch_jan21a:168: error: 'now' was not declared in this scope

 minute = now.minute();

  ^

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

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
 
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,14,0);

if (second != secondBK){secondLA = secondBK; secondBK=second;scrollctrSE=8;}
if (scrollctrSE > 0){scrollctrSE = Vscroll(second, secondLA, 15,0,scrollctrSE);} else {charput((second/10),15,0);charput((second%10),23,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++;}


}
}
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…