Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: arduino pong clock sure 2416 and ds1307 on: January 27, 2013, 05:59:59 pm
If function

I think that probably I don't need to add that
|| day != rtc[DS1307_DAY]

becouse it recall gettemp function by
|| sec != rtc[DS1307_SEC] that change each secon ?

Is it wrong ??

Next days I'll ask you about scroll text... I hope it will be possible !
2  Using Arduino / Programming Questions / Re: arduino pong clock sure 2416 and ds1307 on: January 27, 2013, 05:50:58 pm
As I promise to you here the video

Thank you. Tomorrow I'll post the code with the day and month.

In id function I added

|| day != rtc[DS1307_DAY]
But I'm not sure that is needed

Here the video



3  Using Arduino / Programming Questions / Re: arduino pong clock sure 2416 and ds1307 on: January 26, 2013, 07:50:13 pm
Tomorrow i'll post a video. I wpuld like tu put the data where is the invaders. With your suggestion there will be not problem. I hope !
4  Using Arduino / Programming Questions / Re: arduino pong clock sure 2416 and ds1307 on: January 26, 2013, 06:18:32 pm
Code:
   //update the clock if this is the first run of the show clock loop, or if the time has changed from
    //what we had stored in mins and hours vars.
    if ( show == 0 || (mins != rtc[DS1307_MIN] || (second != rtc[DS1307_SEC]) ) ) { 

      //udate mins and hours with the new time
      mins = rtc[DS1307_MIN];
      hours = rtc[DS1307_HR];
      second = rtc[DS1307_SEC];
     
      char buffer[8];

      itoa(hours,buffer,10);
      //fix - as otherwise if num has leading zero, e.g. "03" hours, itoa coverts this to chars with space "3 ".
      if (hours < 10) {
        buffer[1] = buffer[0];
        buffer[0] = '0';
      }

      //update the display
      ht1632_putchar(9,  1, buffer[0]);
      ht1632_putchar(15, 1, buffer[1]);

      plot (21,3,1); //top point
      plot (21,5,1); //bottom point

      itoa (mins, buffer, 10);
      if (mins < 10) {
        buffer[1] = buffer[0];
        buffer[0] = '0';
      }

      ht1632_putchar(23, 1, buffer[0]);
      ht1632_putchar(29, 1, buffer[1]); 
   
   
    itoa(second,buffer,10);
      //fix - as otherwise if num has leading zero, e.g. "03" hours, itoa coverts this to chars with space "3 ".
      if (second < 10) {
        buffer[1] = buffer[0];
        buffer[0] = '0';
      }   
      ht1632_puttinychar(36, 3, buffer[0]);
      ht1632_puttinychar(40, 3, buffer[1]); 
     
      }
   
//    if (scroll_invader (9,-11,49,random(1,4))) {
//      return;
//    }
//    if (scroll_invader (9,49,-11,random(1,4))) {
//      return;
//    }

    delay(500);
  }
  fade_down();
}

NOW WORKS !! ( and now I have understand the problem )

the only thing I must comment the code after the clock becouse the refresh was not every 1 second.

no problem becouse I don't want this code.

Many thanks

Daniel
5  Using Arduino / Programming Questions / Re: arduino pong clock sure 2416 and ds1307 on: January 26, 2013, 05:40:17 pm
this is how i think

there is a loop and this loop change mins on display if  rtc[1] is different DS1307_MIN

so

when inside the loop DS1307_MIN NOT EQUAL rtc[1] it change mins

this happening each minute.

I must change this loop and change second on display every second

I think in this way that I don't need to check each minute becouse it check HH and MM and at 59 second change minute ( I think )

what I should do ?

many thanks

Daniel
6  Using Arduino / Programming Questions / Re: arduino pong clock sure 2416 and ds1307 on: January 26, 2013, 04:37:23 pm
this is my error

I write here
mins = rtc[DS1307_SEC];

but I write
second = rtc[DS1307_SEC]

this is the code that I used following your suggestion:

