Go Down

Topic: Arduino Lightsaber (Read 432390 times) previous topic - next topic

Canobi

The accelerometer in the pic is an MMA8452Q. I've had it quite a while, my remit at the time was to get the smallest breakout I could find that was well supported which this one is. There's plenty of documentation and it comes with example code as well.


As to a match for the WT pins, their exact title is: SKT SIL turned pin strip which look like this:



They can also be found under the heading of round pin female header socket.

jshaw

Have any of you experimented w/ the "shimmer" effect?  I'm playing around w/ the basic "fade" sketch to see if stepping one LED up while the other counts down, and adding in a bright and off to break up the pulse a bit.

Code: [Select]


int blue = 9;           // pure blue pwm
int rblue = 5;          // royal blue pwm
int brightblue = 150;   // minimum LED brightness
int brightrblue = 255;  // maximum LED brightness
int fadeAmount = 5;     // how many points to fade the LED by

void setup() {
  // declare pin 9 and 5 pints to be outputs
  pinMode(blue, OUTPUT);
  pinMode(rblue, OUTPUT);
}

void loop() {
  // set the brightness of the pins to high and low
  analogWrite(rblue, brightrblue);
  analogWrite(blue, brightblue);

  // true blue goes up while royal blue goes down
  brightblue = brightblue + fadeAmount;
  brightrblue = brightrblue - fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightblue == 150 || brightblue == 255) {
    fadeAmount = -fadeAmount ;
    // go bright and off to break up the straight pulsing effect
      analogWrite(rblue, 255);
      analogWrite(blue, 0);
  }
  // wait for 5 milliseconds to see the dimming effect
  delay(5);
}


Any other ideas on how to achieve a shimmer effect w/ 1-3 LEDs (vs a LED string)?

Canobi

Have any of you experimented w/ the "shimmer" effect?  I'm playing around w/ the basic "fade" sketch to see if stepping one LED up while the other counts down, and adding in a bright and off to break up the pulse a bit.

Code: [Select]


int blue = 9;           // pure blue pwm
int rblue = 5;          // royal blue pwm
int brightblue = 150;   // minimum LED brightness
int brightrblue = 255;  // maximum LED brightness
int fadeAmount = 5;     // how many points to fade the LED by

void setup() {
  // declare pin 9 and 5 pints to be outputs
  pinMode(blue, OUTPUT);
  pinMode(rblue, OUTPUT);
}

void loop() {
  // set the brightness of the pins to high and low
  analogWrite(rblue, brightrblue);
  analogWrite(blue, brightblue);

  // true blue goes up while royal blue goes down
  brightblue = brightblue + fadeAmount;
  brightrblue = brightrblue - fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightblue == 150 || brightblue == 255) {
    fadeAmount = -fadeAmount ;
    // go bright and off to break up the straight pulsing effect
      analogWrite(rblue, 255);
      analogWrite(blue, 0);
  }
  // wait for 5 milliseconds to see the dimming effect
  delay(5);
}


Any other ideas on how to achieve a shimmer effect w/ 1-3 LEDs (vs a LED string)?
Ooh, thanks for the reminder =)

I have but not with code. I was looking at an easy hardware solution a while back but kind of got sidetracked from that avanue of investigation when I started working on the new boards.

I did find one too but never got round to trying it out properly. Now you've brought that back to my attention I will have another look as I could use it for the Sprite.




Here's a link to the article I found that gave me the idea for the schematic above:

http://www.evilmadscientist.com/2011/does-this-led-sound-funny-to-you/

The transistor he uses is no longer available but I found two almost identical equivalents in through hole and surface mount packages. I will find out what their names are if anyone is interested.

jshaw

Ooh, thanks for the reminder =)

I have but not with code. I was looking at an easy hardware solution a while back but kind of got sidetracked from that avanue of investigation when I started working on the new boards.

I did find one too but never got round to trying it out properly. Now you've brought that back to my attention I will have another look as I could use it for the Sprite.




Here's a link to the article I found that gave me the idea for the schematic above:

http://www.evilmadscientist.com/2011/does-this-led-sound-funny-to-you/

