Don’t you
find it entertaining if an animated Scratch that you had created comes alive
when the night falls, and stops when the sun rises ?? Or turns on the alarm when there is an intruder around the perimeter fence ??
A typical example is show below
In the above
set up, Scratch constantly polls information from the micro controller and check if the
motion sensor is triggered. If true, it turns on the siren (alarm). The siren
continues to switch on to a logical “True” state until the spacebar of your
keyboard is pressed.
It’s not as difficult
as you thought, all you need is to snap a few Scratch blocks as follows
The combination
of Arduino and Scratch Extension makes physical computing possible, that allows
Scratch program to react and response to events happening outside of the computer.
It is an engaging and practical topic that adds
interactivity where children (even adults) enjoy learning about.
A Scratch Extension is an object that can be used with Scratch, in some cases as an
add-on to interface with the outside world. There are many variants (or Scratch-like),
specifically developed to teach children the concept of physical computing, each
has its shortcomings and appropriateness for specific applications. Of the
variants, Scratch for
Arduino (S4A), developed by Citilab is
a direct modification of Scratch 1.4
and is explicitly designed to work with Arduino UNO. However, the pre-assigned I/O pins in S4A hinders the flexibility of
I/O configuration as you would in a micro controller. That doesn’t imply it is not
up to snuff but relevance of its application.
The 18 I/Os
are assigned as followss
- 6 analog inputs (pins A0, A1, A2, A3, A4 and A5)
- 2 digital inputs (pins 2 and 3)
- 3 analog outputs (pins 5, 6 and 9)
- 4 digital outputs (pins 10, 11, 12 and 13)
- 2 digital outputs for continuous-rotation servo motor (pins 4 and 7)
- 1 digital outputs for 0-180 rotation servo motor (pins 8)
S4A is an ideal program for beginners (at least in my
context) but as you progressed, it might not be adequate for your applications
where more I/Os are needed.
Citilab has also developed an extension for SNAP! called Snap4Arduino, a derivative of Scratch
by Jens Mönig at MioSoft Corporation, with
contributions by some folks at Berkeley.
Snap4Arduino is purportedly tailored for the Arduino variants such as the UNO, Mini, Mega2560, Pro, Lilypad, etc. Although it’s still in its alpha phase, it works flawlessly with the atmega328 and atmega168 processors, namely the UNO, Pro Mini, to name a few.
SNAP!
allows you to build your own blocks, and with the added features of first
class list, procedures, etc, it renders a serious introduction to computer
science to high school or college students.
Snap4Arduino is purportedly tailored for the Arduino variants such as the UNO, Mini, Mega2560, Pro, Lilypad, etc. Although it’s still in its alpha phase, it works flawlessly with the atmega328 and atmega168 processors, namely the UNO, Pro Mini, to name a few.
For the
Mega2560, all 54 IO pins are accessible, except there are some bugs with PWM,
digital input and Servo functionality for higher pins (pin14 onwards).
Unlike S4A,
all the digital I/O pins are configurable, extending its flexibility.
As of this
date, the bugs has not been fixed but the folks at Citilab has committed to
sort it out prior to the upcoming Scratch@MIT conference, somewhere in August
this year.
You can
download both S4A or Snap4Arduino at http://s4a.cat/ and http://s4a.cat/snap/ respectively. Instruction
to install the program is available at their site.
Throughout
this blog, we’ll start with S4A for
the very beginners and switch to Snap4Arduino
for projects where more IOs are needed.
To be
continued……….