Code:
void invaders()
{
  cls();
  byte hours = rtc[DS1307_HR];
  byte mins = rtc[DS1307_MIN];
  byte second = rtc[DS1307_SEC];
 
  //loop to display the clock for a set duration of SHOWCLOCK
  for (int show = 0; show < SHOWCLOCK ; show++) {

    gettime(); //get the time from the clock chip

    flash_seconds();

    if (button_checks())
    {
      return;
    }

    //update the clock if this is the first run of the show clock loop, or if the time has changed from
    //what we had stored in mins and hours vars.
    if ( show == 0 || (mins != rtc[1] || (second != rtc[3]) ) ) { 

      //udate mins and hours with the new time
      mins = rtc[1];
      hours = rtc[2];
      second = rtc[3];
     
      char buffer[8];

      itoa(hours,buffer,10);
      //fix - as otherwise if num has leading zero, e.g. "03" hours, itoa coverts this to chars with space "3 ".
      if (hours < 10) {
        buffer[1] = buffer[0];
        buffer[0] = '0';
      }

      //update the display
      ht1632_putchar(9,  1, buffer[0]);
      ht1632_putchar(15, 1, buffer[1]);

      plot (21,3,1); //top point
      plot (21,5,1); //bottom point

      itoa (mins, buffer, 10);
      if (mins < 10) {
        buffer[1] = buffer[0];
        buffer[0] = '0';
      }

      ht1632_putchar(23, 1, buffer[0]);
      ht1632_putchar(29, 1, buffer[1]); 
   
   
    itoa(second,buffer,10);
      //fix - as otherwise if num has leading zero, e.g. "03" hours, itoa coverts this to chars with space "3 ".
      if (second < 10) {
        buffer[1] = buffer[0];
        buffer[0] = '0';
      }   
      ht1632_puttinychar(36, 3, buffer[0]);
      ht1632_puttinychar(40, 3, buffer[1]); 
     
      }
   
    if (scroll_invader (9,-11,49,random(1,4))) {
      return;
    }
    if (scroll_invader (9,49,-11,random(1,4))) {
      return;
    }

    delay(500);
  }
  fade_down();
}


with this code second are always 01 on display

I hope to resolve

Daniel

Many thanks
7  Using Arduino / Programming Questions / Re: arduino pong clock sure 2416 and ds1307 on: January 26, 2013, 04:07:41 pm
Yes I try to guess !

I added

second = rtc[3];

becouse there were

hours = rtc[0];

and
mins = rtc [1];


I started writing

mins = rtc[DS1307_SEC] ;

but I didn't understand why it doesn't works
8  Using Arduino / Programming Questions / Re: arduino pong clock sure 2416 and ds1307 on: January 26, 2013, 01:58:29 pm
Thanks for your answer
I've just tryed this code without success

Code:
   //what we had stored in mins and hours vars.
    if ( show == 0 || (mins != rtc[1] || (second !=rtc[3]) ) ) { 

      //udate mins and hours with the new time
      mins = rtc[1];
      hours = rtc[2];
      second = rtc[3];


9  Using Arduino / Programming Questions / Re: arduino pong clock sure 2416 and ds1307 on: January 26, 2013, 11:06:05 am
On first post there is the full code of this clock

Now in INVADER FUNCTION the time is showed

HH:MM

I would like that the clock show

HH:MM ss

I hope that I answer your question
10  Using Arduino / Programming Questions / Re: arduino pong clock sure 2416 and ds1307 on: January 26, 2013, 10:43:04 am
I supposed that was an update problem but can I resolve changing min with sec ??
11  Using Arduino / Programming Questions / arduino pong clock sure 2416 and ds1307 on: January 26, 2013, 08:58:50 am
Hi people, I know I'm boring sometimes but I have a big problem and I'm stopped near the solution.

I've post the full code of this famous clock.

I would like to add a little funzion: add second near the minute.

This is the code that I added

Code:
void invaders()
{
  cls();
  byte hours = rtc[DS1307_HR];
  byte mins = rtc[DS1307_MIN];
  byte second = rtc[DS1307_SEC];
 
  //loop to display the clock for a set duration of SHOWCLOCK
  for (int show = 0; show < SHOWCLOCK ; show++) {

    gettime(); //get the time from the clock chip

    flash_seconds();

    if (button_checks())
    {
      return;
    }

    //update the clock if this is the first run of the show clock loop, or if the time has changed from
    //what we had stored in mins and hours vars.
    if ( show == 0 || (mins != rtc[1] ) ) { 

      //udate mins and hours with the new time
      mins = rtc[1];
      hours = rtc[2];
      second = rtc[3];       [color=red]<== I THINK HERE IS THE PROBLEM !![/color]
     
      char buffer[8];

      itoa(hours,buffer,10);
      //fix - as otherwise if num has leading zero, e.g. "03" hours, itoa coverts this to chars with space "3 ".
      if (hours < 10) {
        buffer[1] = buffer[0];
        buffer[0] = '0';
      }

      //update the display
      ht1632_putchar(9,  1, buffer[0]);
      ht1632_putchar(15, 1, buffer[1]);

      plot (21,3,1); //top point
      plot (21,5,1); //bottom point

      itoa (mins, buffer, 10);
      if (mins < 10) {
        buffer[1] = buffer[0];
        buffer[0] = '0';
      }

      ht1632_putchar(23, 1, buffer[0]);
      ht1632_putchar(29, 1, buffer[1]); 
   
   
    itoa(second,buffer,10);
      //fix - as otherwise if num has leading zero, e.g. "03" hours, itoa coverts this to chars with space "3 ".
      if (second < 10) {
        buffer[1] = buffer[0];
        buffer[0] = '0';
      }   
      ht1632_puttinychar(36, 3, buffer[0]);
      ht1632_puttinychar(40, 3, buffer[1]); 
     
      }

so the problem is that the second remain stopped and never change. I would like that every one second it change !!!

if I change :

Code:
second = rtc[DS1307_SEC];

second change when the minute is update.

I become crazy

Why it doesn't change every time that the buffer change ?

What is rtc[1] or rtc[2] ?

Thanks in advance

Daniel

(this version is with INVADERS )
12  Using Arduino / Programming Questions / Re: Arduino Uno ds18b20 and sure 2416 dor matrix display on: January 24, 2013, 01:34:06 pm
jhon thank you so much now with your details I've understand the meaning of it

I've changed the code here

float temp = sensors.getTempCByIndex(0);

Serial.println(temp,DEC);
      char buffer[10];
   //     itoa(temp,buffer,10);
      dtostrf(temp, 5, 2, buffer);
      ht1632_putchar(6 , 8, buffer[0]);
      ht1632_putchar(12 , 8, buffer[1]);
      ht1632_putchar(18 , 8, buffer[2]);
      ht1632_putchar(24 , 8, buffer[3]);
      ht1632_puttinychar(32 , 8, 'o');
      ht1632_putchar(37 , 8, 'C');
      delay(150); 

now works perfectly

many thanks
13  Using Arduino / Programming Questions / Re: Arduino Uno ds18b20 and sure 2416 dor matrix display on: January 24, 2013, 12:43:40 pm
many thanks for you help

here what I write

 
sensors.requestTemperatures();
//int temp = sensors.getTempCByIndex(0);
float temp = sensors.getTempCByIndex(0);

Serial.println(temp,DEC);
      char buffer[10];
   //     itoa(temp,buffer,10);
      dtostrf(temp, 8, 3, buffer);
      ht1632_putchar(6 , 8, buffer[0]);
      ht1632_putchar(12 , 8, buffer[1]);
      ht1632_putchar(18 , 8, buffer[2]);
      ht1632_putchar(24 , 8, buffer[3]);
      ht1632_puttinychar(32 , 8, 'o');
      ht1632_putchar(35 , 8, 'C');
      delay(150); 

in this way change only where the temp is writed on display

ie 22 degree is written in decimal position  _ _ , 22 °C

but without comma

where is the error ? I feel to be near to solution

Many thanks
Daniel
14  Using Arduino / Programming Questions / Re: Arduino Uno ds18b20 and sure 2416 dor matrix display on: January 24, 2013, 11:48:45 am
I understand the kind of error but I don't know what I should write.


 
sensors.requestTemperatures();

float temp = sensors.getTempCByIndex(0);

Serial.println(temp,DEC);
      char buffer[8];
      dtostrf(temp,buffer,10);                                    <====== Float temp inside to buffer in decimal type but how change it ?
      ht1632_putchar(6 , 8, buffer[0]);
      ht1632_putchar(12 , 8, buffer[1]);
 //     ht1632_putchar(12 , 8, buffer[2]);
 //     ht1632_putchar(18 , 8, buffer[3]);
      ht1632_puttinychar(19 , 8, 'o');
      ht1632_putchar(24 , 8, 'C');
      delay(150); 


temp is the variable where the sensor give the reading of temperature
buffer is where temp goes

how convert by dtostrf float temp to buffer  ?


the error is

 dtostrf(double, signed char, unsigned char, char*)

what is double ?
what is signed char ?
what is unsigned char ?
what is char* ?

many thanks

Daniel
15  Using Arduino / Programming Questions / Re: Arduino Uno ds18b20 and sure 2416 dor matrix display on: January 24, 2013, 10:48:46 am
lcd24x16_base___temperatura.cpp: In function 'void loop()':
lcd24x16_base___temperatura:112: error: invalid conversion from 'char*' to 'signed char'
c:/users/daniele/desktop/varie2/arduino-0023/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:581: error: too few arguments to function 'char* dtostrf(double, signed char, unsigned char, char*)'
lcd24x16_base___temperatura:112: error: at this point in file
Pages: [1] 2 3