loading
  • XY - 2 dimensional laser scanning
  • 2x 35mm 0.9° stepper motors - 400 steps/rev
  • Automatic mirror calibration
  • Remote serial control (via bluetooth)
  • Auto mode
  • Remote control app with GUI
  • Open Source

Download:

github.com/stanleyondrus

stanleyprojects.com

Step 1: Theory

Laser projectors can be divided into two main categories. Either they use a diffraction glass/foil to project a pattern or they have a system which moves laser beam in XY axis directions. The second option usually looks much better because it is possible to program the pattern to be projected. While in the first case, the laser beam is being diffracted and projects a static image, in the second one, the laser still consists of just one beam, that moves very fast. If this movement is fast enough, we perceive it as a pattern because of persistence of vision (POV). This is usually done by having two perpendicular mirrors, each capable of moving the laser beam in one axis. By combining them, it is possible to position the laser beam to the exact location.

For professional applications, galvanometer scanners are usually used. Some of these scanners are capable of doing 60kpps (kilo point per second). That means, they can position the laser beam to 60000 different locations during 1 second. This creates a really smooth projection without the stroboscopic effect. However, they can be really expensive. I have used the stepper motors, which is the cheap, not so fast, alternative.

The laser draws the pattern by orbiting the lines over and over at really high speed. Sometimes there are multiple parts of the pattern that are not connected together. In this example, each letter is separated, however when the laser moves from one letter to another one, it creates an unwanted line. This is solved by a technology called blanking. The whole idea behind is, that the laser is switched of when moving from one, to another pattern. This is done by a high-speed controlling unit, which needs to be synchronized with the scanning system.

Step 2: Obtaining Components

