simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Scratch and GPIO

Sat Aug 25, 2012 2:48 pm

Thoughts on Scratch and the GPIO - any comments/suggestions greatly welcomed :)
http://cymplecy.wordpress.com/2012/08/2 ... direction/

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Scratch and GPIO

Sat Aug 25, 2012 10:45 pm

I having a discussion on what to name the GPIO ports in Scratch on twitter.

If YOU actually use the GPIO in any projects/code - what name/reference do YOU use in your project if YOU were to refer to Pin11.

Only people who've done something to answer please - don't need any google quotes :)

And then if I've set 6 pins for output and 2 pins for input, what names should I use for them in Scratch targetting Age 7-11 year olds?

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

User avatar
jbeale
Posts: 3494
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Scratch and GPIO

Sun Aug 26, 2012 5:35 am

I don't know anything about Scratch, but my brother is trying to get his 11-yo interested in doing some kind of hardware project with it. Is it possible to talk to an external I2C device using Scratch? Or some external USB-connected hardware of some type? Has anyone tried doing this sort of thing?

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Scratch and GPIO

Sun Aug 26, 2012 9:21 am

Scratch will talk natively to LEgo Wedo http://scratched.media.mit.edu/discussi ... spberry-pi

The Pi-Face team used a python intermediiate progam that listens to Scratch broadcasts and sends appropriate commands onto their hardware. (£30 for their board)

And their is S4A which is a Scratch mod that lets you talk to an Ardino (I've not tried to get it working on A RaspberryPI but it works fine in Windows)

And then there is the OU Sense project - again not been ported to RaspberryPi.

I'm working on the stuff you've asked for :)
I took the pi-face code and applied it to talking to the GPIO ports.

Also, I have this board on its way to me http://www.web4robot.com/RoboticBoard.html which I'm hoping won't be too hard to use the same technique and control/listen to it from Scratch.

regards
Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

cjturnpike
Posts: 1
Joined: Tue Dec 18, 2012 2:59 pm

Re: Scratch and GPIO

Tue Dec 18, 2012 3:14 pm

This is a great project, and i am desperately trying to discover what I have done wrong, I dont see the GPIO options under the SENSING {slider sensro value] drop down after enabling remote sensor connections. Any idea what i’m doing wrong, also I dont see the SCRATCH GPIO on my desktop and I have manually run the PYTHON rsc.sb file and tested the GPIO17 (pin11) with the BLINK11.PY script which works.

Any pointers as to how to get the GPIO sensor options INTO Scratch are warmly welcomed. Please talk to me like I’m an idiot as well, total newbie, albeit I’ve had mild GPIO with PYTHON success.
Cheers
Craig

longboat
Posts: 12
Joined: Sun Dec 23, 2012 9:47 pm

Re: Scratch and GPIO

Sun Dec 23, 2012 10:19 pm

