You are on page 1of 5

Food Living Outside Play Technology Workshop

A Gentle Introduction to Arduino for Scratch Users


by akellyirl on February 7, 2013

Table of Contents

A Gentle Introduction to Arduino for Scratch Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: A Gentle Introduction to Arduino for Scratch Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: You Will Need . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 2: Flashing LED Experiment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Step 3: Scratch Program 1: LED Blinking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 4: Scratch Program 2: LED and Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Step 5: One for You to Do . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

http://www.instructables.com/id/A-Gentle-Introduction-to-Arduino-for-Scratch-Users/
Intro: A Gentle Introduction to Arduino for Scratch Users
There are lots of people who are very comfortable with the Scratch programming environment but want to try something with Arduino to Blink Lights, Sense Buttons, Run
Servos or whatever. They may find the C programming environment in Arduino IDE - Sketch, a bit too much of a step.

This instructable draws on the work of the guys at “Citilab” http://seaside.citilab.eu/scratch .

They have created a modified version of Scratch to interface with Arduino.

Using Scratch Programs you can make Arduino Flash Lights, Read Buttons, and do many of the things that you can do with the the regular Arduino environment.

So if you like Scratch and Arduino but are not quite ready for C programming (yet), this is something you can try out.

Step 1: You Will Need


Follow the Install guide to download and install S4A ( Scratch 4 Arduino) and the Firmware for Arduino to talk to S4A:
http://goo.gl/4pU2h

For our experiment you will need:

* Arduino UNO
* Some LEDs
* A 560 Ohm resistor for each LED (or a value similar to that)
* A 10k Ohm resistor
* A Pushbutton Switch
* Breadboard for wiring up e.g. (http://goo.gl/1E1iI l)
* Some Wires

http://www.instructables.com/id/A-Gentle-Introduction-to-Arduino-for-Scratch-Users/
Step 2: Flashing LED Experiment
To start we need to wire an LED and Switch to the Arduino (along with some Resistors), as shown in the diagrams below.

We're using the switch in the second experiment and the LED in both the first and second experiments.

Go ahead and wire it up as shown.

http://www.instructables.com/id/A-Gentle-Introduction-to-Arduino-for-Scratch-Users/
Step 3: Scratch Program 1: LED Blinking
Startup S4A (Scratch 4 Arduino) and Enter the Scratch program as Shown.

You Should Now See the LED flashing.

If you don't. Check the wiring.

The equivalent C program (Arduino Sketch) is shown below as well.

Compare the C and the Scratch and see if you can figure out what's going on.

http://www.instructables.com/id/A-Gentle-Introduction-to-Arduino-for-Scratch-Users/
Step 4: Scratch Program 2: LED and Button
Now we'll use the button to turn on on the LED when it's pressed.

Enter the Scratch shown.

Compare it to the equivalent C Code in the picture.

Try to Understand how they both work.

Step 5: One for You to Do


This is one for you to do yourself, based on the experiment above.

Add another LED and Resistor as you did previously, but this time connect it to Arduino pin 12.

Write a Scratch Program to Turn One LED ON and the other LED OFF when the switch is pressed. HINT: When the Switch is NOT Pressed the LED state should be
opposite (i.e. ON:OFF become OFF:ON)

Write a program to do the same thing in the Arduino IDE – C

Related Instructables

Arduino
Arduino / Arduino Light Blink- Your First Examples #2
Arduino Robot Raspberry Pi Storybug by Sensitive Bar Arduino Project Use an Arduino
for lowest cost Internet Radio rwistort Graph by akellyirl by Mr.Monkey16 as a FTDI
by doncrush by akellyirl Programmer by
qazwsx755

Advertisements

http://www.instructables.com/id/A-Gentle-Introduction-to-Arduino-for-Scratch-Users/

You might also like