Laser spirograph adding beat to music function

Hey all! Thanks to the so many of you that helped me on my first post http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1231205087/0!

It's been 2 years since I completed the project and now I've put it back together cause I'd like to expand upon it. If anyone thinks this is in the wrong section just lemme know!

This is the updated project, I know it's not the prettiest thing in the world but it's easy to troubleshoot.

The wiring is just 3 copies of this diagram plus 3v power to the laser

The code that runs the fans and the pots is

int fanA= 3;
int fanB = 5;
int fanC= 6;


int fanaVal = 100;
int fanbVal = 100;
int fancVal = 100;
int potpinA = 0;
int potpinB = 1;
int potpinC = 2;

char controlChar;

void setup() {}



void loop() {
fanaVal = analogRead(potpinA);
fanbVal = analogRead(potpinB);
fancVal = analogRead(potpinC);
fanaVal = fanaVal / 4;
fanbVal = fanbVal / 4;
fancVal = fancVal / 4;

analogWrite(fanA, fanaVal);
analogWrite(fanB, fanbVal);
analogWrite(fanC,fancVal);
}

The back is simply a switch and 3 pots

And it makes patterns like these on the wall

So now that you have the back story let's get to the question!

I did another project that took three leds(RGB) and beat them to music based on this code

int bluePin = 9;
int redPin = 10;
int greenPin = 11;


// readings from the serial port
int blueVal = 0;
int redVal = 0;
int greenVal = 0;

char controlChar;

void setup() { 
  analogWrite(redPin, redVal);
  analogWrite(greenPin, greenVal);
  analogWrite(bluePin, blueVal);
  
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() >= 2) {
    controlChar = Serial.read();
    if (controlChar == 'r') {
      redVal = Serial.read();
      analogWrite(redPin, redVal);
    } else if (controlChar == 'g') {
      greenVal = Serial.read();
      analogWrite(greenPin, greenVal); 
    } else if (controlChar == 'b') {
      blueVal = Serial.read();
      analogWrite(bluePin, blueVal); 
    }
  } 
}

And this program

Basically what happened was the program would check the internal mic for whatever music you were playing and interpret the beats. Then it would send that via USB to the board which had the code above on it and the LEDs would change based on the beat.

Sooooo, anyone got any thoughts on how to take that program and those two pieces of code and meld them together so that my 3 fans(which control the spirograph's shapes) are like the RGB leds and I get different patterns based on the beat.

I understand that the fans will have to slow down and speed up so PWM doesn't work as easily on a fan as it does on an LED but maybe it only samples ever few minutes so it keeps the same pattern for the song or something like that.

Any suggestions are always helpful so feel free to take a shot!

Thanks!! -Ray-

Bump?...Please?

Here's an idea, though it might take more skill than what can be done on a workbench.

Essentially, your laser scanner works by spinning mirrors which are each tilted by a small amount. The laser bounces off of these, and due to the speed of each spinning mirror you get different Lissajous patterns. So far so good.

If you could somehow position each mirror, perfectly centered on the axis of rotation of the fan (no wobble), and have each mirror tilted on the fan by the same amount, then you could aim the laser at the direct center of each fan, and no matter what you did to the fans speed-wise, the laser wouldn't move.

Then, set up a mirror just prior to the fans (your third bounce mirror after the laser in your picture) in the same or similar manner as Richard describes, so that when the speaker cone/actuator is at "rest", the laser stays centered. When driven positive or negative, though, the pattern will change. You could quickly drive it with the beats, while you could alter the fan(s) speed on some multiple of beats or other input.

For the actuator, you could use a speaker as shown, or perhaps a small speaker from some headphones, or maybe even attach a low-mass mirror to an analog meter movement. You could use a small stepper motor, or a fast servo motor. If you really want a challenge, you could even construct your own laser galvos (not for the faint of heart, certainly - and if you managed to actually construct such devices and they were fast/accurate, you could move on with the whole laser show thing to the next level)...

Good luck - hope this helps...

:)

Wow, I like it...so is this what you were referring to with the galvos except making my own with servo motors http://www.limpkin.fr/public/.laser_box_m.jpg? Secondly, I got kinda lost on how the image would change if the 3 mirrors were centered, I see how the pattern would change though with the last mirror beating to music but if the mirrors are evenly displaced then wouldn't they provide no variation?

Thanks!

Wow, I like it...so is this what you were referring to with the galvos except making my own with servo motors http://www.limpkin.fr/public/.laser_box_m.jpg?

Those look like commercial galvos; they're fairly expensive, and the driver/amplifier/servo circuitry isn't cheap either.

Yes, you could build something using a servo; get the fastest servo you can find. It won't be as accurate as a galvo, but it will be much cheaper. You could try a stepper, but the degrees per step would have to be pretty small, or your would have to roll a "micro-stepping" system on the stepper to gain more resolution; it would probably be easier, less frustrating, and cheaper just to use a servo. Alternatively, use a speaker like already suggested, configured so that you can driver the cone (and hence the mirror) both in and out (negative/positive) - where no signal and the speaker at rest is the "centered/zero" position.

