Pages: [1]   Go Down
Author Topic: Nick's Pong Clock, Arduino and Sure 2416 panels advice  (Read 862 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-wink   
Logged

Brisbane, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1121
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
/*
 * 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:
/*
  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:
dimTheClock(true);
And where you want to drive the clock brightly, use
Code:
dimTheClock(false);
Hope you can get to where you need to from here, cheers !
Geoff
Logged

"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

« Last Edit: April 15, 2012, 07:01:57 pm by Lucian1977 » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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


Cannibalised some of the button functions and added C and D. Bit primitive though smiley-grin

I still can't get figure out how to derive the hour digits to call the true and false values smiley-sad
Logged

Pages: [1]   Go Up
Jump to: