2 - POWER UP THE MACHINE

We are going to continue working in the Scratch file we have open. Remember, if you're thinking about saving your work to continue editing later, you will need to sign in.

You may notice that at the moment your machine does not do anything. That's because we need to power it up (figuratively). The next set of instructions will guide you through that process.

2.1

Click the button below to download the “POWER SWITCH.sprite3” file.

The file will automatically download to your computer. If it doesn't ask where to save, In most cases, it'll save to your "Downloads" folder.

2.2

Hover over the [Choose a Sprite] button located near the bottom-right of the screen.

A blue drawer of options will appear above the button.

2.3

Click the [Upload Sprite] button.

A finder window will open through your browser.

2.4

Locate the “POWER SWITCH.sprite3” file on your computer.

Select the file, then click [Open].

The file will load into your Scratch project and you should now see the POWER SWITCH listed with your other sprites.

2.5

Locate and click the POWER SWITCH sprite in the Sprites Pane. Click the [Code] tab to view the coding blocks that came with this sprite.

These blocks may look intimidating for those new to scratch. All you need to know and do with this step is to realize that we’ve pre-programmed this beat machine to turn on/off by pressing the [P] key on your computer’s keyboard. However, if you try pressing the [P] key now, you’ll notice that nothing happens.

Let’s fix that.

2.6

Finally, some coding!

Locate, then drag the following blocks into the [Code] section of the POWER SWITCH sprite. Scratch blocks work like legos and read from top to bottom. In fact, read is a perfect word since you can literally read each line of code like a sentence or "command".

Let's talk about what these blocks are saying.

This is our sentence starter. This is our trigger for scratch to know when to start reading the rest of the sentence.
Purple blocks deal with the looks of the sprite. I originally drew this a bit too big, so were going to shrink it down to 10% its original size
Blue blocks deal with location. All of the sprites in this machine need to stay put. The X and Y coordinates are important. Make sure yours matcheså mine.
Since this app has many elements layered on each other we will need this block to state its place behind the machine. Simply for aesthetics.
This POWER SWITCH has two costumes and we are going to program it to toggle. For now we want it to start on OFF
Another "looks" block, show simply tells the sprite to be visible when it starts.

Let's try clicking the Green Flag.

Now press the [P] key. Did anything happen? Nope! Our POWER SWITCH is missing one more important piece of code.

2.7

For this machine I've created several variables for this machine. Variables are alphanumeric and can be set, adjusted. We'll cover more on variables later but what you should know for now is that the variable called [POWER] has the value of 0-100. 0 means OFF and 100 means on.

Drag a Power variable into each empty slot as pictured to the right. You will have to do this twice for each line of code.

BEFORE
AFTER

2.8

I've also used broadcast blocks. These blocks allow the sprites to talk to each other. We want our power switch to tell the other sprites that the machine is turning on.

Locate and drag a broadcast block into your lines just about the [wait] block. Use the drop down menu to select the message to broadcast.

2.9

Lastly, let's change the costume to make it look like the switch is actually being pressed. The costume should match the broadcast.

Let's place the block in between the broadcast and wait blocks.

Okay, Let's try clicking the Green Flag to reset our program.

Now press the [P] key on your keyboard.

Did your beat machine power up? You should have seen the pads light up and the startup sound play?

If it did not light up, scroll back through this page to double check your work.

Now that you are powered up, lets upload some sounds into our machine in Section 3!