10
“Robots have taken over our school!” How to make an interactive light display You will need computer or Raspberry Pi with s4A ‘Scratch 4 Arduino’ installed. An Arduino with the S4A firmware uploaded.

How to make an interactive light display that showts how a robot is feeling

Embed Size (px)

Citation preview

Page 1: How to make an interactive light display that showts how a robot is feeling

“Robots have taken over our school!”

How to make an interactive light display

You will need

computer or Raspberry Pi with s4A ‘Scratch 4 Arduino’ installed.An Arduino with the S4A firmware uploaded.

Page 2: How to make an interactive light display that showts how a robot is feeling

How to control more than one light using the keyboard

Breadboards can be used to connect wires, lights, sensors and motors together.

Columns go up and down and are numbered 1 – 30, with letters a toj. If you connect two wires into the same numbered column they will be connected.

Rows going sideways are used for either (+) positive or (-) negative.

If you place two wires in the same (+) or (-) row they will be connected.

Page 3: How to make an interactive light display that showts how a robot is feeling

Light Show schematic

Place your Breadboard as shown in the picture so that the numbers on the bottom half go from 1 on the left to 30 on the right.

Connect a black jumper lead from the GND pin nearest the Arduino logo, to the 1st hole on the negative sideways row at the bottom of the board. It is the furthest hole to the left, but 1 hole up.

Connect a red jumper lead from digital pin 10 on the Arduino to hole 5Aon the breadboard. This is the bottom hole in column number 5.

Connect another black jumper lead from hole 5A to any hole on the negative sideways row at the bottom of the breadboard.

Page 4: How to make an interactive light display that showts how a robot is feeling

Resistors

Sometimes too much electricity can make an LED bulb blow up.

We don’t want this to happen so we’ll use a resistor to limit the electrical current passing through our circuit.

A resistor has two wires. Place the resistorwires in hole 9B and hole 9C.

It does not matter which resistor pingoes in which hole.

Page 5: How to make an interactive light display that showts how a robot is feeling

LEDs

An LED is a light with two wires.

One is positive and one is negative. The positive wire islonger than the negative one.

Stand the LED up on the table to test which is which.

Put the long leg of your 1st LED into hole 5A.

Put the short leg of your 1st LED into hole 4A.

Page 6: How to make an interactive light display that showts how a robot is feeling

Repeat this for more LED lights and connect them to Arduino pins 11, 12or 13.

Page 7: How to make an interactive light display that showts how a robot is feeling

How to program light shows using the keyboard

From the Control drawer, drag out a When Green Flag Clicked block, aForever block and an If Else block. Connect them together like shown.

From Sensing, drag out a Key Pressed block and place it in the top socket of the If Else block.

From Motion, drag out a Digital On block and a Digital Off block and place them as shown.

TEST: Click the green flag. What happens when you press number 1 on the keyboard?

Debug: Check if the digital pin that you are turning on and off with your Scratch code is the same number as the Arduino digital pin that is connected to the long leg ofyour LED.

Page 8: How to make an interactive light display that showts how a robot is feeling

Right click on the If Else block andselect duplicate. Place the new If Else

block below the 1st one.

For each new If Else block, edit thekey pressed and the digital pin turned onor off so that you can trigger each of the

lights you have connected to the Arduinoby pressing a different key.

Page 9: How to make an interactive light display that showts how a robot is feeling

How to program automatic light shows

You can make light so come on and off at different times by using a Waitblock. A wait block will ask Scratch4Arduino to wait for as long as many seconds as you tell it to until it carries out the next instruction.

TEST: Click the green flag. What happens when you press ‘a’?

CHALLENGE: Create an interactive light show that allows the user to select between 2 different light sequences. Try and create one sequence that describes a positive emotion, like happy, excited, or interested and one light sequence that describes a negative emotions like sad, angry or bored.

Page 10: How to make an interactive light display that showts how a robot is feeling