It's a 16 led christmas tree controlled by using 2x shift registers 74595's.
I know this isn't anything new because I've seen many kits around for this type of thing but I wanted to make my own, the PCB board was designed using Diptrace and I got the boards made by iTeadstudio,
apart from some leds, resistors and the 74595's there isn't much to the boards.
The boards are controlled using a Arduino board but I guess they will work with any chip processor, only 5 connections are needed to run the christmas tree (Power, Ground, data line, latch line and clock line).
If I had more time I would have probably included a pic and battery holder on the design, but I wanted the boards by christmas maybe next year!?...
Example video of the christmas tree in many colours, running on one Arduino (clone) board:
Code: Select all
// data pins setup...
const int clockPin = 5; // connect to "C" on pcb
const int latchPin = 6; // connect to "L" on pcb
const int dataPin = 7; // connect to "D" on pcb
// the setup function runs once when you press reset or power the board...
void setup() {
pinMode(latchPin, OUTPUT); // set our digital pins to output.
pinMode(clockPin, OUTPUT); // "
pinMode(dataPin, OUTPUT); // "
// read analog input pin 0, as pin is unconnected, this should give us a random
// value for our random seed. see web arduino.cc/en/Reference/RandomSeed
randomSeed(analogRead(0));
}
// the loop function runs over and over again forever...
// here we call each function one after the other.
void loop() {
ledRandom();
nightRider();
allLedsOn();
}
// flash all leds On/Off...
void allLedsOn(){
for (int j = 0; j < 8; j++) {
//all leds on
shiftOut(dataPin, clockPin, MSBFIRST, B11111111); // we need to send 16bits to the tree
shiftOut(dataPin, clockPin, MSBFIRST, B11111111); // 2x 8bit shift registers
digitalWrite(latchPin, HIGH); // strobe latch pin to store data
digitalWrite(latchPin, LOW);
delay(500); // delay
//all leds off
shiftOut(dataPin, clockPin, MSBFIRST, B00000000);
shiftOut(dataPin, clockPin, MSBFIRST, B00000000);
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
delay(500);
}
}
// night rider effect...
void nightRider(){
int delayTime = 80; // delay betweek each led on, change value to suit
for (int j = 0; j < 8; j++) {
shiftOut(dataPin, clockPin, MSBFIRST, B00000001 << j); // send first 8bits
shiftOut(dataPin, clockPin, MSBFIRST, B00000000); // send second 8bits
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
delay(delayTime);
}
for (int j = 0; j < 8; j++) {
shiftOut(dataPin, clockPin, MSBFIRST, B00000000);
shiftOut(dataPin, clockPin, MSBFIRST, B00000001 << j);
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
delay(delayTime);
}
for (int j = 0; j < 8; j++) {
shiftOut(dataPin, clockPin, MSBFIRST, B00000000);
shiftOut(dataPin, clockPin, MSBFIRST, B10000000 >> j);
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
delay(delayTime);
}
for (int j = 0; j < 8; j++) {
shiftOut(dataPin, clockPin, MSBFIRST, B10000000 >> j);
shiftOut(dataPin, clockPin, MSBFIRST, B00000000);
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
delay(delayTime);
}
}
// random flashing of all leds...
void ledRandom(){
int randNumber = 0; // a holder for our random num
for (int j = 0; j < 100; j++) { // loop 100 times
randNumber = random(255); // print a random number from 0 to 255
shiftOut(dataPin, clockPin, MSBFIRST, randNumber); // send first 8bits to tree
randNumber = random(255); // print a random number from 0 to 255
shiftOut(dataPin, clockPin, MSBFIRST, randNumber); // send second 8bits to tree
digitalWrite(latchPin, HIGH); // strobe latch pin to store data
digitalWrite(latchPin, LOW);
delay(randNumber = random(50, 250)); // delay between 50-250ms (random)
}
}