The transistor he uses is no longer available but I found two almost identical equivalents in through hole and surface mount packages. I will find out what their names are if anyone is interested.

Getting that flicker with hw, especially if it doesn't require an LED in the circuit would be pretty cool. Although if we had to use one of those "candle LEDs" it could be neat for a crystal chamber.

Canobi

#304
Jan 03, 2016, 07:59 pm Last Edit: Jan 03, 2016, 08:38 pm by Canobi
Getting that flicker with hw, especially if it doesn't require an LED in the circuit would be pretty cool.
I did look at other alternatives but none of them would have produced a flicker as random as candle LEDs do.

Canobi

Anyone used a Leonardo before?

Found this and started wondering if it could be used for this sytem instead of the pro mini.


JakeSoft

Anyone used a Leonardo before?

Found this and started wondering if it could be used for this sytem instead of the pro mini.


Hmm, well it does have just barely enough I/O for my application. What does the price look like? It's tough to find anything cheaper than a Pro Mini which, aside from the size, was attractive to me when doing component selection.

Here is a the Arduino pinout of my Mk. IV system.


Protonerd

Have any of you experimented w/ the "shimmer" effect?  I'm playing around w/ the basic "fade" sketch to see if stepping one LED up while the other counts down, and adding in a bright and off to break up the pulse a bit.

Code: [Select]


int blue = 9;           // pure blue pwm
int rblue = 5;          // royal blue pwm
int brightblue = 150;   // minimum LED brightness
int brightrblue = 255;  // maximum LED brightness
int fadeAmount = 5;     // how many points to fade the LED by

void setup() {
  // declare pin 9 and 5 pints to be outputs
  pinMode(blue, OUTPUT);
  pinMode(rblue, OUTPUT);
}

void loop() {
  // set the brightness of the pins to high and low
  analogWrite(rblue, brightrblue);
  analogWrite(blue, brightblue);

  // true blue goes up while royal blue goes down
  brightblue = brightblue + fadeAmount;
  brightrblue = brightrblue - fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightblue == 150 || brightblue == 255) {
    fadeAmount = -fadeAmount ;
    // go bright and off to break up the straight pulsing effect
      analogWrite(rblue, 255);
      analogWrite(blue, 0);
  }
  // wait for 5 milliseconds to see the dimming effect
  delay(5);
}


Any other ideas on how to achieve a shimmer effect w/ 1-3 LEDs (vs a LED string)?
Best shimmer effect, which also works if you have single LED (or RGB) if you adjust the PWM of the drive based on the fluctuations of the sounds. How this is done is easy>
https://forum.arduino.cc/index.php?topic=361566.30
post #32

Main idea is to connect SPK- and SPK+ to one analog input each and in each loop convert the voltage on the speaker pins and adjust the drive of the LED(s) with a scaling of your choice. You can look at the video (observe the wall, the blade is simply too bright for the camera).

jshaw

Best shimmer effect, which also works if you have single LED (or RGB) if you adjust the PWM of the drive based on the fluctuations of the sounds. How this is done is easy>
https://forum.arduino.cc/index.php?topic=361566.30
post #32

Main idea is to connect SPK- and SPK+ to one analog input each and in each loop convert the voltage on the speaker pins and adjust the drive of the LED(s) with a scaling of your choice. You can look at the video (observe the wall, the blade is simply too bright for the camera).
That's a really interesting idea. I've never thought about using speakers as input...  Now if only all of my parts would arrive.

Canobi

Hmm, well it does have just barely enough I/O for my application. What does the price look like? It's tough to find anything cheaper than a Pro Mini which, aside from the size, was attractive to me when doing component selection.

Here is a the Arduino pinout of my Mk. IV system.


OK, so I'm going to bite the bullet and change the accelerometer on the PCB for the ADXL to make a new set as it seems the most popular choice.

One thing is stumping me though. I noticed the ADXL's ground pin is attached to pin 13 on the pro mini in your MkIV diagram. I must be missing something, how come it's not attached to common?

JakeSoft

OK, so I'm going to bite the bullet and change the accelerometer on the PCB for the ADXL to make a new set as it seems the most popular choice.
Oh, cool. And yes, it is. It's the GY-61 is actually the smallest I've found so far. That's what I used.

