Introduction: Star Jar Geiger Counter Triggered LED Decoration (2012 Remix)
This instructable builds on top of the Geiger counter triggered LED decorations I made last year. This version powers the Geiger counter from the Arduino (itself now powered from a mains adaptor, so I no longer need to keep feeding them batteries) and the LEDs now fade in and out for a more gentle effect.
What you'll need:
A Geiger counter with pulse output (I'm using the Gieger counter from MightyOhm)
A few strings of battery-operated LED decorations (I'm actually using USB-powered strings of stars from Poundland - you want something that'll comfortably run off 5V)
Arduino-based microcontroller (I'm using an UNO)
Female header (three sockets' worth)
Male header (I used an 8 pin run)
5V power supply for your Arduino (this will also power the Geiger counter)
Assortment of connecting wires (I used a combination of multi-core, ribbon cable and solid core)
Soldering equipment, wire cutters, wire strippers etc.
Insulation tape or heat shrink
Arduino IDE and an USB cable to connect to your microcontroller
A jar or other receptacle to put the LEDs in
I'm also assuming you've read the original instructable - if not, now might be a good time to do so!
What you'll need:
A Geiger counter with pulse output (I'm using the Gieger counter from MightyOhm)
A few strings of battery-operated LED decorations (I'm actually using USB-powered strings of stars from Poundland - you want something that'll comfortably run off 5V)
Arduino-based microcontroller (I'm using an UNO)
Female header (three sockets' worth)
Male header (I used an 8 pin run)
5V power supply for your Arduino (this will also power the Geiger counter)
Assortment of connecting wires (I used a combination of multi-core, ribbon cable and solid core)
Soldering equipment, wire cutters, wire strippers etc.
Insulation tape or heat shrink
Arduino IDE and an USB cable to connect to your microcontroller
A jar or other receptacle to put the LEDs in
I'm also assuming you've read the original instructable - if not, now might be a good time to do so!
Step 1: The Circuit
The diagram shows the circuit we're going to build.
First prep your LED strings by cutting off the battery pack, USB jack or whatever else they have attached to them.
This should leave you with 2 wires coming from your strings. Strip back the plastic insulation enough that you can insert the ends into the GND and 5V pins of the powered Arduino to check the polarity of the LEDs. Find which way around you need the wires to be so that the LEDs light up, and make a note of which wire must be connected to GND.
You'll also need to prep various wires by cutting to length and stripping and tinning the ends... Insulate the exposed joints with tape or heatshrink as you go.
* I used a 4-strand length of ribbon cable to run between the LED strings and the Arduino - this gives me some extra length to play with so I can house the business end out of sight away from the pretty end.
* I used 2 lengths of multi-core wire to connect between the pulse output on the Geiger counter and the Arduino
* I used 1 length of solid core wire to connect between the pulse output and the 3.3V output on the Arduino.
Also tin the contacts on the male and female headers.
Solder the length of solid core wire (red in the diagram) to one of the outer positions of the female header, then solder the multi-core wire to the other two positions (the signal wire will be in the middle, with ground on the outside - orange and black on the diagram respectively).
Leave the remaining end of the solid core wire loose - this will plug straight into the arduino.
Solder the GND wires from the LED strings together. If you are using ribbon cable to extend your reach, then solder the connected GND wires to one strand and then independently solder the +ve wires to the remaining 3 strands.
Follow the GND strand to the other end of the ribbon cable and solder this and the GND wire from the pulse output to the male header at the GND position on on the Arduino.
Solder the remaining strands of the ribbon cable to the positions on the header for PWM pins 9, 10 and 11.
Finally solder the signal (middle wire) from the pulse output to position 8.
First prep your LED strings by cutting off the battery pack, USB jack or whatever else they have attached to them.
This should leave you with 2 wires coming from your strings. Strip back the plastic insulation enough that you can insert the ends into the GND and 5V pins of the powered Arduino to check the polarity of the LEDs. Find which way around you need the wires to be so that the LEDs light up, and make a note of which wire must be connected to GND.
You'll also need to prep various wires by cutting to length and stripping and tinning the ends... Insulate the exposed joints with tape or heatshrink as you go.
* I used a 4-strand length of ribbon cable to run between the LED strings and the Arduino - this gives me some extra length to play with so I can house the business end out of sight away from the pretty end.
* I used 2 lengths of multi-core wire to connect between the pulse output on the Geiger counter and the Arduino
* I used 1 length of solid core wire to connect between the pulse output and the 3.3V output on the Arduino.
Also tin the contacts on the male and female headers.
Solder the length of solid core wire (red in the diagram) to one of the outer positions of the female header, then solder the multi-core wire to the other two positions (the signal wire will be in the middle, with ground on the outside - orange and black on the diagram respectively).
Leave the remaining end of the solid core wire loose - this will plug straight into the arduino.
Solder the GND wires from the LED strings together. If you are using ribbon cable to extend your reach, then solder the connected GND wires to one strand and then independently solder the +ve wires to the remaining 3 strands.
Follow the GND strand to the other end of the ribbon cable and solder this and the GND wire from the pulse output to the male header at the GND position on on the Arduino.
Solder the remaining strands of the ribbon cable to the positions on the header for PWM pins 9, 10 and 11.
Finally solder the signal (middle wire) from the pulse output to position 8.
Step 2: The Code
Copy this code into an Arduino sketch and upload to your microcontroller
/*
Monitors pulses from a Geiger counter to fade between 3 strings
of LED lights in sequence.
*/
const int geigerPin = 8; // connected to pulse out of Geiger counter
int lights = 1; //counter to keep track of where in the sequence we are
// PWM pis that the LED strings are connected to:
int lights1 = 9;
int lights2 = 10;
int lights3 = 11;
// maximum brightness settings for the lights - adjust to suit
int bright1 = 250;
int bright2 = 250;
int bright3 = 250;
// increments for fading in and out - larger numbers result in faster transitions
int fadeIn = 5;
int fadeOut = 2;
void setup() {
Serial.begin(9600); //Use serial for debugging
pinMode(geigerPin, INPUT);
pinMode(lights1, OUTPUT);
pinMode(lights2, OUTPUT);
pinMode(lights3, OUTPUT);
analogWrite(lights1, bright1);
analogWrite(lights2, bright2);
analogWrite(lights3, bright3);
Serial.println("setup finished");
}
int led = LOW;
void loop() {
int val = digitalRead(geigerPin);
while (val == LOW) {
// do what ever happens when there is no signal
val = digitalRead(geigerPin);
}
Serial.println("LOW");
while (val == HIGH) {
// wait for pulse to end, 100us is a long time for an Arduino
val = digitalRead(geigerPin);
}
// pulse finished
lights ++; //increment the counter
if (lights == 1){
Serial.println("lights1");
// fade out string 3, fade in string 1
for(int fadeValue = bright1 ; fadeValue >= 0; fadeValue -=fadeOut) {
analogWrite(lights1, fadeValue);
delay(30);
}
for(int fadeValue = 0 ; fadeValue <= bright3; fadeValue +=fadeIn) {
analogWrite(lights3, fadeValue);
delay(30);
}
}
if (lights == 2){
Serial.println("lights2");
// fade out string 1, fade in string 2
for(int fadeValue = bright2 ; fadeValue >= 0; fadeValue -=fadeOut) {
analogWrite(lights2, fadeValue);
delay(30);
}
for(int fadeValue = 0 ; fadeValue <= bright1; fadeValue +=fadeIn) {
analogWrite(lights1, fadeValue);
delay(30);
}
}
if (lights == 3){
Serial.println("lights3");
// fade out string 2, fade in string 3
for(int fadeValue = bright3 ; fadeValue >= 0; fadeValue -=fadeOut) {
analogWrite(lights3, fadeValue);
delay(30);
}
for(int fadeValue = 0 ; fadeValue <= bright2; fadeValue +=fadeIn) {
analogWrite(lights2, fadeValue);
delay(30);
}
lights = 0;
}
Serial.println(lights);
}
/*
Monitors pulses from a Geiger counter to fade between 3 strings
of LED lights in sequence.
*/
const int geigerPin = 8; // connected to pulse out of Geiger counter
int lights = 1; //counter to keep track of where in the sequence we are
// PWM pis that the LED strings are connected to:
int lights1 = 9;
int lights2 = 10;
int lights3 = 11;
// maximum brightness settings for the lights - adjust to suit
int bright1 = 250;
int bright2 = 250;
int bright3 = 250;
// increments for fading in and out - larger numbers result in faster transitions
int fadeIn = 5;
int fadeOut = 2;
void setup() {
Serial.begin(9600); //Use serial for debugging
pinMode(geigerPin, INPUT);
pinMode(lights1, OUTPUT);
pinMode(lights2, OUTPUT);
pinMode(lights3, OUTPUT);
analogWrite(lights1, bright1);
analogWrite(lights2, bright2);
analogWrite(lights3, bright3);
Serial.println("setup finished");
}
int led = LOW;
void loop() {
int val = digitalRead(geigerPin);
while (val == LOW) {
// do what ever happens when there is no signal
val = digitalRead(geigerPin);
}
Serial.println("LOW");
while (val == HIGH) {
// wait for pulse to end, 100us is a long time for an Arduino
val = digitalRead(geigerPin);
}
// pulse finished
lights ++; //increment the counter
if (lights == 1){
Serial.println("lights1");
// fade out string 3, fade in string 1
for(int fadeValue = bright1 ; fadeValue >= 0; fadeValue -=fadeOut) {
analogWrite(lights1, fadeValue);
delay(30);
}
for(int fadeValue = 0 ; fadeValue <= bright3; fadeValue +=fadeIn) {
analogWrite(lights3, fadeValue);
delay(30);
}
}
if (lights == 2){
Serial.println("lights2");
// fade out string 1, fade in string 2
for(int fadeValue = bright2 ; fadeValue >= 0; fadeValue -=fadeOut) {
analogWrite(lights2, fadeValue);
delay(30);
}
for(int fadeValue = 0 ; fadeValue <= bright1; fadeValue +=fadeIn) {
analogWrite(lights1, fadeValue);
delay(30);
}
}
if (lights == 3){
Serial.println("lights3");
// fade out string 2, fade in string 3
for(int fadeValue = bright3 ; fadeValue >= 0; fadeValue -=fadeOut) {
analogWrite(lights3, fadeValue);
delay(30);
}
for(int fadeValue = 0 ; fadeValue <= bright2; fadeValue +=fadeIn) {
analogWrite(lights2, fadeValue);
delay(30);
}
lights = 0;
}
Serial.println(lights);
}
Step 3: The Results
Detach your computer and power the Arduino from the mains adaptor (ensure it is set to 5V and the power jack is centre positive).
The Geiger counter should also be powered (ensure there are no batteries inserted) and the LED strings should start to fade in and out.
Tastefully arrange everything, sit back and enjoy!
The Geiger counter should also be powered (ensure there are no batteries inserted) and the LED strings should start to fade in and out.
Tastefully arrange everything, sit back and enjoy!