In the list bellow you can find the components I used and the links where I bought them.

    And then some material and tools you can find at home. Hopefully ;)

    • Mirror (the best is a metallic mirror like HDD Platter)
    • Aluminium sheet
    • Snips
    • Hot Glue (or Pattex Repair Express )
    • Wires
    • Pliers
    • Drill (or scissors in my case :D)
    • Box (e.g. Junction Box)

    Step 3: Mounting Steppers

    Aluminium sheet needed to be cut and bent into the proper shape. Then holes were drilled and steppers attached.

    Step 4: Laser Blanking + Mirror Calibration

    Motor Shield has a small prototyping area that was used for two small circuits.

    Laser Blanking

    We want to control our laser with an Arduino. However we need to limit current flowing into the laser and also driving it directly from a digital output pin is not a good idea. My laser module already had a current protection. Thus I've built just a simple circuit where transistor is switching the laser on and off. Base current can be regulated by trimmer and controls the brightness of the laser.

    Mirror Calibration

    Photodiode was placed in the hole in the central axis right above the X-axis stepper. Pull-down resistor circuit was necessary to obtain exact measurements. When calibrating, we are reading values from the photodiode and when the value exceeds a specific value (laser directly shines into it), steppers stop and return to the home position.

    pseudo code for calibration
    // 1step = 0.9° / 400steps = 360° = full rotation
    laserOn();
    for (int a=0; a<=400; a++) {
    for (int b=0; b<=400; b++) {
    photodiodeValue = readValue();
    if (photodiodeValue >= photodiodeThreshold) {
    laserOff();
    returnHome();
    }
    stepY(1,1);
    }
    stepX(1,1);
    }
    laserOff();
    unsuccessfull();</p>

    Step 5: Final Assembly

    The whole circuit was put into the plastic junction box and tightened by screws. The whole projector is really portable, just plug the power supply, switch the toggle and we have laser show.

    Step 6: Laser Control App

    The controlling app was made in C# and allows to switch between patterns, adjust the speed and see current actions. It is free to download together with the Arduino code (see Intro).

    Step 7: Video

    <p>help me please...</p><p>i can't compile to arduino uno..</p><p>i have problem with library </p><p>&quot; AFMotor.h&quot; and </p><p>utility/Adafruit_MS_PWMServoDriver.h.</p><p>i have library at arduino but not work...</p><p>what wrong ???</p>
    <p>What is the error message?</p>
    <p>That is correct?</p>
    <p>Yes it is. Or you can use in-built pull-up resistors inside Arduino and modify the code. By the way, please use the &quot;Reply&quot; button so we won't start a new conversation every time.</p>
    <p>Hello. Can i make laser drawing smaller? Maybe problem is in motors, i have very old motors from 5,25 FDD</p>
    <p>Hello again!</p><p>Where i must write microstepping code and steps per revolution?</p>
    <p>You can find all the information here: https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/using-stepper-motors</p>
    <p>More steps per revolution = smaller single step. You can even use microstepping.</p>
    <p>Ok. Thanks :)</p>
    <p>Both of them to the ground through a pull-down resistor. To switch on, apply 5V.<br>Even easier way would be to initialize those pins as INPUT_PULLUP and then just short them to ground as you switch the toggle.</p>
    <p>Where i need connect mode switch?</p>
    <p>Serial more - D14<br>Auto mode - D15</p>
    <p>The problem is pretty self-explanatory. You are missing the AccelStepper/MultiStepper.h library.</p><p>By the way, when you download a library, make sure to put in the the right folder structure, Documents\Arduino\libraries\xxx, where xxx will be the name of the library, and it will directly contain all the necessary files. It is always better to use the libraries folder located in Documents, in case of you will reinstall or update your Arduino IDE. You can always delete the .github folder to remove the warnings.</p>
    <p>Thanks. It works :)</p>
    <p>Hello. Can you help me? ArduinoIDE says Error compiling for board arduino Mega or Mega 2560. What can i do?</p>
    It can be caused by many things. Try to post here the full error log.
    <p>Can i make this wit mega2560?</p>
    <p>Yes. As far as I know, motor shield v2 is compatible with Arduino Mega. Basically, it should not be a problem with anything, as far as it is capable of controlling stepper motors and providing modulated output signal for laser blanking. Of course in that case, only the concept of this project should be used, not the exact same code. </p>
    <p>I`m having a problem with the softare. I`m using windows 10, 64-bit and I click to open the app but it simply doesen`t wanna open. It shows the loading cursor for 4 seconds and stops, with no sign of the app.</p><p>Thanks.</p>
    Try to right-click it, go to properties, and if there is an option called &quot;Unblock&quot;, then check it and click apply.
    <p>Hy ! I modified code work Adafruit Motor Shield V1 but not good effect .</p><p>Can i help you ?</p><p>I use order 400 steps/rev motor !!</p><p>It's code </p><p>&quot;/*</p><p> Arduino Laser Scanner</p><p> by Stanley Ondrus 2016</p><p> - XY - 2 dimensional laser scanning</p><p> - Automatic mirror calibration</p><p> - Remote serial control (via bluetooth)</p><p> - Auto mode</p><p> - Remote control app with GUI</p><p> <a href="http://www.stanleyprojects.com" rel="nofollow"> www.stanleyprojects.com</a></p><p> <a href="http://www.github.com/stanleyondrus/ArduinoLaserScanner" rel="nofollow"> www.github.com/stanleyondrus/ArduinoLaserScanner</a></p><p>*/</p><p>#include &lt;AccelStepper.h&gt;</p><p>#include &lt;MultiStepper.h&gt;</p><p>#include &lt;Wire.h&gt;</p><p>#include &lt;AFMotor.h&gt;</p><p>int stepsPerRevolution = 350;</p><p>int serialLed = 10;</p><p>int autoLed = 11;</p><p>int calibrationLed = 12;</p><p>int laserPin = 13;</p><p>int switchPin = 14;</p><p>int autoModePin = 15;</p><p>int photodiodePin = 16;</p><p>AF_Stepper myX(stepsPerRevolution, 1);</p><p>AF_Stepper myY(stepsPerRevolution, 2);</p><p>static int METHOD = INTERLEAVE;</p><p>int speedValue = 800;</p><p>int initialSize = 20;</p><p>int currentType = 0;</p><p>int currentId = 0;</p><p>int currentSize = initialSize;</p><p>int currentSpeed = speedValue;</p><p>int currentDuration = 0;</p><p>int minType = 1;</p><p>int maxType = 5; // how many shapes</p><p>int minId = 1;</p><p>int maxId = 5; // how many patterns</p><p>int minSize = 3;</p><p>int maxSize = 30; // size in steps</p><p>int minPatternSpeed = 10;</p><p>int maxPatternSpeed = 800; // speed of steppers</p><p>int minDuration = 1;</p><p>int maxDuration = 10; // iterations of for loop</p><p>int patternSize[] = {5, 10, 15, 20, 25, 30};</p><p>int sizeStart = 0;</p><p>int sizeEnd = 7;</p><p>int photodiodeValue = 0; // photodiode value needed for calibration</p><p>int photodiodeThreshold = 170; // min value when laser points to diode</p><p>int returnY = 109; // Y steps needed to return home from calibration</p><p>int returnX = 12; // X steps needed to return home from calibration</p><p>boolean laser = false;</p><p>boolean calibrated = false;</p><p>boolean calibration = false;</p><p>boolean randomSize = false;</p><p>int c = 0; // used for serial receive</p><p>// you can change these to DOUBLE or INTERLEAVE or MICROSTEP</p><p>void forwardstep1() {</p><p> myX.onestep(FORWARD, METHOD);</p><p>}</p><p>void backwardstep1() {</p><p> myX.onestep(BACKWARD, METHOD);</p><p>}</p><p>void forwardstep2() {</p><p> myY.onestep(FORWARD, METHOD);</p><p>}</p><p>void backwardstep2() {</p><p> myY.onestep(BACKWARD, METHOD);</p><p>}</p><p>AccelStepper x(forwardstep1, backwardstep1); // use functions to step</p><p>AccelStepper y(forwardstep2, backwardstep2); // use functions to step</p><p>void setup()</p><p>{</p><p> Serial.begin(9600); // set up Serial library at 9600 bps</p><p> Serial.println(&quot;Arudino Laser Scanner&quot;);</p><p> pinMode(serialLed, OUTPUT);</p><p> pinMode(autoLed, OUTPUT);</p><p> pinMode(calibrationLed, OUTPUT);</p><p> pinMode(laserPin, OUTPUT);</p><p> pinMode(switchPin, INPUT);</p><p> pinMode(autoModePin, INPUT);</p><p> pinMode(photodiodePin, INPUT);</p><p> stepperSpeed(speedValue);</p><p> x.setAcceleration(1000);</p><p> y.setAcceleration(1000);</p><p> laserOff();</p><p> sLedOff();</p><p> aLedOff();</p><p> cLedOff();</p><p>}</p><p>void loop()</p><p>{</p><p> if (switchRead())</p><p> {</p><p> if (calibration)</p><p> {</p><p> calibrate();</p><p> }</p><p> if (!(calibrated))</p><p> {</p><p> calibrateOnSerial();</p><p> }</p><p> serialMode();</p><p> }</p><p> if (autoModeRead())</p><p> {</p><p> autoMode();</p><p> }</p><p>}</p><p>void serialEvent() {</p><p> while (Serial.available())</p><p> {</p><p> c = Serial.read();</p><p> switch (c)</p><p> {</p><p> case 'A': //laser on</p><p> laserOn();</p><p> Serial.println(&quot;Laser On&quot;);</p><p> break;</p><p> case 'B': //laser off</p><p> laserOff();</p><p> Serial.println(&quot;Laser Off&quot;);</p><p> break;</p><p> case 'C': //calibrate</p><p> calibrate();</p><p> break;</p><p> case 'D': //stop</p><p> setCurrentPattern(0, 0);</p><p> calibration = false;</p><p> Serial.println(&quot;Stopped&quot;);</p><p> break;</p><p> case 'E': //random size enable</p><p> randomSize = true;</p><p> Serial.println(&quot;Random Size Enabled&quot;);</p><p> break;</p><p> case 'F': //random size disable</p><p> randomSize = false;</p><p> Serial.println(&quot;Random Size Disabled&quot;);</p><p> break;</p><p> case 'G': //size increment</p><p> if (currentSize &lt; 30)</p><p> {</p><p> currentSize += 5;</p><p> }</p><p> // Serial.println(&quot;Current Size: &quot; + currentSize);</p><p> break;</p><p> case 'H': //size decrement</p><p> if (currentSize &gt; 5)</p><p> {</p><p> currentSize -= 5;</p><p> }</p><p> // Serial.println(&quot;Current Size: &quot; + currentSize);</p><p> break;</p><p> case 'I': //square 1</p><p> setCurrentPattern(1, 1);</p><p> currentDetails(&quot;Square 1&quot;);</p><p> break;</p><p> case 'J': //square 2</p><p> setCurrentPattern(1, 2);</p><p> currentDetails(&quot;Square 2&quot;);</p><p> break;</p><p> case 'K': //square 3</p><p> setCurrentPattern(1, 3);</p><p> currentDetails(&quot;Square 3&quot;);</p><p> break;</p><p> case 'L': //square 4</p><p> setCurrentPattern(1, 4);</p><p> currentDetails(&quot;Square 4&quot;);</p><p> break;</p><p> case 'M': //cross 1</p><p> setCurrentPattern(2, 1);</p><p> currentDetails(&quot;Cross 1&quot;);</p><p> break;</p><p> case 'N': //cross 2</p><p> setCurrentPattern(2, 2);</p><p> currentDetails(&quot;Cross 2&quot;);</p><p> break;</p><p> case 'O': //cross 3</p><p> setCurrentPattern(2, 3);</p><p> currentDetails(&quot;Triangle 1&quot;);</p><p> break;</p><p> case 'P': //cross 4</p><p> setCurrentPattern(2, 4);</p><p> currentDetails(&quot;Triangle 2&quot;);</p><p> break;</p><p> case 'Q': //line 1</p><p> setCurrentPattern(3, 1);</p><p> currentDetails(&quot;Line 1&quot;);</p><p> break;</p><p> case 'R': //line 2</p><p> setCurrentPattern(3, 2);</p><p> currentDetails(&quot;Line 2&quot;);</p><p> break;</p><p> case 'S': //line 3</p><p> setCurrentPattern(3, 3);</p><p> currentDetails(&quot;Line 3&quot;);</p><p> break;</p><p> case 'T': //line 4</p><p> setCurrentPattern(3, 4);</p><p> currentDetails(&quot;Line 4&quot;);</p><p> break;</p><p> case 'U': //sticky man figure</p><p> setCurrentPattern(4, 1);</p><p> currentDetails(&quot;Man Figure&quot;);</p><p> break;</p><p> case 'V': //</p><p> setCurrentPattern(4, 2);</p><p> currentDetails(&quot;Smiley&quot;);</p><p> break;</p><p> case 'W': //</p><p> setCurrentPattern(4, 3);</p><p> currentDetails(&quot;Heart&quot;);</p><p> break;</p><p> case 'X': //</p><p> setCurrentPattern(4, 4);</p><p> currentDetails(&quot;Star&quot;);</p><p> break;</p><p> }</p><p> }</p><p>}</p><p>//----switches-and-button-reads------------</p><p>boolean autoModeRead() {</p><p> if (digitalRead(autoModePin) == HIGH ) {</p><p> return true;</p><p> } else {</p><p> return false;</p><p> }</p><p>}</p><p>boolean switchRead() {</p><p> if (digitalRead(switchPin) == HIGH) {</p><p> return true;</p><p> } else {</p><p> return false;</p><p> }</p><p>}</p><p>//-----------------------------------------</p><p>//------------calibration-----------------</p><p>boolean calibrateOnSerial()</p><p>{</p><p> calibration = true;</p><p> cLedOn();</p><p> Serial.println(&quot;XY Calibration&quot;);</p><p> stepY(returnY, 1);</p><p> stepX(returnX, 1);</p><p> for (int a = 0; a &lt;= stepsPerRevolution; a++)</p><p> {</p><p> for (int i = 0; i &lt;= stepsPerRevolution; i++)</p><p> {</p><p> serialEvent();</p><p> if (!(calibration) || (!(switchRead())))</p><p> {</p><p> notSuccessful();</p><p> return false;</p><p> }</p><p> laserOn();</p><p> photodiodeValue = map(analogRead(photodiodePin), 0, 1023, 0, 255);</p><p> //delay(50);</p><p> if (photodiodeValue &gt;= photodiodeThreshold)</p><p> {</p><p> laserOff();</p><p> rotateHome();</p><p> Serial.println(&quot;Calibrated&quot;);</p><p> cLedOff();</p><p> calibration = false;</p><p> calibrated = true;</p><p> return true;</p><p> }</p><p> stepY(1, 1);</p><p> }</p><p> stepX(1, 1);</p><p> }</p><p> notSuccessful();</p><p>}</p><p>boolean calibrate() {</p><p> calibration = true;</p><p> cLedOn();</p><p> Serial.println(&quot;XY Calibration&quot;);</p><p> stepY(returnY, 1);</p><p> stepX(returnX, 1);</p><p> for (int a = 0; a &lt;= stepsPerRevolution; a++)</p><p> {</p><p> for (int i = 0; i &lt;= stepsPerRevolution; i++)</p><p> {</p><p> serialEvent();</p><p> if (!(calibration))</p><p> {</p><p> notSuccessful();</p><p> return false;</p><p> }</p><p> laserOn();</p><p> photodiodeValue = map(analogRead(photodiodePin), 0, 1023, 0, 255);</p><p> //delay(50);</p><p> if (photodiodeValue &gt;= photodiodeThreshold)</p><p> {</p><p> laserOff();</p><p> rotateHome();</p><p> Serial.println(&quot;Calibrated&quot;);</p><p> cLedOff();</p><p> calibration = false;</p><p> calibrated = true;</p><p> return true;</p><p> }</p><p> stepY(1, 1);</p><p> }</p><p> stepX(1, 1);</p><p> }</p><p> notSuccessful();</p><p>}</p><p>boolean notSuccessful()</p><p>{</p><p> Serial.println(&quot;Calibration not successful.&quot;);</p><p> laserOff();</p><p> cLedOff();</p><p> rotateHome();</p><p> calibrated = true;</p><p> calibration = false;</p><p> return false;</p><p>}</p><p>void rotateHome()</p><p>{</p><p> stepY(returnY, 2);</p><p> stepX(returnX, 2);</p><p>}</p><p>//-----------------------------------------</p><p>//--------serial-mode-functions--------------</p><p>void serialMode()</p><p>{</p><p> sLedOn();</p><p> if (currentType != 0 || currentId != 0)</p><p> {</p><p> if (randomSize)</p><p> {</p><p> currentSize = patternSize[random(sizeStart, sizeEnd)];</p><p> }</p><p> currentSpeed = 800;</p><p> currentDuration = 1;</p><p> patternCall(currentType, currentId, currentSize, currentSpeed, currentDuration);</p><p> }</p><p> sLedOff();</p><p>}</p><p>void setCurrentPattern(int patternType, int patternId)</p><p>{</p><p> currentType = patternType;</p><p> currentId = patternId;</p><p>}</p><p>void currentDetails(String pattern)</p><p>{</p><p> String details = pattern + &quot; - Size: &quot; + currentSize + &quot; Speed: &quot; + currentSpeed + &quot; Duration: &quot; + currentDuration;</p><p> Serial.println(details);</p><p>}</p><p>//-----------------------------------------</p><p>//--------auto-mode-functions--------------</p><p>void autoMode()</p><p>{</p><p> aLedOn();</p><p> calibrated = false;</p><p> currentType = random(minType, maxType);</p><p> currentId = random(minId, maxId);</p><p> currentSize = patternSize[random(sizeStart, sizeEnd)];</p><p> //currentSpeed = random(minPatternSpeed, maxPatternSpeed);</p><p> currentDuration = random(minDuration, maxDuration);</p><p> patternCall(currentType, currentId, currentSize, currentSpeed, currentDuration) ;</p><p> currentType = 0;</p><p> currentId = 0;</p><p> currentSize = initialSize;</p><p> currentDuration = 0;</p><p> aLedOff();</p><p>}</p><p>void patternCall(int patternType, int patternId, int patternSize, int patternSpeed, int patternDuration)</p><p>{</p><p> stepperSpeed(patternSpeed);</p><p> for (int i = 0; i &lt;= patternDuration; i++)</p><p> {</p><p> patternTypeCall(patternType, patternId, patternSize);</p><p> }</p><p>}</p><p>void patternTypeCall(int patternType, int patternId, int patternSize)</p><p>{</p><p> switch (patternType) {</p><p> case 1:</p><p> square(patternId, patternSize);</p><p> break;</p><p> case 2:</p><p> object(patternId, patternSize);</p><p> break;</p><p> case 3:</p><p> line(patternId, maxSize);</p><p> break;</p><p> case 4:</p><p> logo(patternId, maxSize / 2);</p><p> break;</p><p> default:</p><p> square(patternId, patternSize);</p><p> break;</p><p> }</p><p>}</p><p>//--------------------------------------</p><p>//-------------patterns-----------------</p><p>void square(int patternId, int patternSize)</p><p>{</p><p> switch (patternId) {</p><p> case 1:</p><p> square1(patternSize);</p><p> break;</p><p> case 2:</p><p> square2(patternSize);</p><p> break;</p><p> case 3:</p><p> square3(patternSize);</p><p> break;</p><p> case 4:</p><p> square4(patternSize);</p><p> break;</p><p> default:</p><p> break;</p><p> }</p><p>}</p><p>void object(int patternId, int patternSize)</p><p>{</p><p> switch (patternId) {</p><p> case 1:</p><p> cross1(patternSize);</p><p> break;</p><p> case 2:</p><p> cross2(patternSize);</p><p> break;</p><p> case 3:</p><p> triangle1(20);</p><p> break;</p><p> case 4:</p><p> cicuska(20);</p><p> break;</p><p> default:</p><p> break;</p><p> }</p><p>}</p><p>void line(int patternId, int patternSize)</p><p>{</p><p> switch (patternId) {</p><p> case 1:</p><p> line1(patternSize);</p><p> break;</p><p> case 2:</p><p> line2(patternSize);</p><p> break;</p><p> case 3:</p><p> line3(patternSize);</p><p> break;</p><p> case 4:</p><p> line4(patternSize);</p><p> break;</p><p> default:</p><p> break;</p><p> }</p><p>}</p><p>void logo(int patternId, int patternSize)</p><p>{</p><p> switch (patternId) {</p><p> case 1:</p><p> manFigure(patternSize);</p><p> break;</p><p> case 2:</p><p> smiley(patternSize);</p><p> break;</p><p> case 3:</p><p> heart(patternSize);</p><p> break;</p><p> case 4:</p><p> star(patternSize);</p><p> break;</p><p> default:</p><p> break;</p><p> }</p><p>}</p><p>//------------------------------------</p><p>//-------------squares-----------------</p><p>void square1(int squareSize)</p><p>{</p><p> laserOn();</p><p> stepX(squareSize, 1);</p><p> stepY(squareSize, 1);</p><p> stepX(squareSize, 2);</p><p> stepY(squareSize, 2);</p><p> laserOff();</p><p>}</p><p>void square2(int squareSize)</p><p>{</p><p> laserOn();</p><p> stepX(squareSize, 1);</p><p> laserOff();</p><p> stepY(squareSize, 1);</p><p> laserOn();</p><p> stepX(squareSize, 2);</p><p> laserOff();</p><p> stepY(squareSize, 2);</p><p>}</p><p>void square3(int squareSize)</p><p>{</p><p> laserOff();</p><p> stepX(squareSize, 1);</p><p> laserOn();</p><p> stepY(squareSize, 1);</p><p> laserOff();</p><p> stepX(squareSize, 2);</p><p> laserOn();</p><p> stepY(squareSize, 2);</p><p> laserOff();</p><p>}</p><p>void square4(int squareSize)</p><p>{</p><p> laserOn();</p><p> delay(50);</p><p> laserOff();</p><p> stepX(squareSize, 1);</p><p> laserOn();</p><p> delay(50);</p><p> laserOff();</p><p> stepY(squareSize, 1);</p><p> laserOn();</p><p> delay(50);</p><p> laserOff();</p><p> stepX(squareSize, 2);</p><p> laserOn();</p><p> delay(50);</p><p> laserOff();</p><p> stepY(squareSize, 2);</p><p>}</p><p>//----------------------------------------</p><p>//-------------objects-----------------</p><p>void cross1(int crossSize)</p><p>{</p><p> laserOn();</p><p> for (int i = 0; i &lt; crossSize; i++)</p><p> {</p><p> stepX(1, 1);</p><p> stepY(1, 1);</p><p> }</p><p> laserOff();</p><p> stepX(crossSize, 2);</p><p> laserOn();</p><p> for (int i = 0; i &lt; crossSize; i++)</p><p> {</p><p> stepX(1, 1);</p><p> stepY(1, 2);</p><p> }</p><p> laserOff();</p><p> stepX(crossSize, 2);</p><p>}</p><p>void cross2(int crossSize)</p><p>{</p><p> square1(crossSize);</p><p> laserOn();</p><p> for (int i = 0; i &lt; crossSize; i++)</p><p> {</p><p> stepX(1, 1);</p><p> stepY(1, 1);</p><p> }</p><p> laserOff();</p><p> stepX(crossSize, 2);</p><p> laserOn();</p><p> for (int i = 0; i &lt; crossSize; i++)</p><p> {</p><p> stepX(1, 1);</p><p> stepY(1, 2);</p><p> }</p><p> laserOff();</p><p> stepX(crossSize, 2);</p><p>}</p><p>void triangle1(int objectSize)</p><p>{</p><p> laserOn();</p><p> stepX(objectSize, 1);</p><p> for (int i = 0; i &lt; objectSize / 2; i++)</p><p> {</p><p> stepY(2, 1);</p><p> stepX(1, 2);</p><p> }</p><p> for (int i = 0; i &lt; objectSize / 2; i++)</p><p> {</p><p> stepY(2, 2);</p><p> stepX(1, 2);</p><p> }</p><p> laserOff();</p><p>}</p><p>void cicuska(int crossSize)</p><p>{</p><p> int pixel = crossSize / 11;</p><p> stepX(2 * pixel, 1);</p><p> laserOn();</p><p> stepX(7 * pixel, 1);</p><p> //DOPRAVA HORE</p><p> stepY(1 * pixel, 1);</p><p> stepX(1 * pixel, 1);</p><p> stepY(1 * pixel, 1);</p><p> stepX(1 * pixel, 1);</p><p> //STLPEC VPRAVO NAHOR</p><p> stepY(9 * pixel, 1);</p><p> //PRAVE USKO</p><p> stepX(1 * pixel, 2);</p><p> stepY(1 * pixel, 2);</p><p> stepX(1 * pixel, 2);</p><p> stepY(1 * pixel, 2);</p><p> stepX(1 * pixel, 2);</p><p> stepY(1 * pixel, 2);</p><p> stepX(1 * pixel, 2);</p><p> //STRED</p><p> stepY(1 * pixel, 1);</p><p> stepX(3 * pixel, 2);</p><p> stepY(1 * pixel, 2);</p><p> //LAVE USKO</p><p> stepX(1 * pixel, 2);</p><p> stepY(1 * pixel, 1);</p><p> stepX(1 * pixel, 2);</p><p> stepY(1 * pixel, 1);</p><p> stepX(1 * pixel, 2);</p><p> stepY(1 * pixel, 1);</p><p> stepX(1 * pixel, 2);</p><p> //PRAVY STLPEC</p><p> stepY(9 * pixel, 2);</p><p> //DOPRAVA DOLE</p><p> stepX(1 * pixel, 1);</p><p> stepY(1 * pixel, 2);</p><p> stepX(1 * pixel, 1);</p><p> stepY(1 * pixel, 2);</p><p> laserOff();</p><p> stepX(2 * pixel, 2);</p><p>}</p><p>//----------------------------------------</p><p>//-------------line-----------------</p><p>void line1(int lineSize)</p><p>{</p><p> stepY(lineSize / 2, 1);</p><p> laserOn();</p><p> stepX(lineSize, 1);</p><p> stepX(lineSize, 2);</p><p> laserOff();</p><p> stepY(lineSize / 2, 2);</p><p>}</p><p>void line2(int lineSize) // from the center to sides</p><p>{</p><p> int pixel = lineSize / 11;</p><p> stepY(lineSize / 2, 1);</p><p> stepX(5 * pixel, 1);</p><p> laserOn();</p><p> stepX(1 * pixel, 1);</p><p> stepX(2 * pixel, 2);</p><p> stepX(3 * pixel, 1);</p><p> stepX(4 * pixel, 2);</p><p> stepX(5 * pixel, 1);</p><p> stepX(6 * pixel, 2);</p><p> stepX(7 * pixel, 1);</p><p> stepX(8 * pixel, 2);</p><p> stepX(9 * pixel, 1);</p><p> stepX(10 * pixel, 2);</p><p> stepX(11 * pixel, 1);</p><p> stepX(11 * pixel, 2);</p><p> stepX(11 * pixel, 1);</p><p> stepX(11 * pixel, 2);</p><p> laserOff();</p><p> stepY(lineSize / 2, 2);</p><p>}</p><p>void line3(int lineSize) // from the center to sides - up/down</p><p>{</p><p> int pixel = lineSize / 11;</p><p> stepX(5 * pixel, 1);</p><p> laserOn();</p><p> stepX(1 * pixel, 1);</p><p> stepX(2 * pixel, 2);</p><p> laserOff();</p><p> stepY(3 * pixel, 1);</p><p> laserOn();</p><p> stepX(3 * pixel, 1);</p><p> stepX(4 * pixel, 2);</p><p> laserOff();</p><p> stepY(3 * pixel, 1);</p><p> laserOn();</p><p> stepX(5 * pixel, 1);</p><p> stepX(6 * pixel, 2);</p><p> laserOff();</p><p> stepY(3 * pixel, 1);</p><p> laserOn();</p><p> stepX(7 * pixel, 1);</p><p> stepX(8 * pixel, 2);</p><p> laserOff();</p><p> stepY(3 * pixel, 2);</p><p> laserOn();</p><p> stepX(9 * pixel, 1);</p><p> stepX(10 * pixel, 2);</p><p> laserOff();</p><p> stepY(3 * pixel, 2);</p><p> laserOn();</p><p> stepX(11 * pixel, 1);</p><p> stepX(11 * pixel, 2);</p><p> laserOff();</p><p> stepY(3 * pixel, 2);</p><p> laserOn();</p><p> stepX(11 * pixel, 1);</p><p> stepX(11 * pixel, 2);</p><p> laserOff();</p><p>}</p><p>void line4(int lineSize) // from the center to sides - up/down</p><p>{</p><p> int pixel = lineSize / 11;</p><p> stepY(5 * pixel, 1);</p><p> laserOn();</p><p> stepY(1 * pixel, 1);</p><p> stepY(2 * pixel, 2);</p><p> laserOff();</p><p> stepX(3 * pixel, 1);</p><p> laserOn();</p><p> stepY(3 * pixel, 1);</p><p> stepY(4 * pixel, 2);</p><p> laserOff();</p><p> stepX(3 * pixel, 1);</p><p> laserOn();</p><p> stepY(5 * pixel, 1);</p><p> stepY(6 * pixel, 2);</p><p> laserOff();</p><p> stepX(3 * pixel, 1);</p><p> laserOn();</p><p> stepY(7 * pixel, 1);</p><p> stepY(8 * pixel, 2);</p><p> laserOff();</p><p> stepX(3 * pixel, 2);</p><p> laserOn();</p><p> stepY(9 * pixel, 1);</p><p> stepY(10 * pixel, 2);</p><p> laserOff();</p><p> stepX(3 * pixel, 2);</p><p> laserOn();</p><p> stepY(11 * pixel, 1);</p><p> stepY(11 * pixel, 2);</p><p> laserOff();</p><p> stepX(3 * pixel, 2);</p><p> laserOn();</p><p> stepY(11 * pixel, 1);</p><p> stepY(11 * pixel, 2);</p><p> laserOff();</p><p>}</p><p>//----------------------------------------</p><p>//-------------objects-----------------</p><p>void manFigure(int logoSize)</p><p>{</p><p> int pixel = logoSize / 11;</p><p> stepY(3 * pixel, 1);</p><p> stepX(3 * pixel, 1);</p><p> laserOn();</p><p> stepY(6 * pixel, 1);</p><p> stepX(3 * pixel, 2);</p><p> stepY(2 * pixel, 1);</p><p> stepX(4 * pixel, 1);</p><p> stepY(3 * pixel, 1);</p><p> stepX(3 * pixel, 1);</p><p> stepY(3 * pixel, 2);</p><p> stepX(4 * pixel, 1);</p><p> stepY(2 * pixel, 2);</p><p> stepX(3 * pixel, 2);</p><p> stepY(6 * pixel, 2);</p><p> stepX(2 * pixel, 2);</p><p> stepY(3 * pixel, 1);</p><p> stepX(1 * pixel, 2);</p><p> stepY(3 * pixel, 2);</p><p> stepX(2 * pixel, 2);</p><p> laserOff();</p><p> stepX(3 * pixel, 2);</p><p> stepY(3 * pixel, 2);</p><p>}</p><p>void smiley(int logoSize)</p><p>{</p><p> int pixel = logoSize / 11;</p><p> stepY(3 * pixel, 1);</p><p> stepX(2 * pixel, 1);</p><p> stepY(2 * pixel, 1);</p><p> laserOn();</p><p> stepY(4 * pixel, 1);</p><p> stepX(2 * pixel, 1);</p><p> laserOff();</p><p> stepY(1 * pixel, 1);</p><p> laserOn();</p><p> stepX(2 * pixel, 2);</p><p> stepY(2 * pixel, 1);</p><p> stepX(2 * pixel, 1);</p><p> stepY(2 * pixel, 2);</p><p> laserOff();</p><p> stepY(1 * pixel, 2);</p><p> laserOn();</p><p> stepY(2 * pixel, 2);</p><p> stepX(3 * pixel, 1);</p><p> stepY(2 * pixel, 1);</p><p> stepX(2 * pixel, 1);</p><p> laserOff();</p><p> stepY(1 * pixel, 1);</p><p> laserOn();</p><p> stepX(2 * pixel, 2);</p><p> stepY(2 * pixel, 1);</p><p> stepX(2 * pixel, 1);</p><p> stepY(2 * pixel, 2);</p><p> laserOff();</p><p> stepY(1 * pixel, 2);</p><p> laserOn();</p><p> stepY(4 * pixel, 2);</p><p> stepX(7 * pixel, 2);</p><p> laserOff();</p><p> stepY(2 * pixel, 2);</p><p> stepX(2 * pixel, 2);</p><p> stepY(3 * pixel, 2);</p><p>}</p><p>void heart(int logoSize)</p><p>{</p><p> int pixel = logoSize / 11;</p><p> laserOff();</p><p> stepX(5 * pixel, 1);</p><p> laserOn();</p><p> stepX(1 * pixel, 1);</p><p> stepY(1 * pixel, 1);</p><p> stepX(1 * pixel, 1);</p><p> stepY(1 * pixel, 1);</p><p> stepX(1 * pixel, 1);</p><p> stepY(1 * pixel, 1);</p><p> stepX(1 * pixel, 1);</p><p> stepY(1 * pixel, 1);</p><p> stepX(1 * pixel, 1);</p><p> stepY(1 * pixel, 1);</p><p> //column right</p><p> stepX(1 * pixel, 1);</p><p> stepY(3 * pixel, 1);</p><p> stepX(1 * pixel, 2);</p><p> //</p><p> stepY(1 * pixel, 1);</p><p> stepX(1 * pixel, 2);</p><p> stepY(1 * pixel, 1);</p><p> //row 2moves right</p><p> stepX(2 * pixel, 2);</p><p> //</p><p> stepY(1 * pixel, 2);</p><p> stepX(1 * pixel, 2);</p><p> stepY(1 * pixel, 2);</p><p> stepX(1 * pixel, 2);</p><p> stepY(1 * pixel, 1);</p><p> stepX(1 * pixel, 2);</p><p> stepY(1 * pixel, 1);</p><p> //row 2moves left</p><p> stepX(2 * pixel, 2);</p><p> //</p><p> stepY(1 * pixel, 2);</p><p> stepX(1 * pixel, 2);</p><p> stepY(1 * pixel, 2);</p><p> //column left</p><p> stepX(1 * pixel, 2);</p><p> stepY(3 * pixel, 2);</p><p> stepX(1 * pixel, 1);</p><p> //</p><p> stepY(1 * pixel, 2);</p><p> stepX(1 * pixel, 1);</p><p> stepY(1 * pixel, 2);</p><p> stepX(1 * pixel, 1);</p><p> stepY(1 * pixel, 2);</p><p> stepX(1 * pixel, 1);</p><p> stepY(1 * pixel, 2);</p><p> stepX(1 * pixel, 1);</p><p> stepY(1 * pixel, 2);</p><p> laserOff();</p><p> stepX(5 * pixel, 2);</p><p>}</p><p>void star(int logoSize)</p><p>{</p><p>int pixel= logoSize/11; </p><p>laserOff();</p><p>stepX(1*pixel,1);</p><p>stepY(2*pixel,1);</p><p>laserOn();</p><p>stepX(4*pixel,1);</p><p>stepY(2*pixel,1);</p><p>stepX(1*pixel,1);</p><p>stepY(2*pixel,2);</p><p>stepX(4*pixel,1);</p><p>stepY(1*pixel,1);</p><p>stepX(1*pixel,2);</p><p>stepY(1*pixel,1);</p><p>stepX(1*pixel,2);</p><p>stepY(1*pixel,1);</p><p>stepX(1*pixel,1);</p><p>stepY(1*pixel,1);</p><p>stepX(1*pixel,1);</p><p>//column right</p><p>stepY(2*pixel,1);</p><p>//</p><p>stepX(3*pixel,2);</p><p>stepY(2*pixel,1);</p><p>stepX(1*pixel,2);</p><p>stepY(1*pixel,1);</p><p>stepX(1*pixel,2);</p><p>stepY(1*pixel,2);</p><p>stepX(1*pixel,2);</p><p>//column left</p><p>stepY(2*pixel,2);</p><p>//</p><p>stepX(3*pixel,2);</p><p>stepY(2*pixel,2);</p><p>stepX(1*pixel,1);</p><p>stepY(1*pixel,2);</p><p>stepX(1*pixel,1);</p><p>stepY(1*pixel,2);</p><p>stepX(1*pixel,2);</p><p>stepY(1*pixel,2);</p><p>stepX(1*pixel,2);</p><p>stepY(1*pixel,2);</p><p>laserOff();</p><p>stepX(1*pixel,2);</p><p>stepY(2*pixel,2);</p><p>}</p><p>//----------------------------------------</p><p>//-----stepper-and-laser-control----------</p><p>void stepX(int steps, int newDirection)</p><p>{</p><p> if (newDirection == 1)</p><p> myX.step(steps, FORWARD, METHOD);</p><p> else</p><p> myX.step(steps, BACKWARD, METHOD);</p><p>}</p><p>void stepY(int steps, int newDirection)</p><p>{</p><p> if (newDirection == 1)</p><p> myY.step(steps, FORWARD, METHOD);</p><p> else</p><p> myY.step(steps, BACKWARD, METHOD);</p><p>}</p><p>void moveX(int newPosition)</p><p>{</p><p> x.moveTo(newPosition);</p><p> while (x.distanceToGo() != 0)</p><p> {</p><p> x.run();</p><p> }</p><p>}</p><p>void moveY(int newPosition)</p><p>{</p><p> y.moveTo(newPosition);</p><p> while (y.distanceToGo() != 0)</p><p> {</p><p> y.run();</p><p> }</p><p>}</p><p>void moveXY(int newXPosition, int newYPosition)</p><p>{</p><p> x.moveTo(newXPosition);</p><p> y.moveTo(newYPosition);</p><p> while (x.distanceToGo() != 0 || y.distanceToGo() != 0)</p><p> {</p><p> x.run();</p><p> y.run();</p><p> }</p><p>}</p><p>void stepperSpeed(int stepperSpeed)</p><p>{</p><p> x.setSpeed(stepperSpeed);</p><p> y.setSpeed(stepperSpeed);</p><p> x.setMaxSpeed(stepperSpeed);</p><p> y.setMaxSpeed(stepperSpeed);</p><p> myX.setSpeed(stepperSpeed);</p><p> myY.setSpeed(stepperSpeed);</p><p>}</p><p>void laserOn()</p><p>{</p><p> digitalWrite(laserPin, HIGH);</p><p>}</p><p>void laserOff()</p><p>{</p><p> digitalWrite(laserPin, LOW);</p><p>}</p><p>//----------------------------------</p><p>//-----------LED-control------------</p><p>void sLedOn()</p><p>{</p><p> digitalWrite(serialLed, HIGH);</p><p>}</p><p>void aLedOn()</p><p>{</p><p> digitalWrite(autoLed, HIGH);</p><p>}</p><p>void cLedOn()</p><p>{</p><p> digitalWrite(calibrationLed, HIGH);</p><p>}</p><p>void sLedOff()</p><p>{</p><p> digitalWrite(serialLed, LOW);</p><p>}</p><p>void aLedOff()</p><p>{</p><p> digitalWrite(autoLed, LOW);</p><p>}</p><p>void cLedOff()</p><p>{</p><p> digitalWrite(calibrationLed, LOW);</p><p>}</p><p>//----------------------------------</p>
    <p>Well done!</p><p>One problem is that the pattern is not pretty.</p><p>I think it's wrong for 1.8 deg step motor.</p>
    <p>I have new questens the project it's work Adafruit Motor Shield V1 ?</p>
    No, it's for the V2.
    <p>The code can not be rewritten to be good?</p>
    <p>Feel free to use V1 library and rewrite the code :)</p>
    <p>I write code v1 and succesful . It's work but a pc controller not work . </p>
    <p>I am really sorry but I don't have time to review and rewrite the whole code now. I think it will be much easier also for you if you buy Motorshield V2. It doesn't even have to be the original one. On aliexpres.com you can buy a cheap and working one around $6. I hope that helps you :)</p>
    <p>I installed 4.5.2 framework and &quot;System.IndexOutOfRangeException&quot; error .</p>
    <p>Try to download the last version of LaserControl from GitHub.</p>
    <p>windows 7 not runnig laser control app help</p>
    Are you sure it is not blocked by something? (antivirus, windows protection,...) What kind of error do you get?
    <p>Here is a picture of the wranning :/</p><p>I have no idea, I chechk anti virus and fire wall and system right .</p><p>32bit windows 7 </p>
    <p>Make sure you have .NET framework 4.5.2 installed on your computer.</p>
    <p>Nice Instructable! What power output is your laser module?</p>
    <p>Thank you! It's just 50mW.</p>
    <p>How do you use HDD platters, I thought they were made of some sort of glass material</p>
    <p>Actually they are made of aluminium so you can cut or press-brake them.</p>
    <p>Really? I've got 26 of 'em because they looked to good to throw away and I've always handled them with care. Now I know what my next project will be!! </p><p>Thanks for the instuctable.</p>
    <p>Could you post a video of operation ? </p><p>Are steppers fast enough ?</p>
    <p>You can find the video in the Intro section.</p><p>It depends on what your definition of &quot;fast enough&quot; is. In my opinion, for a small laser show it's more than enough, but if you want to make a precise 2D animation system, you will need high Kpps galvo scanners.</p>

    About This Instructable

    7,350views

    68favorites

    License:

    Bio: I am a 22 years old student from Slovakia currently studying ICT Engineering (Embedded Systems) in Denmark. In my free time I like working with ... More »
    More by stanleyprojects:Robotic Arm Laser Engraver Arduino Laser Projector + Control App 
    Add instructable to: