Scratch GPIO Version 2 – Using Stepper Motors

Stepper Motors


However, if you would like to build a neat little vehicular robot then you can do so by connecting up a pair of cheap Stepper Motors through a couple of very cheap ULN2003s.

The cheap 5V steppers that are widely available (BY28) don’t turn very fast (maximum about 12 RPM) which actually makes them idea as beginners motors as your vehicle won’t run away during testing 🙂

These motors have 5 connections, 1 for power and the rest to control the stepping.  (Their technical name is 5 Wire Unipolar Stepper Motor)

To use them in Scratch, you need to connect them up as follows

Stepper Motors Battery_bb

StepperA should end up (via the ULN2003 buffer of course)  being controlled by pins 11,12,13 and 15 – Stepper B  is via pins 16,18,22 and 7.

Pin 9 of the ULN2003s should be connected to +ve on the motor battery pack.

(The battery +ve MUST NOT be connected to any pins on the Pi)

stepperIn your Scratch program, you need to say that you are using Stepper motors instead of ordinary motors this is simply done by broadcasting Stepper in your Green Flag code block.

You can then simply using variables MotorA and MotorB as before with simple DC motors but this time they will each control 4 pins at a time.


The advantage of using stepper motors is that they can be just as easily stepped backwards as forwards.  So to make MotorA go backwards at full speed simply use set MotorA to -100

Position Control
As well as treating the stepper as a continuously rotating motor, you can simply tell the stepper to change its “position” by a number of steps.

e.g. To turn 500 steps (approx 180 degrees on my motors) use posa

Note the use of change and not set

Part 4 – Direct Support for External Modules/Boards

Advanced Stepper Control

Stepper motors need a delay between each step – this is currently set to 0.003 secs.   You can control this value by using a variable called StepDelay.

You can also change the type of stepping mode from 2Coil (default value that gives maximum turning force) to 1Coil or HalfStep

You may also like...

