Arduino Laser Show with Full XY Control

 by nothinglabs
Contest WinnerFeatured

Step 30: Change the Code!

arduino.jpg
You didn't do all that work to just display the demo - it's time to make your own laser show!

Note: If you made it to this step without downloading the source code - it's in a zip file attached to Step 26.

Here's a few of the included routines:

laser_on()
Turns laser on.

laser_off()
Turns laser off.

sendto (X,Y)
Sends laser to X and Y coordinates.  The coordinate system is 256 x 256 - but the real resolution is lower (maybe half) that.

draw_string("STRING", X, Y, COUNT)
Draws a text string at X,Y for COUNT times.  Uppercase characters, numbers and some punctuation is supported (see code).

move_scale = X
Sets scaling (font size) used by draw_string.  Setting it to 2.8 provides enough room for 5 characters.
 
marquee("HELLO WORLD", CHARACTERS)
Draws a scrolling marquee CHARACTERS long - text is autoscaled to fit (4 to 7 characters long works best).

Now for a little tutorial - look for this code at around line 90:

//put your laser control code here!

void loop()
{

    //run the default laser show demo
    demo();

}


The Arduino runs any code in this section over and over again.  Try changing it to:

void loop() 
{

     move_scale = 2.8;        //sets text size

    draw_string("LASER", 1, 1, 10);
    draw_string("TEST", 1, 1, 10);

    marquee("LET'S DRAW A STAR!!!", 5) ;

   //draw a star 15 times
    for (int loop = 0; loop < 15; loop ++)
    {
       laser_off();
       sendto (85,10);
       laser_on();
       sendto (150,130);
       sendto (0,40);
       sendto (170,40);
       sendto (20,130);
       sendto (85,10);
    }

}


There are a bunch of variables you can tweak and a few more routines documented in the code.

Dig in and have fun!  If you mess things up - you can always re-download the code and start over.


 
Remove these adsRemove these ads by Signing Up
DBender says: Jun 23, 2012. 12:04 PM
what is the purpose of 8ohm resistors? thank you
nothinglabs (author) in reply to DBenderJun 23, 2012. 3:26 PM
it's not 100% clear what the 8 ohm resistors do - but I think they do two things:

Provide a more stable load for the transistors to drive
Reduce back-EMF

The effect is definitely to increase how much the speakers are driven and the quality of the rendering.

I came up with this configuration more by experimenting than anything else.

If you aren't getting good results - I would be sure the resistors you are using are rated to handle the power.
DonQuijote in reply to nothinglabsAug 1, 2012. 9:18 AM
if that would be true (it was my first assumption as i read through your setup)

since you basically only drive your speakers with either positive, or zero voltage, you could replace the resistors with a diode. the diode should point its arrow the other way than the normal flow of current through your circuit. that would drain away the back-emf, but not also the driving voltage. i assume you would find that you will have increased the gain of your diy galvos, and possibly need to adjust for that....

i don't have the time or resources to try this out anytime in the near future, but i would sure love if you'd try out my suggestion and tell me about the results.
nothinglabs (author) in reply to DonQuijoteAug 2, 2012. 10:49 AM
yup - the resistors seem to be eating the back-emf.

I actually have things setup using a diodes now - works great - and uses a little less power.

Had to make a few tweaks to some variables to get good results - but this is probably a better setup.

I'm going to add some notes to the project (and parts numbers for diodes / etc.)
abend in reply to nothinglabsAug 1, 2012. 8:38 AM
If the resistors are handling back-EMF from the speaker coils, you might have better luck with a diode, particularly a schottkey diode wired as a snubber/flyback diode. Wire-wound resistors strike me as not-so-great snubbers because their construction makes them slightly inductive.

http://en.wikipedia.org/wiki/Flyback_diode
nothinglabs (author) in reply to abendAug 2, 2012. 10:50 AM
yes - the resistors definitely deal with the back emf.

turns out diodes (if big enough) can work as well.

going to update the project notees in the next day or so to reflect this option.
DBender says: Jun 24, 2012. 6:14 PM
Finalized the entire assembly is working but still not have a good definition have difficulty reading. what should I do to calibrate?
nothinglabs (author) in reply to DBenderJun 24, 2012. 9:59 PM
i would look at step 29. if you slow things down - at some point you should improve quality

