roannahutch14
Posts: 1
Joined: Fri Mar 09, 2018 10:01 pm

coding GPIO high/low input pins on Scratch

Fri Mar 09, 2018 10:14 pm

Hi there,

I am completely new to scratch and I was wondering what the most simple way of coding GPIO high/low input pins were? I was hoping to implement cases where, when a certain GPIO pin is low, a note is played from the midi sound system using a pHAT DAC with a Raspberry Pi Zero. Any help would be greatly appreciated.

Thank You!

pcmanbob
Posts: 4084
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: coding GPIO high/low input pins on Scratch

Fri Mar 09, 2018 10:35 pm

There is an example of scratch and gpio inputs in the parents guide under physical computing

https://projects.raspberrypi.org/en/pro ... -scratch/8
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

ghp
Posts: 1170
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: coding GPIO high/low input pins on Scratch

Sun Mar 11, 2018 8:00 pm

Hello,
there are two things to solve, get a button press and then play a sound.
The example cited from pcmanbob is for scratch1.4 with gpioserver. When using scratch2, then see https://www.raspberrypi.org/blog/scratc ... pberry-pi/.

For playing sounds, there is an option using scratchclient and sonicpi. I noticed that sound quality of scratch sounds is not very good, but sonicpi has astonishing good sound quality. Fortunately sonicpi has an interface and there was a possibility to connect this with scratchClient to scratch1.4 and scratch2.
See http://heppg.de/ikg/wordpress/?p=960 for some details.

pymyk59
Posts: 3
Joined: Sat May 12, 2018 2:13 pm

Re: coding GPIO high/low input pins on Scratch

Sat May 12, 2018 4:02 pm

hey there....dunno if I'm in the right place, but i have just registered in the forum and I have a GPIO related query....
I'm basically new to RP, but I need to build a MULTI IN/OUT core "engine" to manage autonomously my trams layout.
I have an RP b rev.2 and I have just got a Pridopia128-ch GPIO extension board.
I'm no great shakes when it comes to coding, so i think using Scratch would be a good way to get what i want, which is "just" half the channels configured as in's and the other half as out's with a number of conditional steps(if then) to do whatever... :)
Both inputs and outputs are simply optoisolators, so we are looking at simple switches at the in and led drives at the outs.
So far so good.....
HOWEVER
I note that according to the board's documentation, it requires running in Rasbian Wheezy, which I have discovered is currently at end-of-life.
My question is this......
Would the Pridopia 128 card run under the latest rasbian and Scratch versions? (please say yes......please!!! :)
...and if not.... :( ...... what requires to be done......

ermmmmmm, just to be up front, I am NOT looking for the actual coding, but what is required to get both the PI and the board to work together in Scratch... :) Once that is sorted out, I'll soldier on myself.....with updates here, if anyone's interested.... :)

thanks up front..... :) :) :)

User avatar
DougieLawson
Posts: 33314
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: coding GPIO high/low input pins on Scratch

Sat May 12, 2018 6:20 pm

It doesn't need Wheezy. It will work with Stretch as long as you enable I2c with

Code: Select all

dtparam=i2c_arm=on
in /boot/config.txt
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

ghp
Posts: 1170
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: coding GPIO high/low input pins on Scratch

Mon May 14, 2018 6:06 pm

Hello,
There are two flavors for this card, I2C and SPI. In scratchClient, there is support for 23S17 chips using SPI. Eight chips are possible.
scratchClient supports scratch1.4 and scratch2.
Eight chips are possible. ScratchClient allows to name each pin individually. But keep in mind that scratch using a hundred IO might be slow and response times in tenths of a second could be a challenge.

pymyk59
Posts: 3
Joined: Sat May 12, 2018 2:13 pm

Re: coding GPIO high/low input pins on Scratch

Fri May 25, 2018 4:17 pm

thanks for your kind replies...i have now bought an RP 3B+, and Scratch 2 running on it has GPIO support....what I am uncertain is can Scratch 2 see and process GPIO extensions running on the I2C bus ? :) I have changed my design path to use addressable chips (PCF8574). There also is a setting in the menu Preferences/Raspberry Pi Configuration/Interfaces/ which allows you to enable I2C...(which I did.. :) ) .....my ultimate aim is to control model trams by detecting where they are and use this information to control track sections, so the kind of speed i'm looking is really very slow, comparatively speaking.........so no speed probs here... :)

Forris
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 242
Joined: Fri Jan 06, 2012 7:46 pm

Re: coding GPIO high/low input pins on Scratch

Sun May 27, 2018 7:43 am

If you want a version of Scratch on the Pi that has a few more features than the installed version, have a look at http://simplesi.net/scratchgpio/scratch ... rypi-gpio/

It's been around for a while, but it is able to support many more peripherals and the developer is easy to contact if you need help. We've used it for loads of Physical Computing projects at school.

Return to “Scratch”

Who is online

Users browsing this forum: No registered users and 5 guests