posts tagged with the keyword ‘arduino’



I finally got the electronics for my Turntable Drawing Machine working. It wasn’t easy…

I decided to use a DC gearmotor controlled by an Arduino and potentiometer for the speed. I did a quick test of this with a Leonardo and a DRV8835 Dual Motor Driver Shield for Arduino. It worked fine for controlling the speed of the motor, but I didn’t really want to use the shield, so I used a DRV8835 Dual Motor Driver Carrier I had on hand. (Since I’m only using one DC motor, I probably could have used a DRV8838 Single Brushed DC Motor Driver Carrier.)

Pololu has an easy-to-use Arduino library for the DRV8835 Dual Motor Driver Shield which worked fine for the shield, but doesn’t (I mean didn’t) work with the DRV8835 Dual Motor Driver Carrier. I ended up hacking the library a bit to make it work. All was well until I added a servo. Since the Arduino library for the shield is hard-coded to use pins 7, 8, 9 and 10 there’s an issue because the default Arduino servo library disables PWM control on pins 9 and 10. I then changed the library to not use pins 9 and 10, but that still didn’t quite work… Seems that the servo library and the motor control library both need to use times, so there’s some weirdness there…

I ended up digging through the forums and eventually found some useful posts and a link to (It’s worth noting that there are a number of ServoTimer2 libraries, but I tried this one and it worked.)

Once I had the ServoTimer2 library in place, getting it to work with the my hacked ‘DRV8835DualDriver’ library was simple. (I’m saying “simple” but it took a few hours of screwing around with things that should have worked but didn’t) If I had used one of the Arduino Megas I had lying around, I probably could have avoided some of the issues the Servo library causes.

Alright, well… electronics seem good! Next step is to build things, and get the turntable portion constructed to test if the DC gearbox will work out. I think it will, as it’s got plenty of torque, and there shouldn’t be much resistance.


In accordance with a request from organizations and people I respect, here’s a photo take on 2015-04-19 showing the packaging from an Arduino UNO I purchased from Adafruit Industries (in the United States of America) on 2010-10-19 showing the text “Manufactured under license from Arduino by SMART PROJECTS S.r.l.”.

Adafruit /

Here is the order information from that purchase. For more info, see the Hackaday post Your Arduino Packaging Could Sway a Court Case and the Adafruit post Please post old Arduino packaging that says “Manufactured under license from Arduino” #TeamArduinoCC.


When last we discussed rotary encoding, it was all experimental. Since the project (which will eventually be revealed) is complete, I figured I should share a bit more about the exploration and final solution.

Encoding Disk

I moved from printed paper disks to laser-cut disks. I cut some 3mm Baltic Birch plywood at Milwaukee Makerspace. They worked well, but since I was hoping to get more steps/resolution I continued with the paper prototypes as well.

Encoding Disk

The one in the photo above was a bit too fine… too many steps. The more steps the more precise the alignment has to be, and the more chance of errors.


We had some concerns about a disk spinning between a U-shaped sensor with just a few millimeters on each side, so rather than just go with the GP1A57HRJ00F Photo Interrupter, I started experimenting with the QRD1114 Optical Detector / Phototransistor as an alternative.


The idea would be to use a wider disk and instead of it spinning between two pieces, it would have the encoding stripe on the edge, and the sensors would be on the outside of the disk. Back to the breadboard! The QRD1114s require a pair of resistors to work properly, so I wired it up and did a few tests and things seemed to work.

Encoding Strips

My first tests just involved sliding a piece of striped paper across the sensors, but I needed a real disk. I used the laser cutter at Brown Dog Gadgets to cut some disks from 1″ pink foam, and also from 1/4″ foamcore board. The pink foam actually ended up with concave sides due to the melting power of the laser, so I used the foamcore board pieces stacked up.


Math time! How long of a strip do we need to wrap around the disk? Well, you can determine the circumference of a circle if you know the radius or diameter. Hooray for math! Above is a letter size file that I could print on a laser printer to produce the stripes I needed. The thin line on the right side was used for alignment since I had to use multiple stripes to wrap around the disk.


Here’s a sneak peek of what the final disk looks like. There’s a few more steps before we got this far though, so I’ll continue the story next time.


Motor Mounts

I needed a few motor mounts for a project and since I was at Milwaukee Makerspace it seemed quicker/faster to just laser cut a few since I had files on my laptop. (I could have 3D printed them as well.)


I assembled a quick and dirty polargraph, and while I attempted to use an Adafruit Motor Shield I had on hand, it did not work. The steppers were not moving, just humming and stuttering.

I then grabbed the CNC Shield I’ve been testing and put that in place. The steppers worked fine with a test sketch, but the firmware I wanted to load (Dan’s Makelangelo code) expects either an Adafruit Motor Shield or a RUMBA board. I thought about trying to rewrite things to work with the Pololu motor drivers, but it was also after 11pm.

(I later realized that I should have looked at the RUMBA firmware, as that supposedly works with RAMPS. And yes, while I do have a spare RAMPS board, it’s across town at my studio. I decided to punt and see what I could do with what was in my workshop.)


I figured I’d throw Grbl on it and see what happened. I used Grbl Controller to connect to the board and loaded some G-code to run. I knew it would not work (as expected) but I tried anyway.


Grbl supports machines that use Cartesian coordinates, but not those that use polar coordinates, like a polargraph. Still, I was surprised at what I got. It basically worked, except for flipping the image and running it diagonally up to the left.

Grbl Controller

I then took my original vector file and flipped it, and skewed it up and to the left, to match (somewhat) how it was drawn by the machine.

Shapes skewed

It actually sort of worked! I think it was after midnight by now so I gave up on it. My lack of math skills prevent me from converting between coordinate systems, but I think there’s a few things to explore here, and if I get time (uhhh) it may be something I play with a bit in the future. Also, if anyone wants to add polar coordinate support to Grbl that would be lovely. :)


Rotary Encoding

For an upcoming project we want to use rotary encoding with optical sensors, so I did a bit of hacking testing today…

I’m using two photo interrupters mounted on breakout boards with 220 ohm resistors.

For an encoding disk I searched for a suitable SVG file and found this blog post, which just happened to have a link to a perl script (of course!) to generate encoding disks. A little Inkscape magic and I printed out a disk to test with.

I should note that my original plan was to use the Silhouette Cameo to cut the slots in the disk, but the paper version actually worked fine for testing. In the final piece we’ll probably use a piece of laser-cut acrylic.

With my encoding disk ready I hot glued it to a bolt and chucked it in the drill. This gave me an easy way to vary the speed and direction.

Rotary Encoding

I grabbed the Encoder_Polling library and used the counter example and that was about it. I could now see if the disk was spinning and in which direction (by looking at the numbers increase or decrease.)

I really thought I’d need to mount the photo interrupters more precisely, but I pretty much left them hanging in mid-air supported by wires on a breadboard and it worked fine. (Maybe I just got lucky?) There’s a lot more code to write, but this was a good start.

Oh, if you want to learn way too much about reading rotary encoders with an Arduino, visit the Reading Rotary Encoders page and set aside a few hours…

Note: I also found an online encoder wheel generator.

« Older Entries |

buy the button:

Buy The Button

top recent artists: