Arduino class-set in Year 6

Today I tried out a class-set of 15 Arduinos with LEDs with Win 7 laptops with a Year 6 class with past experience of Scratch.

First  issue was that I only managed to get 8 set-ups working before the start of the lesson!

This was due to driver issues – I thought I was OK as I’d used Arduinos in the past in the school but all machines wanted to install a new driver and only 4 of them decided that the ones it had already were suitable.

With all the others, I had to download the latest Arduino package and use the drivers in that.

After that, plain sailing using ScA (Arduino version of ScratchGPIO) to make some Red/Yellow/Green LEDs go on and off.

All groups had a full pedestrian crossing LED Sequence and Scratch cat walking across a Zebra crossing on the screen with quite a lot having cars going back and forth and one group had a baby doing cartwheels across the road!

Technically ScA throws an error if they save and then reload another script meaning it has to be killed and restarted but I’ll hopefully sort that out and get some input handling added to it so be can use switches as well.

As usual, forget to take pics – will try and do better next time.

🙂

Post Post

There may be as easy solution to the driver probelm!

http://forum.arduino.cc/index.php?topic=86603.msg1768273#msg1768273

Pin Trigger handling in ScratchGPIO

I was looking at some of William Bell’s RPiScratchIO scratch code and notice that he had the concept of receiving broadcasts on inputs pins changing state.

So I’ve started implementing this (in dev version)

Basic concept is that if an input changes state – it will send a broadcast message to Scratch.

So if Scratch has a hat block that says

On Trigger received
Say “An input has changed state” for 2 seconds
Broadcast ResetTrigger

then if  any pin changes from 0 to 1 (or 1 to o) then Scratch will run the On Trigger block.

To make sure that only one event is dealt with at a time, my handler will not send any more changes until it receives a ResetTrigger from Scratch which is why that Broadcast ResetTrigger command is at the end.

As well as this global trigger, each pin has its own trigger so to just detect a change in pin7 use

On TriggerPin7 received
Say “Pin7 has changed state” for 2 seconds
Broadcast ResetTriggerPin7

If using an addon that names the inputs (say Switch) then the following would be triggered on a switch press

On TriggerSwitch received
Say “The switch has changed state” for 2 seconds
Broadcast ResetTriggerSwitch

 

Sending messages between Raspberry Pi using ScratchGPIO

NB Only available in dev version
https://cymplecy.wordpress.com/2013/11/26/scratchgpio-development-testing/

For a while I’ve wanted one computer running a Traffic Light program to easily talk  to a  Pi running as robot vehicle so that the robot can respond easily to the traffic light  sequence.

And extending this to another robots crossing the lights as vehicles or pretend pedestrians!

Link1I’ve added in a basic syntax for this

Link is used to setup connection to any other computer running Scratch with Remote Sensor Connections (RSC) enabled.  (All ScratchGPIO instances running on Pi are and it can be simply enabled on other computers by users)

Then simply, prefix any broadcasts that you want to send to the other computer with Send.  The other computer will receive the broadcast without the Send prefix e.g  Stop or Go

Ideas to enhance/change

Let Link work with just last octet of IP (ie. assume on the same LAN and automatically determine first 3 octets. (easy)

Try and come up with using last 4 digits of serial num like SID uses (hard)

Or something to make it less geeky if possible (hard)

Add a prefix/identifier to the broadcast so that receiving computer can identify/filter/differentiate non-local broadcasts (to prevent advanced Scratchers from taking control of a remote Scratch device without permission and make it possible to have more 1 computer sending messages into a remote computer)

The code is in the dev version (but liable to change) but please have a play and pass on your ideas/thoughts

Please remember my target audience are 7-11 year olds and their teachers 🙂

Simon