Secondly, I got kinda lost on how the image would change if the 3 mirrors were centered, I see how the pattern would change though with the last mirror beating to music but if the mirrors are evenly displaced then wouldn't they provide no variation?

The mirror on the servo/stepper would be aligned such that it centers the laser on the center points of the other mirrors (since this is likely to be a rough construction, and not a laser table - you likely won't get it perfect - it will probably project a tiny Lissajous figure). However, when you drive that mirror, you will deflect the laser left or right (or up/down - 180 degrees diametrical) of the center line, by an amount of your choosing, or proportional to the frequency, or proportional to the amplitude of the beat - whatever. Likely, this displacement along the first mirror (which can't be too much, or you will need to use larger mirrors for the second and third motor driven mirrors) will cause the size of the pattern to change (a "beat"); you could of course also change the pattern according to speed of the other mirrors, as you've already mentioned.

Another option would be to set up a mirror to completely deflect the laser away from the mirrors entirely (and into a "safe" zone - away from eyes) - to allow blanking of the beam (or pulsing of the beam to create dashed/dotted lines). Another way of doing this would be to mount a slotted interrupter disk on a motor, and drive the motor with PWM (but such a disk is difficult to stop in such a way to completely blank the beam - you could of course combine the techniques). This blanking/dasher system could also be used in conjunction or alternatively to the "pulser", according to program or whatever - to add yet another effect dimension to the show.

:)

Hmmm...I like the blinking idea, and the idea of growing the pattern...Sounds like I need to look into some motors that might better do the trick. I have no worries about the precision of anything I construct because I have access to a wood shop that's also somewhat of a metal shop as well so it's more my manufacturing ability that's limiting. I have a metal lathe, wood lathe, and steel cutting band saw(among other items) at my disposal.

Is there a particular motor anyone might suggest that I could get in duplicate(for a reasonable price lol) that might serve to make the galvo?

Another thing you cold do is to have more than one laser, say a green and a red and then use the beat detection to make "colorchanges" by turning one laser on and the other off. (or have them both on).

I would love to! I've just never found a good source for cheap lasers, I mean the lasers I've gotten are $100+ and I'm not sure I wanna spend $200-$300 right off the bat yet lol

I have a metal lathe, wood lathe, and steel cutting band saw(among other items) at my disposal.

If you have or can find access to a 4-axis milling machine (if it were CNC, even better), you could quite easily make this a very accurate system.

  1. You would need to take a short length of round aluminum rod, and turn it on the lathe until its "perfectly" round; then bore a hole the diameter of your motor shafts (more on the motors later).

  2. You could then mill a collar on the end (and later tap for a setscrew), then use the lathe or bandsaw to remove this mount from the end.

  3. Then face-mill (using the 4-axis mill) the end of the collar smooth, but on the opposite end, mill a precise 1-3 degree face from perpendicular with the shaft.

  4. Mount the mirror on this face using some 2-part epoxy (JB Weld would be my pick).

Your motors should have as high of RPM as possible; use high-RPM brushless DC (BLDC) motors meant for R/C aircraft. You use them with dedicated controllers, which means you can interface with them using the Servo library. The relatively low mass of the spinning mirror mounts will mean that PWM speed shifting can happen quickly; if you can find coreless BLDC motors, even better - much less mass on the rotor. The cost for motors and controllers are like everything else - there's a wide range available for all budgets, so shop carefully.

If you take care with your mounts (so as to allow for a degree of adjustability and flexibility of placement), and mount them on a flat surface (aluminum plate would be best, but MDF/HDF board can work in a pinch or within a budget), you could make this really accurate, and it might not cost that much more, while giving you a better finished system, with a quicker response time and flexibility.

Hmm - there's even a grain of a business idea there, too - I think (low cost laser show experimentation kits?)...

:)

Hahah! I feel like this might be a topic that keeps you up late at night(like me)! You have some great ideas and I'll do some shopping around and some thinking and I'll see what I can find! Be back with more later!

I dont think you need an expencive red laser for this. I made a spirograph (much less advanced than yours) and used an ordinary cheap red laserpointer.

Of course if you want it to work over a long distance a more powerfull laser is a good thing to have.

Dealextreme have cheap lasers and free shipping.

This for instance:

http://www.dealextreme.com/details.dx/sku.39080

I take it you're from the UK? Maybe I don't understand but what's with all the "United States Customers Only: due to new regulations enforced by the US FDA and PayPal, orders of >5mW lasers units shipped to the United States are no longer accepted. Orders that were previously accepted and unshipped will be cancelled and refunded to customers. This affects United States orders only."

on the site, is that really true? I swear I bought this 20mW online. Also, from my understanding up to a 20mW can be acceptable for this use but do you think 50mW would still be "safe"(as in, within reason it won't hurt anyone with sensibility)