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: 3672
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
Please only ask questions in the forum I will not answer questions sent to me directly via PM
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

ghp
Posts: 1168
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: 1
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: 32332
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, 3B*3, 3B+

Please post ALL technical questions on the forum. Do not send private messages.

ghp
Posts: 1168
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.

Return to “Scratch”

Who is online

Users browsing this forum: No registered users and 2 guests