Hi,
this has to do with the Broadcast Mechanism.
My code (simpler than Simon's) sends a Scratch Command as part of its start up process'
"sendScratchCommand('sensor-update temperature ' + str(i))"
This ensures that temperature will appear in the 'sensor' options.
After that I if I Broadcast from Scratch new names, these are checked in my Pyton code and return a sensor_update of suitable name to Scratch.

As an example.
In Scratch set up a 'When 'space bar' pressed, and broadcast as a result 'fred' in my case.
My code 'listens' for a broadcast and reacts:
.........lots of code
while 1:
data = the_socket.recv(1024)
if not data: break
if "temperature" in data:
i = work_out(0)
sendScratchCommand('sensor-update temperature ' + str(i))

if "fred" in data:
sendScratchCommand('sensor-update pintest ' + str(x))
x += 1
......more code
This counts space bar presses and in Scratch resets the counter x at a predetermined point, a good test of the mechanism for Broadcast and sensor-update.

Note I am checking for th string 'broadcast'. and returning a result to Scratch which will ensure a option 'pintest' appears in the sensor options.

If this is not clear i will try to document the whole process - it was not clear to me 10 days ago!! Works like a charm now.
One hint, when displaying results on the Scratch Stage, Normal readout (ie with descriptive text eats processors cycles, switch to large reduces this considerably.

Richard

https://docs.google.com/open?id=0B0FMn1 ... Fp2dUQ5U0U
My code needs a lot more work and editing etc, but works, drives a MCP3008 A to D board and a L293 driver chip, so Temperature and say Humidity, and Heater and Fan for a Greenhouse model.

User avatar
MsG
Posts: 3
Joined: Sun Apr 06, 2014 9:26 pm
Location: Texas

Re: Scratch and GPIO

Sun Apr 06, 2014 10:03 pm

This is only slightly related, but I am sensing some expertise here, so maybe one of you can help me...

I am a middle-school teacher working on integrating LEGO WeDo systems with Scratch on Linux.
(I have previously used Scratch+WeDo on Windows with students, but I'm hoping to start using Linux so that I can re-purpose old computers, plus encourage more educators and parents to try Linux with kids. Someday I'll move on to trying other Scratch+ interfaces, etc.)

I have recently obtained a Raspberry Pi, which came with a Raspbian (Debian) distro, and the included Scratch 1.4 version worked right away with the WeDo USB connection.
Yay!

However, not so much luck with other laptops & distro I tried.
Boo.

I installed the Ubermix (Ubuntu) distro on 2 old-ish Dell Latitude D610's, and the WeDo USB connection does NOT seem to be working/recognized on either laptop. (The special blocks do not appear in Scratch 1.4, nor does any sensor or motor work, even if I make the blocks appear by using the menu, then put them in a program. And yes, I tried all of the USB ports.)

Any clues to help me trouble-shoot this?
Or know who I could talk to that might know something about any drivers or USB or other configurations needed?

I am NOT at all an expert with Linux, but I can find & edit config files, etc, if I have instructions. I also have a few Linux-loving friends who I can call upon if needed, but I'd like to have first done whatever research I can.

I do have a deadline of sorts -- trying to have this working for demos at the Austin Mini Maker Faire on May 3, 2014.

Any clues would be appreciated!
~ Ms. G
STEM / CTE Teacher
Middle School
Texas

sdmeijer
Posts: 25
Joined: Thu Jun 21, 2012 6:13 pm

Re: Scratch and GPIO

Mon Apr 07, 2014 11:42 am

MsG wrote:This is only slightly related, but I am sensing some expertise here, so maybe one of you can help me...

I am a middle-school teacher working on integrating LEGO WeDo systems with Scratch on Linux.
(I have previously used Scratch+WeDo on Windows with students, but I'm hoping to start using Linux so that I can re-purpose old computers, plus encourage more educators and parents to try Linux with kids. Someday I'll move on to trying other Scratch+ interfaces, etc.)

I have recently obtained a Raspberry Pi, which came with a Raspbian (Debian) distro, and the included Scratch 1.4 version worked right away with the WeDo USB connection.
Yay!

However, not so much luck with other laptops & distro I tried.
Boo.

I installed the Ubermix (Ubuntu) distro on 2 old-ish Dell Latitude D610's, and the WeDo USB connection does NOT seem to be working/recognized on either laptop. (The special blocks do not appear in Scratch 1.4, nor does any sensor or motor work, even if I make the blocks appear by using the menu, then put them in a program. And yes, I tried all of the USB ports.)

Any clues to help me trouble-shoot this?
Or know who I could talk to that might know something about any drivers or USB or other configurations needed?

I am NOT at all an expert with Linux, but I can find & edit config files, etc, if I have instructions. I also have a few Linux-loving friends who I can call upon if needed, but I'd like to have first done whatever research I can.

I do have a deadline of sorts -- trying to have this working for demos at the Austin Mini Maker Faire on May 3, 2014.

Any clues would be appreciated!

I replied to you on the ScratchEd-forums: http://scratched.media.mit.edu/discussi ... fic-issues

Return to “Scratch”