clr();
strput("WOOF",0,0); //from void strput? how?
Blit();
0x00, 0x00, 0xFF, 0x11, 0x11, 0x11, 0x01, 0x00, // 70 F //this is letter "F" yes
0x00, 0x81, 0x21, 0xC1, 0xFF, 0x01, 0x01, 0x00, // 71
0x00, 0x80, 0xFF, 0x18, 0x08, 0x08, 0xFF, 0x00, // 72
0x00, 0x80, 0x81, 0x81, 0xFF, 0x81, 0x81, 0x00, // 73
0x00, 0x18, 0x28, 0x48, 0xfe, 0x08, 0x00, 0x00, // 74 //but what is these between?
0x00, 0xe4, 0xa2, 0xa2, 0xa2, 0x9c, 0x00, 0x00, // 75
0x00, 0x3c, 0x52, 0x92, 0x92, 0x0c, 0x00, 0x00, // 76
0x00, 0x80, 0x8e, 0x90, 0xa0, 0xc0, 0x00, 0x00, // 77
0x00, 0x6c, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, // 78
0x00, 0x00, 0x7E, 0x81, 0x81, 0x81, 0x7E, 0x00, // 79 O //and this is "O" letter
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //A
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //B
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //C
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //.....
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //"end"
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
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
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};
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 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 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);
}
}}
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 = 10; // 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 = 10; //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
}
}
At first, it showed 8585, then re-set time, wait while to check whether time will stay on memory, in the end it workedalso you said it worked with code from post 253, try that again , if you still get time, means we are not loosing power/time
#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, called every now and then, outside of loop
{
if(TIFR2) // Make sure its the timer interrupt.
{
setcolumn(displayPointer); //column scanning
setdata(buffer1[displayPointer]);
PORTD = (1<<PORTD3);
PORTD = (0<<PORTD3);
//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) //loop that takes care of column scanning
{
signed char pos;
for (pos = 32;pos>-1;pos--)
{
if (col == pos)
{
PORTD=(1<<PORTD2);
//digitalWrite(dataPin ,HIGH);
}
else
{
PORTD=(0<<PORTD2);
//digitalWrite(dataPin ,LOW);
} // PIN1 DATA pin
//PORTD=(1<<PORTD4);
//PORTD=(0<<PORTD4);
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;
PORTD=(1<<PORTD2);
//digitalWrite(dataPin ,HIGH);
}
else
{
PORTD=(0<<PORTD2);
}
//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;
}
}
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 = 31; // compare match register 16MHz/256/2Hz -----------------------------------> delay time (lcd flicker/brightness)
TCCR1B |= (1 << WGM12); // CTC mode, free-running, clear on match
TCCR1B |= (0 << CS10); // 256 prescaler
TCCR1B |= (0 << CS11); // 256 prescaler
TCCR1B |= (1 << CS12); // 256 prescaler
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt
interrupts(); // enable all interrupts
} // End main
void loop() //just sitting here
{
signed char scrollctr;
unsigned char numCTR;
/*clr();
strput("WOOF",0,0);
Blit();
delay(5);*/
/*for (scrollctr=-8;scrollctr<9;scrollctr++)
{
clr();
strput("WOOF",0,scrollctr);
Blit();
delay(5);
}*/
for (scrollctr=32;scrollctr>-33;scrollctr--)
{
clr();
strput("WOOF",scrollctr,0);
Blit();
delay(100);
}
/*for (numCTR=0;numCTR<10;numCTR++){
for (scrollctr=-8;scrollctr<9;scrollctr++)
{
clr();
charput(numCTR,24,scrollctr);
Blit();
delay(5);
}
}*/
}
^did we make binary clock by accident?lol, thats rite, i did the mirror cause i forgot which side backbuffer[0] was.
Post 264 is where we cut out the interrupt, strange that it did that , and that it started working suddenly, try to reupload post 264, if it shows 85 then how long till it starts working? also let it run for about a minute or 2, also it should be scrolling,dont worry about flicker...yet!
also, just as fun, check out the first column in backbuffer from your last photo, you will notice that that is your seconds value in binary format, going from bottom to top, ob00101101 = 45 , so that photo was taken at 21:47:45 <--or 9:47pm!
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?