Read articles from the magazine right here on Make:. Don’t have a subscription yet? Get one today.

Randomness has always fascinated me.

Pretty sure it fascinates a bunch of other people too, especially those who try to keep our personal information secure.

And oh yeah, Las Vegas.

So I was very interested in an article on an electronic random number generator (RNG) in Make: Volume 45 entitled “Really, Really Random Number Generator” by Charles Platt and Aaron Logue.

This RNG was based on a simple circuit by Aaron, and here’s what they said about it: “The PN junction of [a transistor] is reverse biased to produce avalanche noise. The resultant signal is amplified for the purpose of driving a TTL-level Schmitt trigger to produce … totally unpredictable signal noise [which] can then be converted into an unlimited stream of random high and low digital states.”

I translated this to: If you correctly connect nine cheap electronic parts, feed them 18 VDC and send their output signals to an input pin of a microcontroller, you’ve got yourself a very fast stream of zeroes and ones in no predictable order, to do with as you wish.

Since I was also exploring DC motor control at the time, it seemed like a good idea to put the two ideas together as a drawing machine (Figure A). Why not let a couple of motors randomly control a pen?

Figure A

So I ordered a cheap dual motor-control circuit board, featuring the L298N wonder-chip, used primarily to move small robotic vehicles. (The board can also control a single stepper motor.) The less common parts for the RNG circuit are available at Amazon or eBay, though some may be on a slow boat from China for awhile. While you’re waiting, you can read up on how to use the L298N board, including a couple of Arduino sketches.

Figure B

Any inexpensive easel will do, but I like to build things. Mine consists of a camera tripod, a piece of dry-erase board (project plywood is also suitable), and a few things that should be lying around any respectable shop (Figures B and C). Use a vise and hammer to bend a piece of aluminum to fit between the tripod’s camera-mounting screw and your screw or knob at the top of the dry-erase board. Drill and tap the holes to match those threads. Be sure to lean the board back so the pen can draw properly; more on that later. There’s a simpler tripod easel on Instructables that’s not as big or sturdy.

Figure C

Platt and Logue used two 9V batteries to power their RNG. With no 9V batteries on hand, I found a 115VAC supply that provides a steady 12VDC at 1A, which is enough for this project. The motors draw about half an amp total when both are pulling the pen over the drawing surface. The L298N also runs on 12VDC.

Figure D

Once your parts arrive, build the circuits (Figures D, E, and F). I built mine on top of a BASIC Stamp Homework Board, but you can use any breadboard or proto board. Note that the first transistor (it generates the random noise) has only two leads connected; clip off the third lead. You should read Platt and Logue’s detailed build description, but here’s an important tip: “When installing the Zener diode, remember that its cathode stripe should point away from the negative bus, unlike a regular diode. The Zener shunts voltages above 4.7VDC to ground.”

Figure E

NOTE: You can safely ignore the right-hand breadboard in Figure D; it comes standard with the HomeWork board, but I played it safe and put my RNG components on the separate breadboard at left, so I didn’t accidentally blow my HW board. The (unconnected) pull-down resistors are for insurance; sometimes you gotta guarantee a 0 when you want a 0. The LED is just for testing.

Figure F

Mount the motors to the left and right top edges of your drawing board with two 3mm machine screws each, either directly to the dry-erase board or through small pieces of project plywood. Mount the string pulleys to the motor shafts. I used thread bobbins from an old sewing machine; Amazon carries these as well. They’re a slip fit on the 6mm motor shafts, so add a disc of masking tape first (Figure G). Wind about 4′ of flexible braided fishing line from one bobbin to another. Try to keep roughly the same amount of line on each bobbin, and leave some slack between them. It doesn’t matter which side of the bobbins the line exits.

Figure G

Make the pen holder from ⅛” clear acrylic — scraps are often available at glass shops — following Figure H, and hang it temporarily (upside down) on the slack “V” in your fishing line, for testing.

Figure H

Connect the output of the RNG’s Zener diode to any input pin of a microcontroller (Arduino, Basic Stamp, etc.). The L298N board has 4 inputs to control 2 motors, so I decided to grab groups of four consecutive signals from the RNG, such as 0010, 1010, etc., all using a single input pin of the microcontroller.

Programming Your Random Drawbot

Download my code for the BASIC Stamp microcontroller. But it’s pretty simple to make your own version for your favorite microcontroller.

What will the next generation of Make: look like? We’re inviting you to shape the future by investing in Make:. By becoming an investor, you help decide what’s next. The future of Make: is in your hands. Learn More.

Project Steps

1.

The L298N controls two motors, A and B. You must enable both by sending HIGHs to ENA and ENB on the L298N board (Figure F). Leave them enabled for the duration of the program. But just enabling the motors will not cause them to run; they must know which direction to turn.

2.

Poll the RNG for a random combination of 4 zeroes (LOWs) and ones (HIGHs). I like to store them as variables (say, W through Z) to make it a bit easier to understand. If all 4 digits are (randomly) zero, go back and get 4 more. It takes at least one HIGH to move the pen.

3.

The first 2 digits control motor A. 10 would turn the motor one way and 01 would turn it the other way. Similarly, the second 2 digits control motor B.

4.

Send the 4 variables’ values to input pins IN1 through IN4 on the L298N board.

5.

Write subroutines to run the motors in their prescribed directions.

6.

Add pauses or delays to keep the motor(s) running for whatever time it takes to draw distinct line segments. I use pauses anywhere from 100 to 500 milliseconds, but if you want to draw larger, um, creations, increase the delays to allow the motors to run longer.

7.

Write a subroutine to brake the motors after they draw the line segments. LOWs to both IN1 and IN2 will brake motor A; LOWs to both IN3 and IN4 will brake motor B. You don’t need to send LOWs to the motor-enable pins.

8.

You can add another degree of randomness if you use an Arduino with the ability to control the motors’ speeds with its PWM pins.

FIRST-TIME OPERATION

1. Connect a 4-wire cable from the L298N board to the motors. Polarity isn’t important; it’s random, you know.

2. Lean the easel back at 15° or 20° and do a dry run with just the pen holder hanging from the fishing line.

3. If the motors don’t run or the pen holder’s motions don’t seem random, check your circuitry and program for errors. Shorten or lengthen pauses as necessary to compensate for motor variations.

4. Tape a piece of paper to the easel’s drawing surface. Position the acrylic pen holder roughly in the center of the paper. You may have to manually wind/unwind fishing line from the bobbins.

5. Remove the top from your pen (I like to use a fine-tip Sharpie) and push it through the hole in its holder, so that the fishing line suspends the pen over the drawing surface (Figure I). Adjust the angle of the easel if necessary.

Figure I

6. Run the program and stand back.

RANDOM TIPS

If the pen’s moves don’t seem random enough (the odds of the RNG spitting out, say, 4 zeroes 3 or 4 times in a row is very small!), and other attempts to fix them don’t work, debug or print a series of the 4 random digits to your computer screen and pause awhile to study the numbers. Try changing the first transistor to another metal-can NPN transistor. It seems that stressing the noise-producing transistor or running it on 12V instead of Platt and Logue’s recommended 18V may not work with some transistors.

Random being random, the pen will sometimes try to go off the paper. It’s OK to give it an occasional shove! I even added two switches and two more input subroutines to occasionally override any overzealous randomness.

Use your favorite photo editor to enhance your art: add or change colors, clone, copy, rotate, add, subtract, solid fills, textures.