Upcoming Events

Jason Kelly Johnson will be running a one-day intensive Firefly/Arduino Workshop "RESPONSIVE BUILDING FACADES" on July 27, 2012 in San Francisco (as a part of the Architect's Newspaper "Art and Science of Building Facades" Symposium.) Register here.

*Read Jason's Hardware Recommendations blog post for 2012-13 Firefly Workshops.  

Are you teaching or participating in a workshop that is using Firefly?  Let us know about it and we'll feature it here on the Firefly website! (info@fireflyexperiments.com)

Discussions > Driving Stepper Motors with Firefly

A number of people have asked me lately about how to drive stepper motors using Firefly. There is great potential to use Firefly / Grasshopper to drive custom fabrication machines, mills, 3d printers, etc. I have created a custom Firefly Stepper Firmata and also a Stepper + Potentiometer .ghx file to get people started. They are available for download here: https://www.box.net/shared/jya59yzdo6. You will need a Potentiometer, a Stepper Motor, and the EasyDriver v4.3 board by Sparkfun - the specs are here: http://schmalzhaus.com/EasyDriver/. In the example I am using 1.8 degree stepper with both the MS1 and MS2 pins set to HIGH (for 1/8 step resolution). I also included an Arduino example that does not need Firefly. Both examples uses the Arduino EasyDriver.h library.

We plan to test a bunch of custom Firefly components that drive things like Steppers, LED Arrays, etc. If you have created something unique please post it here and we will consider incorporating it into the next version of the Firefly Primer.

March 18, 2011 | Unregistered CommenterJason K Johnson

Previously posted by Hassan at: http://www.grasshopper3d.com/forum/topics/controlling-motors-through
"controlling motors through firefly arduino UNO"

I have been experimenting with firefly lately but i couldnt find any way to control motors through it.. i have heard of 3 types of motors
stepper, servo, simple ( those in kids cars)
I have a stepper that i was trying to control but m stuck, i was supplying 1000, 0100, 0010, 0001 to blink n then to 4 digital pins... cant get beyond this... i know there must be solution other than this.
i cant buy servo as its too expensive here in karachi.
About simple motors, is there any solution that i can control there speed and all as i am looking for few motors whose radians \speed can be controlled through sliders.?
i need to make an animated thread model. any other thing you people can suggest like i heard about actuators?? is it cheap ...
please i am kinda stuck for a month now in thesis..... m using arduino UNO

April 6, 2011 | Unregistered CommenterJason K Johnson

Hassan, Yes stepper motors would be perfect for this but you either need a stepper controller board (similar to the Easy Driver mentioned above); or you need to create your own circuit using an H-bridge chip or ULN2003. This is covered here: http://www.arduino.cc/en/Tutorial/Stepper. Based on your project description I think simple Hobby Servos would be better though. Do you have access to an RC Car store, or model airplane shop? They usually carry servos. You might also find servos, or geared DC motors in things like children's toys. Good luck!

April 6, 2011 | Unregistered CommenterJason K Johnson


Im also having a problem connecting stepper to grasshopper. I am not using the easy drive. I use H-Bridge instead.

When I upload EasyDriver_Stepper_Pot_Firefly_18_Mar_2011.pde to the arduino interface, it give me error. It says " 'Stepper' does not name a type"

What am I doing wrong? I connect the stepper motor to the board according to the diagram : http://www.arduino.cc/en/Tutorial/MotorKnob.


May 26, 2011 | Unregistered CommenterSeb

Hi Jason,

I downloaded the stepper definition and the firmata, installed the easyboard libraries into Arduino, but have been unsuccesful in uploading the stepper firmata to my arduino board. When I try to upload it I get this message:

EasyDriver_Stepper_Pot_Firefly_18_Mar_2011.cpp.o: In function `__static_initialization_and_destruction_0':
C:\Users\SIMBIO~1\AppData\Local\Temp\build2770942686309635869.tmp/EasyDriver_Stepper_Pot_Firefly_18_Mar_2011.cpp:31: undefined reference to `Stepper::Stepper(int, int, int)'
EasyDriver_Stepper_Pot_Firefly_18_Mar_2011.cpp.o: In function `serialread()':
C:\Users\SIMBIO~1\AppData\Local\Temp\build2770942686309635869.tmp/EasyDriver_Stepper_Pot_Firefly_18_Mar_2011.cpp:173: undefined reference to `Stepper::setSpeed(long)'
C:\Users\SIMBIO~1\AppData\Local\Temp\build2770942686309635869.tmp/EasyDriver_Stepper_Pot_Firefly_18_Mar_2011.cpp:174: undefined reference to `Stepper::step(int)'

I'm using a bi-polar stepper 1.8 degrees and the easyboard driver. Your suppose to upload the firmata to the arduino board then open the definition correct? Any suggestions would be most appreciated.


November 17, 2011 | Unregistered CommenterHunter Ruthrauff

Hey Hunter,
Make sure that the EasyDriver.h library file is in your arduino-0023\libraries\EasyDriver folder. It look like it is trying to reference the library functions but cannot locate them in the libraries folder. I am going also to release the new QuadDriver (avaialable at Sparkfun) component and firmata in the next few weeks. Best, Jason

November 17, 2011 | Unregistered CommenterJason K Johnson

Hi Jason

can you share the easy driver library to download or where to download it. so many information from google...
thanks !!


January 4, 2012 | Unregistered CommenterChia

HI Jason
I got the same problem as Hunter got. My EasyDriver.h and Easydriver.cp both in the folder named EasyDriver which is under libraries folder.

C:\Program Files\arduino-1.0\libraries\ EasyDrive

and I still got

EasyDriver_Stepper_Pot_Firefly_18_Mar_2011.cpp.o: In function `__static_initialization_and_destruction_0':
C:\Users\Chia\AppData\Local\Temp\build8906309480724427889.tmp/EasyDriver_Stepper_Pot_Firefly_18_Mar_2011.cpp:31: undefined reference to `Stepper::Stepper(int, int, int)'
EasyDriver_Stepper_Pot_Firefly_18_Mar_2011.cpp.o: In function `serialread()':
C:\Users\Chia\AppData\Local\Temp\build8906309480724427889.tmp/EasyDriver_Stepper_Pot_Firefly_18_Mar_2011.cpp:173: undefined reference to `Stepper::setSpeed(long)'
C:\Users\Chia\AppData\Local\Temp\build8906309480724427889.tmp/EasyDriver_Stepper_Pot_Firefly_18_Mar_2011.cpp:174: undefined reference to `Stepper::step(int)'

any something wrong I did ?

thanks, Chia

January 4, 2012 | Unregistered CommenterChia

Hi Chia,
I was actually working on this today. I've developed a new Firefly Firmata (for steppers) which doesn't require the use of the Easy Driver library. I've only tested it for one stepper so far, but I'm working on adding up to four steppers. There's a new Firefly component that accompanies this Firmata which controls the position of the stepper. I still have some more testing I want to do, but it's possible I could release a new version sometime next week. If you're interested in beta testing this version, email me (andyopayne@gmail.com) and I'll try to send you the build files when they are ready.

January 4, 2012 | Registered CommenterEditor

hi Jason

me again : /
I solve the problem of library setting up, but I still cannot make my motor work. I follow the all introduction, lights on easydriver looks work fine,

Does anyone have a idea to give me a hand ?

will thanks a lot !!!


January 4, 2012 | Unregistered CommenterChia

What type of stepper motors are you using? (The EasyDriver doesn't work with 5 wire steppers). Also, you'll usually need a power supply (8V to 12V, 30V max) that provides at least 1 to 1.5 amps per motor.

January 5, 2012 | Unregistered CommenterJason K Johnson

is there a way to control stepper motors with firefly but using a uln2003 chip ??I can't seem to find a arduino firmata that works wit firefly. Thanks

November 4, 2012 | Unregistered CommenterAndrew

Hi! Thanks for Firefly, its really amazing what you are doing.
I am having a problem connecting a stepper (tried both Nema 17 with EasyDriver and 28byj with uln2003) to the component Uno Write in Firefly. The problem is that when i give Easydriver a step signal with any kind of delay (1000-1ms), the motor reacts, but with kind of sinusoidal power and maybe slower, same happens with the other motor, if i give appropriate signals. If i do the same thing coding Arduino directly, everything is ok. Could it be that signals somehow resonating? Or the driver just lacks power?
The reason why i cant use Quad stepper component of Firefly is that i need to get smooth non-linear movement from steppers, and 5 axes cant be described as xzy coordinates, so i cant use any program, which is sending g codes directly. Or maybe i am wrong?
Thank you in advance.

March 23, 2013 | Unregistered CommenterAlex Dembo

Hey Alex,
I am working with some students this semester on a new set of example files (using Firefly to run a hacked 3d printer) that should help folks figure this out. In the meantime - using the Quad Stepper Motor Setup component you would need to dynamically feed the Spd (speed) and Acc (acceleration) to get your smoothing non-linear movement. You can easily simulate this in GH but you'll need to use math components or the Graph Mapper / Graph Type / Conic or other. For something simple like a 3d printer you can easily use XYZ to describe the position of the tip of your printer or robot. For a 5 or 6-axis robot - where you must know the position of all your parts and solve the inverse-kinematics of the arms. I rec looking into Daniel Piker's new Lobster component: http://www.grasshopper3d.com/group/lobster

If your motors are unexpectedly delayed - one thing to try is to adjust the little potentiometers on the Easydriver board. (getting technical here and quoting the Easydriver spec) --- The voltage spec of the motor doesn't really matter, using the EasyDriver. (Or any chopper driver, for that matter.) The EasyDriver will ramp up the voltage to the coil until the _current_ reaches the maximum set with the pot (max of 750mA). Then it will cut the power to the coil until the current dips down again, then re-apply power, over and over again, about 20,000 times per second. Any motor that's rated for 150mA/coil (or more) will work with the Easy Driver just fine, no matter what it's voltage rating. If your motor is rated for less than 750mA/phase, you should adjust the current set pot on the EasyDriver to dial down the maximum coil current to match your motor.

Good luck, Jason

April 8, 2013 | Unregistered CommenterJason Kelly Johnson

Hey, thanks, that really worked! And lobster thing is really cool and just the case i need further. Looking forward to hear about the hacked printer project, if its going to be published:)

May 11, 2013 | Unregistered CommenterAlex

Hi Jason,

Firefly is an amazing application - I've really enjoyed playing around with it.

I'm sorry if I'm a bit slow with this but I'm having a very similar question to Alex's. I'm having no problem getting the stepper motors hooked up and running, and feeding speed & acceleration dynamically.

What I don't understand is how to use the Quad Stepper Motor component if I want feed different speed and acc. to steppers controlling the x and y axis? ie. since there is only one speed and acc input for all 4 motors?

Thanks so much for your help!

April 28, 2014 | Unregistered CommenterDel

Thanks for your email. You can see projects from my CREATIVE ARCHITECTURE MACHINES studio at CCA using the QuadStepper component here.

Also here is a great Instructable for a clay deltbot style 3d printer created by my students at CCA San Francisco.

Right now the speed and accel are the same for all motors. We know this is an issue that we can hopefully correct in an upcoming release.
Cheers, Jason

April 29, 2014 | Unregistered CommenterJason Kelly Johnson

Hi Jason,
I've got a project I'm working on at the moment which I'm hoping to utilize Firefly to drive 2 separate stepper motors. I'm using 2 NEMA 17 Bipolar steppers, each controlled with their own Big Easy Driver from SparkFun. I've seen that the recent CCA studio project is utilizing the Firefly firmata to interface with the QuadStepper, will it also work to control two Big Easy Drivers?

Many thanks,

May 27, 2014 | Unregistered CommenterSean

Sean, Yes that should not be a problem. Wire it up like this: http://www.schmalzhaus.com/EasyDriver/Examples/Example4_bb.png. According to this diagram you'll be using what we define in the Quadstep Firmata / Firefly component as Motor 3 (Arduino Pins 6+7) and Motor 4 (Arduino Pins 8+9). Good luck!

May 27, 2014 | Unregistered CommenterJason Kelly Johnson

Hi Jason,

Thanks so much for your earlier reply - your links to the projects from your CAA class and their instructables page were very helpful!

I've been making progress on my project and have come to another question regarding the setup of the Firefly Firmata.
I'm pretty new to Arduino programming so I'm sort of learning through this project so I apologize for the basic question:

For the machine I'm working on I'm using the Firefly Quadstepper component but I'd also like to use Digital Pins 12 and 13 through the Uno Write Component to turn on and off some solenoids.

I've been working on combining parts of the Firefly Quadstepper Firmata with the UNO Firmata and have made some progress - but once I start running the stepper motors on the machine the switching for DPin's 12 and 13 becomes unreliable, ie they actually turn on and off about 75% of the time that I switch them in firefly.

I think my problem has to do with not entirely understanding how serial buffering works and also the difference between using the serialevent() function to initiate the serial read (as in the FIrefly Quadstepper Firmata) vs. just calling a serialread() function within the main loop (as in your Arduino Uno firmata).

Currently my sketch is using both of these, the serialevent() for the stepper motor function and then calling a serialread() called within the main loop for DPins 12 and 13. I'm also using all of the same variables for buffering the serial streams coming from both of these functions. Not sure if this also might be causing the problem?

OK, please let me know if that makes sense.
This would seem to be very similar to the way your students Delta robot employed Pins 11, 12, and 13 for the limit switches.

Thanks so much for all of your help with this!
All the best,


May 28, 2014 | Unregistered CommenterDel

Hey Jason,
Thanks for the hookup suggestion on my previous post, firefly is driving my stepper motors! However, it seems to be driving them very sporadically. I see from the Stratum Networks Delta Robot definition that the motors are being fed continuously changing values. Can you help clarify for me how the Stepper Motor wants to be receiving data via Firefly's Stepper component?

That is, do the M1, M2, etc. inputs want to be receiving incremental step numbers or absolute step numbers? If I want 2 full revolutions for instance, do I feed just the static value # of steps that equates to 2 revs, or do I break it down and give it continuous, incremental steps? And if so, how does the speed input value fed into Stepper component relate to the incremental rate at which the values to M1 are being fed?


June 6, 2014 | Unregistered CommenterSean

Hey Jason,
The gh. definition and firmata link in your first post is not available anymore. Is there an updated version? It is so great the information ou provide here!!!
I have been following your works with your students recently and I am super impressed! I am doing my masters in Computation in Architecture in the Royal Danish Academy of Fine Arts, School of Architecture- CITA( CENTER FOR INFORMATION TECH. AND ARCHITECTURE).
My ongoing research project is about 3dprinting using a medium sized industrial robot arm. I am in the beginning of my thesis; so I am still dealing with the technical issues like controlling the stepper of my little printhead with Arduino + Firefly; so that I wanna combine the robots GCODE to my design.

May 7, 2015 | Unregistered CommenterASYA

Hey Jason,

In the firefly Is possible to control 3 servo and 3 stepper motor at the same time in the firefly?And in the arduino should I open firefly_ Firmata or firefly_quadstepper?

For example :

stepper 1 - Dir To Arduino Pin 2; Stp To Arduino Pin 3
stepper 2 - Dir To Arduino Pin 4; Stp To Arduino Pin 5
stepper 3 - Dir To Arduino Pin 6; Stp To Arduino Pin 7
servo 1 - pmw To Arduino Pin 8
servo 2 - pmw To Arduino Pin 9
servo 3 - pmw To Arduino Pin 10

thanks ~

February 2, 2016 | Unregistered CommenterALI-HAUNG