Pages: 1 2 [3] 4   Go Down
Author Topic: LED clock with different time speed  (Read 3719 times)
0 Members and 1 Guest are viewing this topic.
nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8477
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
     slow_display = TRUE;
This shouldn't have been there, I was playing with another option and forgot to take it out.

That's your compiler error but not the logic problem.

One way or another there should ba some kind of display even 000000, is that the case?
« Last Edit: September 20, 2010, 11:27:36 pm by graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

More like all segments on.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8477
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Comment out this

 
Code:
// detect falling edge of button
   // record the time and set flag to indicate we are timing for 10 secs
   if (digitalRead (BUTTON) == LOW && button_state == HIGH) {
         time_but_pressed = millis();
         button_state == LOW;
        timing = TRUE;
   }

   // if it's been 10secs since we started timing reset the flag
   if (millis () > time_but_pressed + 10 * 1000) {
      timing = FALSE;
   }

So now we're almost back to the working code. What happens?
Logged

Rob Gray aka the GRAYnomad www.robgray.com

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If comment out means take away, then we are counting seconds again.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8477
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If comment out means take away
Pretty much, you can just cut the text or wrap it in /* */ comment codes.

So there's a problem in that piece of code, put it back and remove one of the "if" blocks, see what happens, then put that back and remove the other and see what happens. Try to determine exactly which line of code causes the problem.

Meanwhile I'll have a think.
Logged

Rob Gray aka the GRAYnomad www.robgray.com

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I took away the second if and then it counts but nothing happens when I press the button. Haven't doublechecked the button though but its time for the bed.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8477
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Two problems, one small one big.

Initialise the timing variable

Code:
unsigned int timing = FALSE;

And the classic C gotcha

Code:
if (ticks = 0) {

should be

Code:
if (ticks == 0) {

Still may not be right but no chance with that.
Logged

Rob Gray aka the GRAYnomad www.robgray.com

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Still may not be right but no chance with that.
Nope, but it counts with both "if" in the code now but no action when button is pressed.
I made a testsketch for the button setup and the button is wired correctly.
Logged

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to understand and as far as I can see there is nothing saying that all displays should be counting the "ticks".
Now it acts as the previous counter ss:mm:hh

I put an extra pair of brackets after tick and now it counts 1/10th seconds but still just the first digit and then when hitting the highs pushes over to the next one.

Code:
[glow]{[/glow]if (seconds > 59) {
      seconds = 0;
      minutes++;
   }
   if (minutes > 59) {
      minutes = 0;
      hours++;
   }
   if (hours > 23) {
      hours = 0;
   }[glow]}[/glow]
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8477
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Back up a bit.

Quote
but it counts with both "if" in the code now but no action when button is pressed.

Is this still the case (without the new braces) and how fast does it count?

Quote
Now it acts as the previous counter ss:mm:hh
All it should do at present is count the same either way, just slower when the button is pressed.
« Last Edit: September 21, 2010, 09:12:23 am by graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Weird, it counts the same without the brackets. Wonder what I was looking at... So the brackets do nothing.

Code:
All it should do at present is count the same either way, just slower when the button is pressed.

No action when pressing button.
« Last Edit: September 21, 2010, 09:19:22 am by sinuslinus » Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8477
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  if (timing == FALSE) {
 [glow]     digitalWrite(latchpin, LOW);
      for (int x = 0; x < 6; x++)
         shiftOut(datapin, clockpin, MSBFIRST, segdisp[digits[x]]);
      digitalWrite(latchpin, HIGH);  [/glow]  
 } else {
      if (ticks == 0) {
         digitalWrite(latchpin, LOW);
         for (int x = 0; x < 6; x++)
            shiftOut(datapin, clockpin, MSBFIRST, segdisp[digits[x]]);
         digitalWrite(latchpin, HIGH);  
      }
   }  

If we are not timing the 10 seconds the yellow bit gets executed 10 times a sec.

If we are timing the other half runs and this tests for tick == 0, therefore it only runs every 10 times, ie every second.
Logged

Rob Gray aka the GRAYnomad www.robgray.com

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8477
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What speed is it counting at?

Quote
No action when pressing button.
Do you mean it stops or that nothing changes?
« Last Edit: September 21, 2010, 09:23:49 am by graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 34
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay,

it counts 10th of seconds.
When I press the button nothing changes.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8477
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Change

Code:
  if (timing == FALSE) {

to

Code:
timing = TRUE;
   if (timing == FALSE) {

Does it now count at 1Hz?
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Pages: 1 2 [3] 4   Go Up
Jump to: