Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LedControl library
06-01-2016, 12:32 AM,
LedControl library
Where can I find the syntax of the ledControl library? Is it close to arduino?
06-01-2016, 02:27 AM, (This post was last modified: 06-01-2016, 02:27 AM by pingotg.)
RE: LedControl library
The wiki looks to be out of date, or at least judging by the code...

Yes, it looks like Arduino. Give it a try.

(I only looked at PIC32 as you didn't say what you use.)

07-01-2016, 09:36 PM,
LedControl library

Tanks for the awnser, and sorry for the uncomplete info.

I'm using a pinguino 2550, IDE 11, win7 64bits.

Trying to make a clock with max7219 and 6 digit 7segment display. If I can get it working, will add 1 more max7219 and 6 digit to make date and rtc.
01-02-2016, 02:46 PM,
LedControl library
Hello everybody,

I'm using the example DS1307serial.pde with a pinguino 2550, bootloader v4, on W7 64bits and ide v.11, with a tiny RTC (Chinese), and a RS232 to TTL (Chinese).

Everything compiles and a message apears in the console, and it responds to commands, but with weird caracters.
Checked configurations in W7, pinguino program and console, mach.

What could be the problem?

Evem tryed with console of MikroC (Usart Terminal), the same problem.

01-02-2016, 04:34 PM,
RE: LedControl library
Would you show us your whole code ? Otherwise we cannot give you an advice.
02-02-2016, 08:21 AM, (This post was last modified: 02-02-2016, 08:27 AM by jwzumwalt.)
RE: LedControl library
(01-02-2016, 02:46 PM)fpeixeiro Wrote: Hello everybody,

I'm using the example DS1307serial.pde with a pinguino 2550, ...but with weird caracters.

Funny you mention this. I am in the process of writing a Library for the DS1302. I expected to use the DS1303 or 04 library with little or no re-write but found such a large difference that I am starting fresh. My warning is make sure you have a DS1307 if that is the library you are using, and get it working in English without conversion - then you will know you have good output going to the Chinese conversion. There is some tricky timing needed by these chips.
03-02-2016, 02:41 PM,
RE: LedControl library
Sorry gtcbreizh, this example is supplyed with pinguino's IDE,

//RTC DS1307 particulars
// case of writing : wbuffer[0] = first register address to write --- wlength = n (data bytes to send) + 1 (address byte to specify)
//                   rlength = 0 if nothing to receive
// case of reading :  wbuffer[0] = first register address to read --- wlength = 1 (address byte to specify)
//                   rlength = n (data bytes to receive)
// tested with Pinguino 4550 :
// DS 1307_SDA connected to pin0 and SCL to pin1
// DS 1307 powered  - by CR2032 lithium battery for backup
//                  - by 5V to communicate with Pinguino
// with the battery connected, once you have initiated the DS1307 using your Pinguino you don't need to keep your
// Pinguino connected
// You connect it and you open a RS232 terminal when you want to know time and date

u8 I2C_address=0xD0; // i2c 8 bits address of DS1307
u8 reg=0x00;           // first addr. reg. to write or to read
u8 i2c_tx_buffer[8];
u8 i2c_rx_buffer[7]={0,0,0,0,0,0,0};
int secondG, minuteG, hourG, dayOfWeekG, dayOfMonthG, monthG, yearG;

u8 DS1307_send_receive(u8 address, u8 *wbuffer, u8 wlength, u8 *rbuffer, u8 rlength)
   u8 i;
   u8 temp;
{do {I2C.restart;}
while(!I2C.write(address)); }
   for (i=0; i<wlength; i++)
if( rlength > 0)
   temp = address | 0x01;
do {I2C.restart();}                 // start again
while(!I2C.write(temp));             // read operation (bit 0 set to 1)
for (i=0; i<rlength; i++)           // Sequential read (auto. inc.)
rbuffer[i] = I2C_read();
if (i== (rlength-1))            // Last byte is sent ?
I2C.sendNack();             // Yes, send a No Ack to the slave (no more data to read)
I2C.sendAck();              // No, send a Ack bit (more data has to be read)

u8 decToBcd(u8 val)
 return ( (val/10*16) + (val%10) );

// Convert binary coded decimal to normal decimal numbers
u8 bcdToDec(u8 val)
 return ( (val/16*10) + (val%16) );

void setDateDs1307(u8 second,  
                  u8 minute,
                  u8 hour,
                  u8 dayOfWeek,
                  u8 dayOfMonth,
                  u8 month,
                  u8 year)
 u8 j=0;
 u8 nb_reg_towrite = 8;


void getDateDs1307(void)  
 u8 j;
 secondG     = bcdToDec(i2c_rx_buffer[0] & 0x7f);
 minuteG     = bcdToDec(i2c_rx_buffer[1] );
 hourG       = bcdToDec(i2c_rx_buffer[2]  & 0x3f);  // Need to change this if 12 hour am/pm
 dayOfWeekG  = bcdToDec(i2c_rx_buffer[3] );
 dayOfMonthG = bcdToDec(i2c_rx_buffer[4] );
 monthG      = bcdToDec(i2c_rx_buffer[5] );
 yearG       = bcdToDec(i2c_rx_buffer[6] );

void setup()
 u8 second, minute, hour, dayOfWeek, dayOfMonth, month, year;
 char carrec;
// following values to change according your time and date
 second = 0;
 minute = 34;
 hour = 12;
 dayOfWeek = 6;
 dayOfMonth = 1;
 month = 02;
 year = 16;
 Serial.printf("\n\rEnter u to initialize or update or c to continue");
 while(!Serial.available());  // a character has been received
   if(carrec=='u') // time and date to init. or update
     setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
 Serial.printf("\n\rEnter t to get time and date");

void loop()
 char carrec;
 if(Serial.available())  // a character has been received
   if(carrec=='t') // time and date to display
    Serial.printf("\n\rh: %d",hourG);
    Serial.printf(" m: %d",minuteG);
   Serial.printf(" s: %d",secondG);//....
   Serial.printf(" dd: %d",dayOfMonthG);//....
   Serial.printf(" mm: %d",monthG);//....
   Serial.printf(" yy: %d",yearG);//....
   Serial.printf(" wkday %d\n\r",dayOfWeekG);//....

Hello jwzumwalt, i'm sure the chip is a DS1307, at least is what is written, but you got me wrong, i'm not trying to convert to chinese, the hardware was bought on ebay, from china.

03-02-2016, 08:15 PM,
RE: LedControl library
I am the DS1307 example's author.
I just checked its functionning and it works well  as both reading and updating. I used a 18f4550. But for 2 years I also use it all along the day with a 18f2550 and  a lcd 16x2/i2c to display date and time.
My module is a home made one. It is important to verify with yours the SDA and SCK lines are each fitted with a resistor (2.2K for instance) linked to the 18f2550 and to 5V.
André/ gtcbreizh
11-02-2016, 08:07 PM,
Sad  RE: LedControl library

I've checked and the SDA and SCL have pull up resistors, 3.3k each.
The image atached is what hyperterminal shows what pinguino is sending.


Attached Files Thumbnail(s)
11-02-2016, 10:15 PM,
RE: LedControl library
Hello Fernando,
Would you try to run the serialprintf.pde example and show us the results in your hyperterminal screen ?
I think the problem is in the serial process, not in the i2c process. That is why I would like to see the results from a pure serial example. as serialprintf.pde.
Do you use a usb-rs232 serial adapter  or a true RS232 serial with a voltage level adapter ? 
hasta pronto

Forum Jump:

Users browsing this thread: 1 Guest(s)