ScratchGPIO8Beta

I’m pushing out a beta version of ScratchGPIO8 for testing

New Features

Calling external programs

broadcast run python test.py

will run an external program (in the /home/pi folder) called test.py

Improved H-Bridge motor control

Just find out which 2 pins control your H-Bridge motor and create a variable to control its speed from -100 to 100

e.g PZM motor Shim uses the pins 35/37 and 36/38  so just create 2 variables

Motor35,37

and

Motor36,38

 

You may also like...

25 Responses

  1. Katrina says:

    Hi Cymplecy,

    I’m currently developing a robot kit (based on the raspberry pi) to be used in classrooms. I’ve found your GPIO examples very helpful but my employers would like me to develop some blocks which make GPIO easier for younger students.

    I was wondering if you could point me in the right direction for adding custom blocks?

    Katrina

    • cymplecy says:

      THere are 3 mthods go to about this
      1. Learn Squeak and modify Scratch directly – hardest – can’t really help with that

      2. Use BYOB -a scratch mod to make your own custom blocks – very easy but is a bit slow compared to Scratch

      3. Use Whiskers to make your own blocks – its still being developed and not as flexible as BYOB but looks/feels like Scratch 2

      Simon
      BYOB http://snap.berkeley.edu/ scroll down to find BYOB download

      • Katrina says:

        Hi again,

        I’m having a look at them and I don’t think any of them really suit my needs. I was under the impression that you wrote code in Python and somehow linked that to scratch?
        That would be awesome if it’s possible, Squeak is a nightmare!

        Katrina

  2. Christian says:

    Hi Cymplecy,
    is there any way to control a 16×2 LCD with ScratchGPIO? I don’t want to use Pi_Scratch again 😉

    • cymplecy says:

      em – the PiAndBash add on board has a 16×2 LCD – if yours is same type as that one then your in business.

      If not – come back to me with your model number

  3. Christian says:

    Hi,
    I could not find out, how the LCD is connected to GPIO-Pins on the PiAndBash. There is no scheme and many of the links on their site, linking to pinventor are broken. The LCD is the same standard type I would use (HD44780). I would connect it directly to GPIO with 4 data wires (D4-D7) and 2 control wires (RS,E) without any additional hardware like I2C controllers.
    I used it in my MakerKit http://amzn.to/TQTZ9O Now I am planning a successor for this product and would like to use ScrathGPIO.

  4. Christian says:

    I am using a similar library for controlling the display, but I made it much shorter and easier to understand – with same functionality:
    https://github.com/christianimmler/python_LCD
    How can your library be used in Scratch?
    Maybe I could then find a way to include my simpler one.
    Just send me your shipping address via e-mail and I will send you one of these “MakeKits” including display and other components.

    • cymplecy says:

      Emailsent 🙂

      I can either use your libary one its own or just select which one to use depending on variable ADDOn

      E.g no Addon set then use yours AddOn set to PiAndBash – use original

      It won’t be a problem

      Simon

  5. Edward Watts says:

    Hi im useig a Explorer pHAT
    useing the informartion on https://pinout.xyz/pinout/explorer_phat

    iv set up the 2x variables
    Motor35,38
    Motor37,40

    but when i set the values nothing happens? can you help with this?

    • Edward Watts says:

      ok now read http://simplesi.net/controlling-h-bridge-motors/

      found the command should be MotorHxx,yy not Motorxx,yy
      this example has an error as it should read MotorH35,37 and MotorH36,38

      also are the pin number correct as http://4tronix.co.uk/blog/?p=1172 is listing different pins for the PZM motor Shim?
      Motor A is physical pins 35 and 36 (Broadcom GPIO 16 and 19)
      Motor B is physical pins 37 and 38 (Broadcom GPIO 26 and 20)

      so would be
      MotorH35,36 and MotorH37,38

      but must say many thanks for scratchgpio and the new v8 version! works very well so far! (and hopes this helps others having the same problems i was)

      • cymplecy says:

        I’ll have a check of docs – I have changed syntax for 8 so that may be issue 🙂

        • Edward Watts says:

          Just checked, used this link from this page, have version 7 and now version 8beta on the desktop useing v8beta but needed MotorH syntax? (just thought you should know) thanks for the reply in letting me know, if you need anything tested let me know as willing to help (have a range of pi’s to try it all on as well pizero, piA+, piB+, pi2 and pi3 – all 40 pin versions and all with the explorer phat)

  6. Jon says:

    I have been working with the Adafruit 16 Channel Servo Hat and LED’s. My goal is to add a bunch of LED’s to a robot without using a lot of GPIO pins. I can get the LED’s to change brightness but not to turn off completely. I have tried both positive and negative numbers with the “set AdaServo1” block. Any suggestions for making the LED’s turn off?

    • cymplecy says:

      I’ll try and dig out my board and see what is happening but I think you’re using the wrong syntax iirc. Servo commands change pulse ratios there should be a plain power command in Scratch GPIO I’ll have a look later as not near computer at moment

  7. cymplecy says:

    Looked at code on github try using adapower and not adaservo make sure you delete the adaservo variablrs

    • cymplecy says:

      I’ve amended the docs to add in the power information – thanks for heads up 🙂 http://simplesi.net/servos/

      • Jon says:

        I finally got around to trying your suggestion. When I use the “AdaPower0” variable and set it to any number from 0 to 100 nothing happens. When I use the “AdaServo0” variable the LED connected to channel 0 turns on as soon as I create the variable but will not do anything else. I can control the LED (get it to blink on and off) on any channel with python from the command line using the Adafruit Library, but not through scratch.

        • Jon says:

          I have been playing some more and discovered that for my setup AdaPower0 does not control a channel. When I use AdaPower1 the LED connected to channel 0 will turn on and off. I think that I had the ground wired funny. Anyway, I can get all the channels to activate LED’s and vary the brightness.
          Thanks for all the work you are doing on ScratchGpio. I am using it with a group of kids at our school to create robots using Lego for the chassis and motors and the Raspberry Pi to control the bot.

          • cymplecy says:

            Glad its working for you now 🙂 When I added in this board I was adverse to using 0 to indicate the 1st connection and that’s why I used 1-16 instead of 0-15.
            Simon

  8. JaKo says:

    Hi Simon, your scratchgpio project is great and the external program call in version 8beta is a fantastic addition!
    However, i have a couple of questions about this beta version:
    1- i notice that the external program call is executed twice, although it’s run once,
    2- i can’t get the ds18b20 (one wire temperature sensor) running. In the debug logfile i see three lines
    >ckecking for DS18B
    >Starting DS180
    >ds18b not found
    Does the ds18b20 still work in scratchgpio8beta?
    3- Do you have any plans to implement the DHT11 (temperature and humidity) sensor?

    Thanks in advance for your response!!

  9. JaKo says:

    Hi Simon, i figured out why the ds18b20 sensor didn’t work: i had to add one-wire support to the Rasspberry Pi first (see https://learn.adafruit.com/downloads/pdf/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing.pdf).
    After that i’m able to display the temperature in Scratch!!

  10. Eflib says:

    I try to use “broadcast run python test.py” but nothing happens.

    • cymplecy says:

      Hi sorry for delay in replying – I haven’t been keeping up with checking comments

      I just installed ScratchGPIO on a new Pi and did
      broadcast run python /home/pi/Pimoroni/unicornhat/examples/rainbow.py

      and it ran my python program

      (My neopixels are sparkling in front of me as I’m typing)

      JFI any program isn’t launched in a terminal window in case you were expecting it to

      Simon

Leave a Reply to Edward Watts Cancel reply

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