Author Topic: Temperature-controlled RGB LED light (for PC case)  (Read 6292 times)

jdmlouis

  • Newbie
  • *
  • Posts: 10
Temperature-controlled RGB LED light (for PC case)
« on: February 21, 2013, 07:25:14 am »
I'm building a new PC soon, and I had the idea one evening to use one of my three Digisparks to act as the brains behind a device that would use an analog thermometer (TMP36) and a diffused RGB LED to provide in-case lighting (visible through the case's window) that changed colour depending on temperature.  I'd also want either an on-off switch for it or some way for it to detect whether the computer is on - maybe a motion sensor placed near a fan would do the trick.  I'd power it via USB.


The end-result would be simple: the case would glow red-hot if the temperature were high, and would glow blue if it were cool.


Thoughts?  Hints?  Advice?

ephphatha

  • Newbie
  • *
  • Posts: 6
Re: Temperature-controlled RGB LED light (for PC case)
« Reply #1 on: February 25, 2013, 11:49:25 pm »
Should be pretty easy :). If you're using a USB port in the computer itself to power the digispark and it's not a standby usb port (it most likely wont be) then your digispark will shut down when the computer goes into standby or shutdown.


You will need to make sure the RGB led uses PWM pins for the red and blue LEDs. The RGB shield connects red to P0 and green to P1 (blue gets a non-PWM pin P2) so that would require modification to use (either cutting traces or insulating and twisting the green and blue leads at the base of the LED so they go through the necessary holes on the PCB).


If you then use P5 to read the thermometer voltage you will have the USB pins free to also use USB communication if you'd like.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Temperature-controlled RGB LED light (for PC case)
« Reply #2 on: February 26, 2013, 12:10:20 pm »
You could also use the stock RGB shield with blue on non-pwm P2 and use the softPWM as demonstrated in the DigiBlink example

jdmlouis

  • Newbie
  • *
  • Posts: 10
Re: Temperature-controlled RGB LED light (for PC case)
« Reply #3 on: August 28, 2013, 10:08:54 am »
It's been a while - still haven't done it, but am getting back into thinking about it.


I was thinking a bit, and I cleared up my 'mission statement' for this.


I want to:
  • Measure temperature with a TMP36.
  • Dynamically convert the reading from the TMP36 into PWM values.
  • Gracefully fade the lighting along with the temperature using the values calculated through blue (B255), yellow (G255 R255), and red (R255).
So, to this end, I've decided I'd use the breakout shield as follows:
  • P0 (PWM) -> 100 Ohm Resistor -> Red LED prong
    P0 GND -> RGB LED GND prong
  • P1 (PWM) -> 180 Ohm Resistor -> Green or Blue LED prong
  • P2 EMPTY
  • P3 EMPTY
  • P4 (PWM) -> 180 Ohm Resistor -> Green or Blue LED prong
  • P5 -> TMP36 Read prong
    P5 GND -> TMP36 GND prong
    P5 5V -> TMP36 5V reference voltage prong

Before I go off half-cocked with a hot soldering iron, I just wanted to solicit a sanity check to make sure this is likely to work as intended. 


I also would really appreciate any advice on an algorithm or logic to properly scale the TMP36 reading to the PWM values so I can gradually fade from one 'temperature' colour to the next, and proportionally to the heat level.  I went to school for law, not math or computer science (though I wanted to), so be gentle and accept my apologies in advance for my ignorance.


Thanks a lot, folks!