One thing is stumping me though. I noticed the ADXL's ground pin is attached to pin 13 on the pro mini in your MkIV diagram. I must be missing something, how come it's not attached to common?
Because my software is magic! ;-)

The short answer is that it has to do with the hardware I used to build my Mk IV. prototype. It was just easier that way and I knew how to make the software handle it.

T_R_O_N

#311
Jan 05, 2016, 08:37 am Last Edit: Jan 05, 2016, 08:43 am by T_R_O_N
Hello everyone

I'm new to the forum, and I've been finding this thread very interesting, I would like to thank JakeSoft for sharing his ideas with us. So far I've read about half of the 21 pages, and the information has been very helpful, but I have a few questions. Hopefully no one has asked these questions before, and if they have, I hope it's alright for me to ask them again.

Firstly what programming knowlage do I need in order to work with the Arduino? I have a good basic understanding of Java, and a small ammount of C++

Secondly I'm having trouble with finding a place that sells sound modules for the Arduino in South Africa. So far the closest thing I've been able to get is this: https://www.robotics.org.za/index.php?route=product/product&path=65_152&product_id=1249

The only other sound module I could get costs more than the Arduino Pro Micro itself. Would it be possible to build the system without using a sound module, and then have the Arduino play the sound on its own? By use of a similar system to this: https://learn.adafruit.com/trinket-audio-player/sound-playback

I would appreciate any help, it is my first time building something with an Arduino, and I hope that I am not biting off more than I can chew.

JakeSoft

Firstly what programming knowlage do I need in order to work with the Arduino? I have a good basic understanding of Java, and a small ammount of C++
There are people in this thread who have built a successful prototype who started with less. You should be fine as long as you are willing to do a lot of reading and learning on your own.

Secondly I'm having trouble with finding a place that sells sound modules for the Arduino in South Africa. So far the closest thing I've been able to get is this: https://www.robotics.org.za/index.php?route=product/product&path=65_152&product_id=1249
I always have to order my sound modules direct from China on Ebay. There are no distributors that I'm aware of in the U.S.A. either.

The only other sound module I could get costs more than the Arduino Pro Micro itself. Would it be possible to build the system without using a sound module, and then have the Arduino play the sound on its own? By use of a similar system to this: https://learn.adafruit.com/trinket-audio-player/sound-playback
Possible? Yes. Easy? Not really. You'd need to code up some kind of scheduler to handle processor loading so it was balanced between LED control, sensor I/O, and audio processing. You'd also likely have to add external storage of some kind to hold the sound files (SD card reader, for example). Add in all of these changes and the solution starts to look less and less like what is discussed here.

In this thread we pretty much stick to the WT588D as the workhorse for sound. This thread is the first and oldest on the topic, but be aware that others have surfaced lately that use different sound hardware. You may want to check some of those out too.

In this thread, racemaniac did his own audio processing. You might be able to glean something from there.
RGB Led String Lightsaber

In this thread, Protonerd used a different audio module than we use here and reports good results.
Arduino Lightsaber for/with LED String Blade


I hope that helps, and welcome to the forums.

jonnieZG

#313
Jan 05, 2016, 10:17 pm Last Edit: Jan 05, 2016, 10:23 pm by jonnieZG
@JakeSoft, is there a reason why you used a 3.3V Arduino instead a 5V version, since the WT588D is a 5V device? I am talking about the schematic in post #6. As far as I've learned by now, it is not recommended to mix 3.3V with 5V shields and vice versa... Am I missing something?

This is what I mean: http://jeelabs.org/2010/12/16/voltage-3-3-vs-5/

stinky1

Howdy,  nother FNG question:

The WT588D and -WT588DU all seem to come with pre soldered pins.
The WT588D obviously needs the little green cpu clamp style programming box.
Though I see there is a adapter cable module for the WT588D
So I figure the WT588DU does not need to be in the board because of the USB.

But I see that all the modules come with the pins pre soldered in place,  so what do
you do?  De solder the pins so you can then attach the wires?  Or attach the wires to
the pins?

Also should I get a 16M or 32M one.  I want to order but If I have one doubt its a no go.


Go Up