Light Bar

Used scavanged parts from an old printer/scanner, a lithium cell from an used battery and an Attiny to make a light bar, whatever that is.


Disassembling a multifunction printer yelds lots of components. They're a goldmine for parts. Got some motors, optical sensors, momentary switches, the scanner light which is used here and a laser module.


After trying some current limited, low voltages on the pins of the scanner light bar, I realized it's a bunch of rgb leds with a common cathode. The circuit is very simple, driving the leds directly from 3 pins of the Attiny, though some resistors. A fourth pin is used with the linear potentiometer as an input.


This will be powered by a lithium cell I got from a 4 cell battery (2 cells visible here).


I used this module to take care of the charging/discharging process. Very inexpensive. However, its output is a USB type A. Had to remove the female plug and wire it directly.


The switch, potentiometer, resistors and the chip socket were mounter to some perf board.


The end result is pretty crusty but it works. The Attiny code cycles through the rainbow as the potentiometer moves. If the potentiometer is at one end it will blink police lights. And at the other end it will slowly 'breathe' white.

As the strip has 4 wires, one for each color and a common cathode, it takes RGB values. I wanted to cycle through all the color hues linearly with the potentiometer. This meant I had to convert colors from HSV to RGB. The math for that wasn't straightforward so I usurped it.

      
        void setLedColorHSV(byte h, byte s, byte v) {
          h = (h * 192) / 256;  // 0..191
          unsigned int i = h / 32;   // We want a value of 0 thru 5
          unsigned int f = (h % 32) * 8;   // 'fractional' part of 'i' 0..248 in jumps
          unsigned int sInv = 255 - s;  // 0 -> 0xff, 0xff -> 0
          unsigned int fInv = 255 - f;  // 0 -> 0xff, 0xff -> 0
          byte pv = v * sInv / 256;  // pv will be in range 0 - 255
          byte qv = v * (256 - s * f / 256) / 256;
          byte tv = v * (256 - s * fInv / 256) / 256;
          switch (i) {
          case 0:
            RedLight = v;
            GreenLight = tv;
            BlueLight = pv;
            break;
          case 1:
            RedLight = qv;
            GreenLight = v;
            BlueLight = pv;
            break;
          case 2:
            RedLight = pv;
            GreenLight = v;
            BlueLight = tv;
            break;
          case 3:
            RedLight = pv;
            GreenLight = qv;
            BlueLight = v;
            break;
          case 4:
            RedLight = tv;
            GreenLight = pv;
            BlueLight = v;
            break;
          case 5:
            RedLight = v;
            GreenLight = pv;
            BlueLight = qv;
            break;
          }
        }
      
    

The solar panels are rated for 0.5V. Two output a max of 1V under full sun, usualy less than that. The joule thief boosts it enough to light up the LEDs.