Monday, January 19, 2015

ATTINY85 RGB light upgrade Vers. 2 - Christmas wreath

In a previous post I put together an LED RGB circuit to replace the incandescent multicolor unit.  It worked pretty well but was not bright enough.




Here is the entire test circuit, but its only using 5 volts just to test the design.
This version of the circuit uses transistors to drive the leds.  Using the transistors allows the use of high power leds(brighter!).  The circuit works, so the next step is to actually use the high power RGB led and see how bright it will be.  The LED is a 4 pin Super Flux RGB led(R50RGB-F-0160).


This is the schematic for the project.


Here is the code for the ATTiny85:
 ==================================================
//ATtiny85 RGB Color Fader
//
// change 100 to a lower value for quicker color cycling

const int redPin = 2;
const int grnPin = 1;
const int bluPin = 0;
const int sensor = 3;

void setup()
{
  pinMode(redPin, OUTPUT);   
  pinMode(grnPin, OUTPUT);   
  pinMode(bluPin, OUTPUT);
  pinMode(sensor, INPUT);
}

void loop() {
  if (analogRead(sensor) <= 200)
  {
    redtoyellow();
    yellowtogreen();
    greentocyan();
    cyantoblue();
    bluetomagenta();
    magentatored();
  }
  else if (analogRead(sensor) >= 201)
  {
    digitalWrite(redPin, LOW);
    digitalWrite(grnPin, LOW);
    digitalWrite(bluPin, LOW);
  }
}

void redtoyellow()
{
  digitalWrite(redPin, HIGH);
  digitalWrite(bluPin, LOW);

  // fade up green
  for(byte i=1; i<100; i++) {
    byte on  = i;
    byte off = 100-on;
    for( byte a=0; a<100; a++ ) {
      digitalWrite(grnPin, HIGH);
      delayMicroseconds(on);
      digitalWrite(grnPin, LOW);
      delayMicroseconds(off);
    }
  }
}

void yellowtogreen()
{
  digitalWrite(grnPin, HIGH);
  digitalWrite(bluPin, LOW);

  // fade down red
  for(byte i=1; i<100; i++) {
    byte on  = 100-i;
    byte off = i;
    for( byte a=0; a<100; a++ ) {
      digitalWrite(redPin, HIGH);
      delayMicroseconds(on);
      digitalWrite(redPin, LOW);
      delayMicroseconds(off);
    }
  }
}

void greentocyan()
{
  digitalWrite(grnPin, HIGH);
  digitalWrite(redPin, LOW);

  // fade up blue
  for(byte i=1; i<100; i++) {
    byte on  = i;
    byte off = 100-on;
    for( byte a=0; a<100; a++ ) {
      digitalWrite(bluPin, HIGH);
      delayMicroseconds(on);
      digitalWrite(bluPin, LOW);
      delayMicroseconds(off);
    }
  }
}

void cyantoblue()
{
  digitalWrite(bluPin, HIGH);
  digitalWrite(redPin, LOW);

  // fade down green
  for(byte i=1; i<100; i++) {
    byte on  = 100-i;
    byte off = i;
    for( byte a=0; a<100; a++ ) {
      digitalWrite(grnPin, HIGH);
      delayMicroseconds(on);
      digitalWrite(grnPin, LOW);
      delayMicroseconds(off);
    }
  }
}


void bluetomagenta()
{
  digitalWrite(bluPin, HIGH);
  digitalWrite(grnPin, LOW);

  // fade up red
  for(byte i=1; i<100; i++) {
    byte on  = i;
    byte off = 100-on;
    for( byte a=0; a<100; a++ ) {
      digitalWrite(redPin, HIGH);
      delayMicroseconds(on);
      digitalWrite(redPin, LOW);
      delayMicroseconds(off);
    }
  }
}

void magentatored()
{
  digitalWrite(redPin, HIGH);
  digitalWrite(grnPin, LOW);

  // fade down blue
  for(byte i=1; i<100; i++) {
    byte on  = 100-i;
    byte off = i;
    for( byte a=0; a<100; a++ ) {
      digitalWrite(bluPin, HIGH);
      delayMicroseconds(on);
      digitalWrite(bluPin, LOW);
      delayMicroseconds(off);
    }
  }
}


===============================================

Saturday, January 10, 2015

ATTINY85 RGB light upgrade Vers. 1 - Christmas wreath

During the holidays a christmas wreath decoration that has flickering lights failed.  I opened it up and found that the light bulb was blown and the motor that controls the multi colored light wheel was no longer working either.


Light and color wheel with motor
 
So I thought that I replace the faulty hardware with the attiny85 and an rgb led.  Well it worked, it just wasn't bright enough.


 




Even though the leds were mounted on a board just above the fiber optic bundle, the light was still not bright enough.  There were only three leds, 1 red, 1 blue and 1 green.



The wreath uses fiber optic strands bundled together to display the colors from the lighting.

 


I have a working circuit and a breadboarded circuit installed that works but it is too dim.  So I am working on putting more leds in the circuit to see how much more light that will provide.  Started using a DipTrace to create schematics and pcbs.

Here is the schematic used for the project, this is a Diptrace screenshot.
  The learning curve is much easier than EagleCad.  So I think I will focus on using Diptrace and but use EagleCad as needed.