Loading Now
SCRATCH EXTENSION ARDUINO

SCRATCH EXTENSION ARDUINO

SCRATCH EXTENSION ARDUINO

Quick Start

To use the extension, upload the StandardFirmata program to your Arduino board and then open the Arduino extension on ScratchX.org.

Introduction

This Scratch extension lets you interact with the physical world using an Arduino board. For example, you can control lights and motors or measure light and temperature. The extension communicates with an Arduino board running the Firmata firmware.

grove SCRATCH EXTENSION ARDUINO
Arduino board with a Grove LED, button, and temperature sensor.

Equipment

You need:

Arduino board

Like the Arduino Uno.
USB Cable
Full-sized
Electronic components
We recommend the Grove starter kit for Arduino (made by Seeed Studio). You can buy it from Maker Shed in the U.S. For other options, see working with basic electronic components below.

[nextpage title=”Getting Started” ]

Getting Started

  1. Download and install the Arduino software (Windows instructions, Mac instructions)
  2. Connect the Arduino to your computer’s USB port
  3. Open the Arduino software
    arduino SCRATCH EXTENSION ARDUINO
  4. Go to File > Examples > Firmata > Standard Firmata
    firmata SCRATCH EXTENSION ARDUINO
  5. Select your Arduino board from the Tools > Board menu
    arduino-board SCRATCH EXTENSION ARDUINO
  6. Select your serial port from the Tools > Port menu.
    On Mac, it’s something like /dev/tty.usbmodem-1511.
    On Windows, it’s probably the highest-numbered COM port.
    (Or unplug the Arduino, check the menu, and then replug your Arduino and see what new port appears.)
    arduino-port SCRATCH EXTENSION ARDUINO
  7. Click the upload button
    arduino-upload SCRATCH EXTENSION ARDUINO
  8. Download and install the Scratch Browser Plugin
  9. Load the Arduino extension on ScratchX.
  10. On FireFox, you might see “Allow scratchx.org to run “Scratch Device?”. Click “Allow…”.
    firefox-plugin SCRATCH EXTENSION ARDUINO
    You might see another message, “Allow scratchx.org to run plugins?”. Set both Adobe Flash and Scratch Device to “Allow and Remember” and click okay.
    firefox-plugin2 SCRATCH EXTENSION ARDUINO
  11. On Chrome, you’ll need to enable NPAPI plugins. Go to chrome://flags/#enable-npapi and click enable:
    chrome-npapi SCRATCH EXTENSION ARDUINO
    Then, click “Relaunch Now” button:
    chrome-npapi3 SCRATCH EXTENSION ARDUINO
    Then, when you go to ScratchX.org, you should see a puzzle piece icon with an X on it: chrome-plugin-broken SCRATCH EXTENSION ARDUINO. Click on it and select “Always allow plug-ins on scratchx.org”:
    chrome-plugin-enable SCRATCH EXTENSION ARDUINO

[nextpage title=”Grove Modules” ]

Grove Modules

Grove Base Shield

grove-shield SCRATCH EXTENSION ARDUINO

The Grove Base Shield (V2) connects your Arduino board to the other Grove modules. It has different kinds of connections:

A0, A1, A2, A3
Analog inputs that read from sensors, like the light sensor, temperature sensor, and rotation knob.
D2, D3, D4, D5, D6, D7, D8
Digital connections that control LEDs and servo motors and read from push buttons. To fade an LED (not just turn it on and off), use D3, D5, or D6.
I2C and UART
These are more complex connections that we don’t use in the extension yet.

To connect a module to the shield, plug one of the Grove cables into the white connector on the module and one of the connectors on the shield. The cable only goes into the connector one way.

Grove Button

grove-button SCRATCH EXTENSION ARDUINOA button you can press

Grove Light Sensor

grove-light-sensor SCRATCH EXTENSION ARDUINOMeasures light

Grove Rotation Knob

grove-rotation-knob SCRATCH EXTENSION ARDUINOControl things by rotating the knob

Grove Temperature Sensor

grove-temperature-sensor SCRATCH EXTENSION ARDUINOMeasures temperature

Grove LED

grove-led SCRATCH EXTENSION ARDUINOA small light

Grove Servo Motor

grove-servo-motor SCRATCH EXTENSION ARDUINOMoves its arm back and forth

Working w/ Basic Electronic Components

Coming soon…

[nextpage title=”Scratch Blocks” ]

Scratch Blocks

This is a brief description of each of the Scratch blocks included with the Arduino extension.

device-connected SCRATCH EXTENSION ARDUINORuns when the device is connected


led-connect SCRATCH EXTENSION ARDUINOConnects an LED, button, or servo to a digital connection (D2, D3, D4, D5, D6, D7, D8).


sensor-connect SCRATCH EXTENSION ARDUINOConnects a rotation knob, light sensor, or temperature sensor to an analog connection (A0, A1, A2, A3).


led-digital SCRATCH EXTENSION ARDUINOTurns an LED on or off.


led-set SCRATCH EXTENSION ARDUINOSets an LED to a specified brightness from 0 – 100%.


led-change SCRATCH EXTENSION ARDUINOChanges the current LED brightness by a specified amount.


servo-set SCRATCH EXTENSION ARDUINORotates a servo to a specified location from 0 – 180 degrees.


servo-change SCRATCH EXTENSION ARDUINOChanges a servo’s current rotation by a specified amount.


button-when SCRATCH EXTENSION ARDUINORuns when a button is pressed or released.


button-boolean SCRATCH EXTENSION ARDUINOChecks if a button is currently pressed.


sensor-when SCRATCH EXTENSION ARDUINORuns when a rotation knob, light sensor, or temperator sensor meet a certain condition.


sensor-read SCRATCH EXTENSION ARDUINOReads the current value of a rotation knob, light sensor, or temperature sensor. Value will be between 0 – 100.


pin-write-digital SCRATCH EXTENSION ARDUINOTurns a digital connection (D2, D3, D4, D5, D6, D7, D8) on or off.


pin-write-analog SCRATCH EXTENSION ARDUINOSets a capable digital connection (D3, D5, D6) to a value from 0 – 100%.


pin-when-digital SCRATCH EXTENSION ARDUINORuns when a digital connection (D2, D3, D4, D5, D6, D7, D8) is turned on or off.

pin-read-digital SCRATCH EXTENSION ARDUINOChecks if a digital connection (D2, D3, D4, D5, D6, D7, D8) is on or off.


pin-when-analog SCRATCH EXTENSION ARDUINORuns when an analog connection (A0, A1, A2, A3) meets a certain condition.

pin-read-analog SCRATCH EXTENSION ARDUINOChecks the current value of an analog connection (A0, A1, A2, A3).


map SCRATCH EXTENSION ARDUINOMaps a value between two ranges of numbers. This example might be used to map an analog sensor’s value (0 to 100) to a sprite’s x position (-240 to 240).