if that doesn't help - i would try other speakers
DBender says: Jun 24, 2012. 6:15 PM
what should I do to be drawing only one star?
nothinglabs (author) in reply to DBenderJun 24, 2012. 9:57 PM
look at the code
DBender says: Jun 23, 2012. 2:46 PM
It seems to me that one of the weakest galvos moves which can be, is this normal?
DBender says: Jun 23, 2012. 12:02 PM
Hello friend, I switched to TIP120 transistors, and still has the problem, the speakers do not move with force, it could be?
DBender says: Jun 21, 2012. 10:27 AM
Hello friend, thanks for the reply, I do not really used TIP120, I use a mosfet, I'll try subtitulos by TIP120, thank you.
DBender says: Jun 20, 2012. 3:07 PM
Hello friend, I'm having problems with the power to the speaker, he is moving slightly out of power, the laser is okay, but the channels 56 are low, what should I do? thank you...
nothinglabs (author) in reply to DBenderJun 21, 2012. 12:27 AM
are you using the tip120 - or another transistor?

also - are you using the resistors across the speaker leads?
DBender in reply to nothinglabsJun 21, 2012. 10:26 AM
Hello friend, thanks for the reply, I do not really used TIP120, I use a mosfet, I'll try subtitulos by TIP120, thank you.
DBender says: Jun 19, 2012. 10:06 PM
Thank you for answering my friend, I can replace the TIP120 transistor why else?
nothinglabs (author) in reply to DBenderJun 21, 2012. 12:25 AM
the tip120 is a special kind of transistor known as a darlington driver.

It combones two transistors in one to acheive higher "gain" - this lets it amplify the tiny arduino signal to somehtng powerful enough to move the speaker without additional supporting electronics.

other darlington drivers may work - but I suggest using the tip120's as they are tested and fairly cheap
DBender says: Jun 18, 2012. 1:28 PM
Hello, I'm from Brazil and found your magnificent project.
Well I wonder if you could provide me the complete code for my arduino UNO.
I would be grateful for your help.
Thanks to more
nothinglabs (author) in reply to DBenderJun 19, 2012. 11:05 AM
see step #26 for the download link - should work fine on the UNO.

good luck!

-Rich
henridutoit says: Mar 20, 2011. 8:47 AM
hello,

can you send me please the full code for my arduino ?


henri,
nothinglabs (author) in reply to henridutoitMar 20, 2011. 12:14 PM
should be attached to step 26 - let me know if you have any trouble with it.

Good luck!

-Rich
henridutoit in reply to nothinglabsMar 21, 2011. 1:36 PM
hello rich,


i have a error when i program my arduino ,

sketch_mar21a.cpp: In function 'void loop()':
sketch_mar21a:6: error: 'demo' was not declared in this scope
sketch_mar21a.cpp: At global scope:
sketch_mar21a:10: error: 'The' does not name a type


bye,


henri
can you send me the FULL program to put on my arduino ?
please ?


thanks .
nothinglabs (author) in reply to henridutoitMar 21, 2011. 2:54 PM
I just verified that the .zip file attached to step 26 compiles fine.

From your error - it sounds like you might be just using the code listed in this step - which isn't complete. It's just showing how you can modify the code that's included in step 26.

I would redownload the code attached to step 26 - and try it again.

If that doesn't work - I'd make sure you have the latest Arduino software.

Let me know if this helps or not.

Good luck!

-Rich
henridutoit in reply to nothinglabsMar 22, 2011. 5:57 AM
hello,


can you send me the FULL PROGRAM FOR MY ARDUINO PLEASE ?


thanks you


henri,
northconnor in reply to henridutoitMar 28, 2011. 7:01 PM
Henri, look in step 26 of this instructable. There is the FULL PROGRAM FOR YOUR ARDUINO. attached in a zip file, not just the text shown in step 30.
mattadamsnet in reply to northconnorFeb 22, 2012. 9:26 PM
:) Love it,

I WONDER IF HE GOT THE CLUE !?!?!?

The .pde in the .zip on step 26 complies with 0 errors using arduino IDE v21

Very Nice Instructable,
Keep up the nice work.

Matt
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!