Go Down

Topic: Nick's Pong Clock, Arduino and Sure 2416 panels advice (Read 968 times) previous topic - next topic

Lucian1977

Hi all, newbie to both these forums and Arduino in general so go easy on me  :smiley-red:

I built a pong clock going by the instructions on Nick's blog (http://123led.wordpress.com/about/) and it has all gone swimmingly. I made a few adjustments to his design but the code is near enough all his code verbatim. What I'd like to do is add some functions (like dimming the panels after 10pm) but I am finding it difficult to decipher the guts of this sketch. Does anyone know of threads where I can find some more information regarding controlling these panels? I've read a few posts of WesfW from these forums and know he laid down a lot of groundwork for the libraries that Nick's clock uses

TIA, I hope this is the right section  ;) 

strykeroz

Hi, and welcome !

Since you admit to being a newbie it might be worth checking out some info on PWM brightness control of LEDs since that's how these displays work.  A good place to start could be the Jeremy Blum youtube tutorial, here: http://youtu.be/_LCCGFSMOr4  This will give you the basic concept if you don't have that covered.

The displays do have a brightness level capability, which will work for you.  The sketch for this clock uses it in the fade functions here:
Code: [Select]
/*
* fade_down
* fade the display to black
*/
void fade_down() {
  char intensity;
  for (intensity=14; intensity >= 0; intensity--) {
    ht1632_sendcmd(0, HT1632_CMD_PWM + intensity); //send intensity commands using CS0 for display 0
    ht1632_sendcmd(1, HT1632_CMD_PWM + intensity); //send intensity commands using CS0 for display 1
    delay(FADEDELAY);
  }
  //clear the display and set it to full brightness again so we're ready to plot new stuff
  cls();
  ht1632_sendcmd(0, HT1632_CMD_PWM + 15);
  ht1632_sendcmd(1, HT1632_CMD_PWM + 15);
}


/*
* fade_up
* fade the display up to full brightness
*/
void fade_up() {
  char intensity;
  for ( intensity=0; intensity < 15; intensity++) {
    ht1632_sendcmd(0, HT1632_CMD_PWM + intensity); //send intensity commands using CS0 for display 0
    ht1632_sendcmd(1, HT1632_CMD_PWM + intensity); //send intensity commands using CS0 for display 1
    delay(FADEDELAY);
  }
}

So you can see that using the constant defined in the HT1632 library HT1632_CMD_PWM and adding the intensity value from 0 (off) to 15 (max brightness) you can set the brightness of the panels.  So that bit's pretty straightforward.

Now you just need to work out what intensity you want to run the things normally (presuming the default 15 for daytime running) and what intensity works for you as a night mode (that will require some testing I'm thinking) and add a function that sets the intensity to those values as desired.  Something like:
Code: [Select]
/*
  dim or return the displays to full brightness
*/
void dimTheClock(boolean dimIt) {
  char intensity = 15;                                               // level for full brightness
  if (dimIt) intensity = 8;                                          // choose a value that suits your taste for this
  ht1632_sendcmd(0, HT1632_CMD_PWM + intensity); //send intensity commands using CS0 for display 0
  ht1632_sendcmd(1, HT1632_CMD_PWM + intensity); //send intensity commands using CS0 for display 1
  }
}
And where you want to set your clock display dim, call it with
Code: [Select]
dimTheClock(true);
And where you want to drive the clock brightly, use
Code: [Select]
dimTheClock(false);
Hope you can get to where you need to from here, cheers !
Geoff
"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

Lucian1977

Hi Geoff,

Thank you for taking the time to reply and a great post too. I think I am tantalisingly close to what I want to achieve, I just need to figure out how to construct my argument (along the lines of if hours = > 22:00 and <06:00 then intensity = 8 else intensity = 15)

Thanks again,

Lucian


Lucian1977

#3
Apr 15, 2012, 11:27 pm Last Edit: Apr 16, 2012, 02:01 am by Lucian1977 Reason: 1
Gagh! I can't figure out how to poll the RTC to get the hours figure   :smiley-red:

Edit: I have the dimming working, oddly intensity 0 gives me the result I need, would have thought 0=off..... Does anyone know how I'd be able to take the RTC hours figure and decide if it were between 10pm and say 7am? The whole code is here I am using is here

http://dl.dropbox.com/u/1026351/pongclock_v2_28.pde


Lucian1977

I've got the dimming working on button presses like so

Code: [Select]
if(buttonC.uniquePress()){
       dimTheClock(false);
             
     }
     if(buttonD.uniquePress()){
        dimTheClock(true);
       


Cannibalised some of the button functions and added C and D. Bit primitive though :D

I still can't get figure out how to derive the hour digits to call the true and false values :(

Go Up