82 Responses

  1. folknology says:

    Hi Simon

    Helpful article, you can improve your circuit further (and make it friendlier for the RaspberryPi) by adding a few extra noise reducing components.

    Instead of using a wire from the 5v to the bread board, use a small inductor (low resistance) and add an electrolytic ALU cap across the breadboard supply rows (make sure it goes the right way around as these are polarised). You could also add a small 100nf (0.1uf) cap in parallel and add one each for the driver chips between their common and ground pins as lose as possible.

    The small caps will reduce higher frequency switching noise locally on the drivers and the supply, the electrolytic acts as a local storage and filter, the inductor will help form a pi filter between the noisy motor circuitry and the RaspberryPi making nasty noise less likely to damage to it or interrupt it unexpectedly.


  2. Chris Roffey says:

    Thanks for these helpful tutorials. I have got the LEDs and the motors working fine but I am having a spot of trouble with the stepper. Using the same IC, I have managed to get the stepper to work with an arduino OK but with my Pi, it buzzes for a short while then stops without ever moving. Am I correct that with only one stepper motor the program only needs these three lines to make it turn continuously?

    when green flag clicked
    broadcast StepperA
    set MotorA to -100

    I am also a little unsure about the pin numbering (I am using a model B, v1 Pi at the moment): Diagram above appears to have the numbering: Orange,Yellow,Pink & Blue to 12,11,13 & 15
    whereas the description says it should be: Orange,Yellow,Pink & Blue to 11,12,13 & 15

    I am using your numbering system not the official Pi pin numbers. Does your numbering system (that is much more logical) still work for a Model B, v2 Pi?

    Can you spot what I am doing wrong? Best wishes, Chris

    • cymplecy says:

      The diagram is wrong – sorry 🙁 (I’ll get onto amending it PDQ!)
      The stepper should be connected to 11,12,13 and 15.
      There are 2 numbering systems for the Pi – the physical pin number (which is what I use) and the one that refers to a broadcom internal numbering (Physical Pin 11 in called GPIO17 in that scheme).
      The software automatically handles which revision of board is being used 🙂
      Come back again if it still doesn’t work.
      (Previous to V2.8 the software didn’t handle any extra spaces in variable values but its a lot more relaxed now )

  3. Chris Roffey says:

    Thanks, all is working now!

  4. Nigel Ferguson says:

    Could you help me write a small python program that can control stepper motors WITHOUT the use of Scratch? For example, you launch the python program, it asks you what speed you want to set MotorA to, then what speed you want to set MotorB to, then runs the motors at that speed until the program is quit?

  5. Kieron says:

    Hi Simon, very nice work. Im currently using it with yrs 4, 5 & 6. Shortly they’ll be learning about stepper motors. I wondered if you could help me. I am thinking that a different wiring layout would help the younger children get the correct colored wires in the right holes. Could you tell me how I can use different pins than those used ? For Stepper A I would like to use pins 15,13,11 & 7 – straight across the top. For Stepper B I would like to use pins 22, 18, 16 & 12 – straight across the bottom. It would help me a lot if you could give me some advice, thanks.

    • cymplecy says:

      I’m afraid I’ve hard coded which pins are used, if your up to it, feel free to edit the python prog. Wiring up the steppers wasn’t on my plan for the pupils to do 🙂

      • cymplecy says:

        I’ve had a quick look and if you find this section in the file
        if ('steppera' in dataraw) or ('turna' in dataraw):
        if (stepperInUse[STEPPERA] == False):
        print "StepperA Stasrting"
        steppera = StepperControl(11,12,13,15,step_delay)
        stepperInUse[STEPPERA] = True
        turnAStep = 0

        if ('stepperb' in dataraw):
        if (stepperInUse[STEPPERB] == False):
        print "StepperB Stasrting"
        stepperb = StepperControl(16,18,22,7,step_delay)
        stepperInUse[STEPPERB] = True
        turnBStep = 0

        if ('stepperc' in dataraw):
        if (stepperInUse[STEPPERC] == False):
        print "StepperC Stasrting"
        stepperc = StepperControl(24,26,19,21,step_delay)
        stepperInUse[STEPPERC] = True
        turnCStep = 0 #reset turn variale

        You might just get away with chaning the pin numbers assigned here
        But no guarantees it won’t affect other things
        Pins 3 & 5 should be left alone as they have pull-up resistors on them and didn’t work when I tried them out as contenders for Stepper C use

        As long as you don’t use Stepper C , you should just leave that bit of the code alone


  6. Kieron says:

    Thanks Simon I’ll give it a go either today or tomorrow. Im only wanting to use StepperA and StepperB. Thanks again for your hard work on this its pivotal to what I do, the club wouldnt exist without it and the kids do so enjoy lighting up LEDs and spinning motors. The stepper part will enable me to build a £10 Scratch programmable robot that Im sure they will love.

  7. Mike Simpson says:

    Hi Simon, after success with your design for driving dc motors using the ULN2003 chip I have been trying to get a (28BYJ-48) 5v stepper + ULN2003 board working properly without much success.
    Must have check the wiring 100 times. It sort of works intermittently and also vibrates. Power supply is not the issue here. I was wondering if you tested these steppers with “version 3” of your GPIO program as your website material looks to be written for “version 2”.

    In any event, I found a website in one of your blogs ( that you recommended to someone looking for a python stepper program. Copied the program (by a Mat Hawkins) and changed the GPIO pin #’s to match yours. It works very well which confirms my wiring.

    I would much prefer a working Scratch version for an upcoming grade school demo as part of our “National Engineering Month” activities on this (very cold) side of the pond (Ontario). Yours has both speed control and revolution control. (is your parameter “StepDelay” req’d in secs or msecs?)

    Maybe “version 4” is the answer – does downloading it replace “version 3” or is the removal of same a manual process?
    Regard Mike S.

    • cymplecy says:

      Version 4 installs separate from Version 3 – there was a recent bug-fix to steppers which is still only in the development version so I recommend downloading that one instead and also note that you now just broadcast Stepper to intialise them. Follow this comment for the full tale

    • cymplecy says:

      PS StepDelay should be in secs but default is pretty much spot on for reliable use of those little steppers – you can try reducing it but make sure you’ve a good PSU and you’ll prob only get another 10% speed out of it

      • Mike Simpson says:

        Simon, many thanks for the Scratch GPIO4 download URL. The download produced two new Scratch GPIOs – GPIO4 & GPIO4plus. Unfortunately neither worked for the stepper control. In fact after some logic state testing it was clear no actual GPIO outputs were being generated by either version. After “quitting” each Scratch session I returned to GPIO3 to make sure the original DC motor control still worked. Was more than a bit concerned that It did not until I decided to “quit” the X-window environment and restart it via the command line “startx” and reload ScratchGPIO3 again. This did the trick as the DC motor control pgm thankfully worked as before. Likely some sort GPIO version interactions going on somewhere behind the scenes that impacts the GPIO I/O??

        After all of the above I refreshed the entire system via apt-get update && apt-get dist-upgrade and tried everything again. Unfortunately, nothing had changed for the GPIO4s. So I’m not too sure where to go from here with the steppers except the Mat Hawkins’ Python stepper, which isn’t the way I hoped to go.

        Any thoughts?
        Mike S

        • cymplecy says:

          Just a bit of info. You can’t run V3 after running V4 in same session as V4 stuff still controlling gpio port. You should be able to run V4 after V3 as V4 should kill any previous running versions but best to play safe and keep to one version per reboot 🙂 Just as a matter of interest, are you running as normal pi user when you log onto your Pi? Simon On 12 Feb 2014 03:51, “cymplecy (simplesi)” wrote:


  8. Mike Simpson says:

    Simon – thanks for the quick Feb 12, 2014 (9:36 am) reply. Interesting info on running V3 and V4 and confirms my experience here. Reboot its is. Regarding Logon: running as a normal Pi user (logon: Pi + my-password). Pi is a v2 512MB, actually a new UK made one. Also have several older V1 256MB Pi’s I use and also have tried these with the stepper. I’m determined to wrestle this one to the ground as I like your Scratch approach for demo’s to young grade school kids. Regards Mike S.

    • cymplecy says:

      I’m going to power my stepper not up tonight and see what the issue is
      Do you have any other hardware that you can plug in just to prove that the software is basically v working such as a led and resistor?

    • cymplecy says:

      Great apolgies 🙁 I introduced a new add-on to the dev version but forgot to make sure some extra support files were added to the install – so of course it works in my developement playground but not as a replacement for the stable version 🙁
      I will hopefully sort this out shortly and get it up an running again.

      It also explains why someone else who I directed to dev version is having issues with something else 🙁


      Off to fix


    • cymplecy says:

      Should be fixed now – try the dev link again

      I’m going to be more careful in future and create a dev dev branch and play in that and make the dev branch more of an beta/RC release status 🙂

      Thanks for persevering and getting me to sort my shizzel out :0


      • Mike Simpson says:

        Simon, does re-downloading it overwrite what is currently on my Pi (GPIO4 and GPIO4plus)?

        Does it have a “package” name in the cache so I can delete what is there now. I did screen dump of the cache but no package had a name that implied it was scratchGPIOx or similar
        Mike S.

        • cymplecy says:

          Yes. Re downloading and reinstalling deletes all old v4 files and creates new ones. Doesnt touch anything outside of scratchgpio4 folder apart from desktop shortcuts. Don’t know what you mean by cache

  9. Mike Simpson says:

    Simon – that’s great then if it deletes the “old”.

    I see now where your GPIO stuff is. I thought perhaps it was installed as a “package” – see below.

    “cache” is essentially a list of all the available s/w “packages” that can be installed with “apt” (e.g on the web). Debian use “apt” as the package manager. “apt-cache” is a utility for managing the cache
    e.g. apt-cache search xxxx Searches and lists s/w packages with xxxx in their name.
    dpkg –list Generates a list of all s/w packages installed on the system

    I am certainly no Linux expert but learnt about the above from Eben Upton’s Raspberrypi User Guide (ver 1) and from a very good and readable Linux book called “The Linux Command Line” by William Shotts.

    There also are tools like Aptidue which is a package manager that allows for e.g. deletion of a package(s) and a lot more. I have it but have not really done much with it. I tend to follow the KISS principal where possible. You very likely know all this anyway.

    Mike S

    • Mike Simpson says:

      7:30 pm EST
      Simon, have now tried the new GPIO4. We are not there yet but some signs of progress.
      On invoking the scratch pgm (see end), the stepper does not turn but now at least one of the 4 inputs is activated (have LEDs on all 4 ULN2003 inputs). The input from Pin11 (Orange) is ON. The pgm is frozen with all the other pins OFF. The ULN2003 module is identical to the one shown in Mat Hawkins (Raspberry Pi Spy) stepper write-up where his ULN2003 inputs are IN1, In2, IN3, IN4. My pin assignments are: IN1 (Blue, Pin 15), IN2 (Pink, Pin 13), IN3 (Yellow, Pin12), IN4(Orange, Pin11).

      Scratch pgm
      1) When “Flag” checked
      2) Broadcast Stepper
      3) Set MotorA to N (N=0, 10, 20,….90,100)

      Hope this helps somewhat……lets battle on.

      Mike S

      • cymplecy says:

        Ok reboot and try invoking the system from LX terminal
        open LX terminal and type
        sudo ./scratchgpio4/
        once scratch is running click back to looking at the terminal window
        Are there any errors showing?

  10. Mike Simpson says:

    Simon, yes there is an error. LX terminal text as follows:
    There was an error connecting to Scratch!
    I couldn’t find a Mesh session at host, port: 42001
    The above 3 lines repeat on the screen ad infinitude……..

    • cymplecy says:

      Yes. You hence to kill it from another session when it’s run this way. Did Scratch launch?
      This is extremely puzzling

      • Mike Simpson says:

        Simon, no scratch did not launch. The 3 text lines just kept repeating on the screen.
        Mike s

      • Mike Simpson says:

        Simon – it seems to be telling us it cannot find in folder scratchgpio4
        Mike S

        • cymplecy says:

          Dear god and little fishes as my granny might have said!

          it must be finding as we tell it to run and it runs 🙂
          ca nyou cd /home/pi/Documents and do ls to see if there is anything in it
          Can you then cd Scratch Projects then ls and see if anything in it ?
          Is in there?
          Can you cat /home/pi/scratchgpio4/ and see if the last lines says
          scratch — document “/home/pi/Documents/Scratch Projects/” &

          You are running this on a Raspberry Pi? 🙂

      • Mike Simpson says:

        Simon…more….doing an ls I see DIRs for among others, scratchgpio and scratchgpio4.

        Scratchgpio4 DIR contents are:,,,,, sgh_Stepper.pyc plus some Adafruit files (5) and

        Scratchgpio DIR contents are:,, 3 x Adafuit files, servomotorpitx and servodpirocom

        Hope this helps somewhat…
        Mike S.

        • cymplecy says:

          Carry on with the questions I asked but also compare this ls of my scratchgpio4 setup
          Adafruit_PWM_Servo_Driver.pyc sgh_servod

          with yours – ignoring .pyc files as there are irrevalavent


  11. Mike Simpson says:

    Simon, difficult to stop this process, CTRL-C and CTRL-Z do not work. I would use KILL or TERM if I could get to command line, which I cannot. I will just power the Pi down. ( last reply should read “infinitem” not what my iPad decided to change it to!
    Mike S,

  12. Mike Simpson says:

    Simon – re your 7:39pm reply. The text displayed is exactly as I show in the 3 text lines in the my 6.02 pm reply. I entered the command line exactly as per you 7:18 pm reply. There was no “standard ………” Text. Is this what you asked!

    Documents – contains some of my stuff including Scratch Projects and RPi.GPIO-0.4.1a

    Scratch Project – contains some of my stuff plus

    Mike S.

  13. Mike Simpson says:

    Simon – yes, I am indeed running this on a Pi (new rev 2 one)
    I think our responses may be overlapping.
    Mike S.

    • Mike Simpson says:

      Simon – copy/paste of, I’m on the Pi now to be able to do this:

      #Version 0.2 – add in & to allow simulatenous running of handler and Scratch
      #Version 0.3 – change sp launches from “/home/pi/Documents/Scratch Projects”
      #Version 0.4 – 20Mar13 meltwater – change to use provided name for home
      #Version 1.0 – 29Oct13 sw – change to cd into simplesi_scratch_handler to run servods OK
      sudo pkill -f scratch_gpio_handler*
      sudo pkill -f scratchgpio_handler*
      cd /home/pi/scratchgpio4
      sudo python standard &

      Mike S,

      • Mike Simpson says:

        4:04 pm EST
        Simon – confirming that our scratchgpio4 DIRs contain identical pgm names/extensions.
        Mike S

      • cymplecy says:

        Hi Mike
        Some of your answers don’t seem to match with my questions but nevertheless we are finally getting there.

        From all the evidence it would seem that instead of my script launching the rprog and then running Scratch – its is only launching the handler.

        for some reason, my installer has not created the correct script
        can you delete /home/pi/scratchgpio4/
        then make sure you are back in /home/pi
        run the download again
        sudo wget -O
        run the installer
        sudo bash
        then cat /home/pi/scratchgpio4/ and make sure the last line reads
        scratch –document “/home/pi/Documents/Scratch Projects/” &

        it it does – then just launch ScratchGPIO4 from desktop
        IF IT DOESN’T then cat /home/pi/scratchgpio4/
        if the last line of that reads
        scratch –document “/home/pi/Documents/Scratch Projects/” &
        then launch ScratchGPIO4plus icon from desktop


  14. Mike Simpson says:

    4:45 PM EST
    Simon – carried out all of your instructions except to launch the icon. Confirming that the last line of does indeed read as (copy/pasted it):
    scratch –document “/home/pi/Documents/Scratch Projects/” &
    I will give it try next but have to go out for a few hours.
    Thanks for all this. If you did not get all your questions answered likely due to our reply sequencing and multiple phone calls i was receiving.
    Mike S.

  15. Mike Simpson says:

    4:44 pm EST
    Simon, well after all that I am sorry to report that the stepper still is not stepping. As before its just pin11 that comes ON (LED lit) and stays on. Based on my experience with the python stepper pgm (went through Mat Kings code) it looks like the scratch pgm is not, for some reason, sequencing through the repeating 4-state sequence of (1000, 0100, 0010, 0001) which, as I’m sure you know well, turns on/off the 4 pin ULN2003 inputs/outputs in this sequence.
    Does all this work at your end? if it does then I’m really “concerned”.
    Got to go out.
    Mike S.

  16. Michael says:

    I would go over the connections again if I were you. I am working off a recent download of scratchgpio4 stable version and I have two stepper motors working both with MotorA/B and PositionA/B. The only difference from Simon’s diagram is that I am using a ULN2803 which has 8 outputs so I can drive both motors off the same chip. I am using an old calculator charger as the external power supply but I have used a 4xAA battery pack also.
    I had problems originally simply from mixing up pins 11/12 and I got the sort of symptoms you described further up – half- running. I was also the person who got caught up in the change from broadcasting “StepperA” to just “Stepper” that Simon referred to above.
    I hope this is some help in confirming that the current stable version works.
    I am running on a rev2 board made in China.
    I hope you get sorted out, it is very frustrating going through the problems but there is great satisfaction when it finally works!

    • Mike Simpson says:

      Thanks Michael. Yea, I am getting a bit disheartened here. I think Simon’s had enough, he’s been extremely helpful. At least the Python program works. I’m familiar with the ULN2803. I am very heartened though that it’s working for you with two steppers. I also have two steppers that each came with uln2003 boards and LEDs (EBay from a US supplier). I have checked the wiring “n” times where n is approaching infinity. My DC motor is working well through Scratch using the SN754410 H-bridge. With it it’s easy to also change the motor spin direction. I think next I will download the most recent Raspbian and cut a new SD card; although I did update it a fews back with apt-get update/upgrade etc so in theory all should be well. We’ll keep on truckin’
      Mike S.

      • cymplecy says:

        Right – you say your boards have LEDS?

        Lets see if we can get them to light up

        Try this
        On GreenFlag
        broadcast pin11on
        wait 1
        broadcast pin11off
        wait 1
        broadcast pin12on
        wait 1
        broadcast pin12off
        wait 1
        broadcast pin13on
        wait 1
        broadcast pin13off
        wait 1
        broadcast pin14on
        wait 1
        broadcast pin14off
        wait 1


  17. Mike F says:

    Hi Simon,
    In GPIO4:

    When green flag clicked
    Broadcast Stepper
    Set MotorA to 100

    This turns LED A on but nothing from the motor. Any ideas?

    • cymplecy says:

      Hi – can you re-download V4 again and re-install it please as I had a bug in there thats been recently fixed 🙂
      Then try again and see what happens
      if it doesn’t work on 2nd time try this
      On green flag
      broadcast pin11on
      wait 1
      broadcast pin11off
      wait 1

      and see if the led blinks

    • cymplecy says:

      Hi Mike
      Sorry about this – having a bit of problem with my versions
      I just MADE SURE this time that the normal version has the bug fix in it.
      So I’ve just updated it at 12:43 – so make sure you download again after that time



      • cymplecy says:

        And yet again – I forgot to press a button 🙁
        Ok now at 12:48 – definetely all I’ll eat my RPi !!!!!!


        • cymplecy says:

          I think I need to hand in my 25m Programming Certificate 🙁

          My RPi was a bit chewy but its now eaten 🙂

          The version available from 13:06 onwards WILL DEFINITELY WORK or I’m packing it all in 🙂

          One things I’ve learnt – don’t put different versions of code in the same folder – this WON’T happen again 🙂


  18. Mike F says:

    Hi Simon,
    Yes, the LED blinks.
    Broadcast Stepper
    Set MotorA to 100
    now does nothing (no LED turned on) and if I re-try the pin11 blink afterwards this no longer does anything.
    Mike F

  19. Mike F says:

    Right oh! Can you tell me where to find it?

  20. Mike F says:

    Simon – That’s brilliant – my motor is spinning! 🙂
    I think I may have mis-interpreted your instructions above as I’ve realised the ‘broadcast stepper’ block has to be activated first under a separate ‘when …’ block from ‘set MotorA …’

    Now to experiment with a second motor attached! 🙂

    Many thanks Simon for your time and help!

    • cymplecy says:

      I jsut simply do
      On Green Flag
      broadcast Stepper
      Set MotorA to 0
      Set MotorB to 0

      And then use something like

      When UpArrow pressed
      Set MotorA to 100
      Set MotorB to 100

      When DownArrow press
      Set MotorA to -100
      Set MotorB to -100

      Note the Scratch “feature” – if a variable isn’t changed (even from 1 GreenFlag event to another) then its value will not be resent so therefore no change occurs to Motors etc

      So I always make the GreenFlag event reset back to 0


  21. Lisa says:

    Hi! I’m a complete freshie to this and I’m trying to get two steppers to work but no luck 🙁 I was wondering where the battery supply is supposed to be connected in the diagram above if there are two ULN2003s? Because the motor diagram with the battery supply consisted of only one ULN2003

    P.S. how do you know if the RPi is damaged? Will it not turn on or something?

    • cymplecy says:

      Hi the diagram shows the motors powered from the Pi itself but in retrospect I should have shown a battery powered setup and then moved onto the self-powered version (as you really need to power your Pi through the main USB and not the micro-USB. Anyway – to power using a battery – disconnect the red wire going from the 5V pin on the RPi to the breadboard (the far right red wire) Then you can safely connect a battery -ve wire to the same horizontal row the black wires are connected to (the top one) and connect the +ve side of your battery to the 2nd horizontal row that the red wire from the Rpi used to be connected to.

      I’d recommend just getting one stepper going first

      Re-damage to your RPi – so many different ways of blowing it up – sometimes it will not power again – sometimes just one of the pins won’t work properly but everything else will.

      Lots of people manage to wire things up but the secret is small steps – this is part 3 of my learning sequence 🙂




      • Lisa says:

        thank you for the new diagram si! i think i have connecting all properly now 🙂 but the only thing is i cannot get the motors to function. i have check the voltage of each wire and of the motor and the all show a voltage so i’m guessing they are broken or anything but i can’t seem to get Scratch instruction working with the steppers 🙁

        any ideas where it could have potentially gone wrong?

        • cymplecy says:

          Steppers are proving to be the bane of my life 🙂

          switch off and on and then start again with this

          On greenflag
          broadcast AllOff

          On Spacebar
          broadcast pin11on
          broadcast pin15off
          wait 0
          broadcast pin12on
          broadcast pin11off
          wait 0
          broadcast pin13on
          broadcast pin12off
          wait 0
          broadcast pin15on
          broadcast pin13off
          wait 0

          which manually simulates what the stepper code is doing

      • Lisa says:

        sorry my typos are really bad! i meant that i cannot get the stepper to work with Scratch and also that i’m sure there aren’t any broken wires since i have checked the voltage across each of them

      • Lisa says:

        Thanks si but still no luck 🙁 This is so stressful, I don’t know where it has gone wrong :/

        • cymplecy says:

          Well – like I said before – this is step 3 – its hard to remote work out what’s going on as we don’t know if step 1 works. (blinking an LED)

          If you are up for a bit of geek stuff we could try running things manually and see if we can find out more info.
          Switch off and on (Very important)

          Load in normal Scratch (NOT SCRATCHGPIO)
          File Open then find and open it.
          Click on Enable Remote Sensor Connections

          Minimise Scratch
          Run LX Terminal and then type the following

          cd scratchgpio5

          sudo python

          Can you take a picture of the screen and email it to me

          (or copy and paste on here what you see?)


      • Lisa says:

        Okay I shall have a go at that but ill have to email you later as I have to go to school now 🙂

      • Lisa says:

        When I open it says file may be damaged, cannot read. ..

        Can I download it from somewhere?

        • cymplecy says:

          Aah – that’s implying somethings got a bit corrupted somewhere
          Can you re-download and re-install ScratchGPIO5 and try the above again?
          If you email me your address (and your in UK) I’ll lendyou a pre-made board with LEDs on that you can use to test


      • Lisa says:

        Thank you for all the help si! But like you said I have dived into the deep end so I shall try your tutorial for just a simple motor first after asking my school for one and see how I can get on
        Thanks again sorry about all this nonsense!

    • cymplecy says:

      I have now updated the instructions and diagram to show the steppers being powered from an external battery which is much more appropriate for beginners

  22. mrteach says:

    How do you change coil modes?

    • cymplecy says:

      I’ll just answer this one 🙂
      Maximum speed of those little steppers is about 12rpm

      to change coil modes
      broadcast 2Coil (default – gives more torque)
      broadcast 1Coil
      broadcast HalfStep
      (default value that gives maximum turning force) to 1Coil or HalfStep

  23. mrteach says:

    found a problem with the handler. it keeps erroring out when using SID (undefined stepmode as variable I think it is because you use stepmode instead of 1stepmode).

    I tried erasing the error (as it seems like it just a ‘print’ command and switching to half-step mode but doesn’t seem to do anything. wheel spins at the exact same speed.

    well on arduino I got a full rotation with a wheel at 4s compared to 7s with the pi. the arduino was in half-step mode.

  24. Ariean says:

    Hello Simon, is it possible to control stepper motors with Scratch GPIO using a adafruit stepper motor HAT?

    • cymplecy says:

      Unfortunately not as that HAT is a bit complicated hardware wise (and I’ve not got one to develop support for it)



  1. 26th April 2013

    […] Scratch GPIO Version 2 – Using Stepper Motors: […]

Leave a Reply

Your email address will not be published. Required fields are marked *