Explore and Challenge: The Pi-Stop Reaction Game

SEE ALSO: Setup: Scratch GPIO: For instructions on how to setup Scratch GPIO with Pi-Stop (which is needed for this guide). Explore and Challenge Scratch GPIO: Pi-Stop First Steps: If you've not used Scratch before, this will provide a quick introduction to building your first Scratch GPIO program. Explore and Challenge Scratch GPIO: Pi-Stop Traffic Sequence - Create your own traffic light sequence and learn how to use Scratch GPIO with the Pi-Stop. In this guide we will use the Pi-Stop in a game of fast reactions. Our program will make the Pi-Stop light up after a random delay, then time how long it takes for us to press the SPACE button on our keyboard in response. The program will also track your best score! Who will be the fastest person in the workshop?

Getting Started As in previous guides, the Pi-Stop should be connected to the Raspberry Pi in Location A, as follows: Location A for Model A+, B+ or Raspberry Pi 2 (purchased after July 2014)

Location A for Model A or B (purchased before July 2014)

With the Pi-Stop fitted in the correct position you can now power up your Raspberry Pi. Once you have started the Raspberry Pi desktop, open Scratch using the Scratch GPIO icon:

Design: The Reaction Game We will break the game down into smaller sections so we can build it up piece by piece. Lets think about how we want the game to function: 1. 2. 3. 4. 5.

Setup and Wait for user - Ensure the player and game is ready. Start the game - Switch OFF the lights and see how long the player takes. Work out the scores! - Workout the player's reaction time. Who is the fastest? - See if the player is the fastest. Next round! - Give the player another go.

First we will need some "variables" to hold our information: Add a new variable by pressing the "Make a variable" button in the Variables tab.

Create a new variable Fastest Score, set it to be For all sprites. This will create a new item in the Variables tab. NOTE: The tick next to it controls if it is displayed on in the main Scratch window. For this game, it doesn't matter if they are visible so you can leave them ticked. Create the following variables to use in our game:

We will also setup some broadcast group blocks as before, to control our lights. We just need an ALLON and an ALLOFF broadcast group block to switch ON or OFF the lights.

1. Setup and Wait for user The game should wait for the use to press a key (for example the UP ARROW key). We do this with:

NOTE: GO will be a broadcast group block which runs the game (see the next section). We have to use a broadcast "GO" and wait block, otherwise Scratch will continue on and try to work out the scores before the player has had chance to play the game. The wait part ensures this block is finished before moving onto the next block.

2. Start the game Next the game should tell the player what to do "Press SPACE when the lights go out!" and switch ON the lights We will measure the players reactions by counting the time the user takes to press the SPACE key and compare it with the time the LEDs go out! This is done with the following steps: We start our timer Wait for a random amount of time

Switch OFF the lights Measure the time when we switch OFF the lights Measure the time when the player presses the SPACE key We do this with:

The key part here is the pick random 1 to 5 to provide a unknown wait time before we switch OFF the lights.

3. Work out the scores! After the game round has finished, we will need to work out the scores. We will have the time the player pressed the SPACE key (the "PlayerTime") verses the time the lights switched OFF (the "GameTime"). From this we can work out which of the following three things has happened: 1. The player saw the lights go OFF and they pressed the SPACE key shortly after (GOOD) 2. The player forgets to press the SPACE key (BAD) 3. The player pressed the SPACE key too soon (BAD) By checking if the "PlayerTime" is shorter than the "GameTime", we will know they pressed too soon (case 3). If that happens, we should tell them (so they know to wait next time "Too Fast!") and give them a very bad score for not waiting/cheating! If the "PlayerTime" is equal to its initial value than the player didn't press the SPACE key at all. Again, we will tell them "Too Slow!" and give them a bad score. If the "PlayerTime" is longer than the "GameTime", they have pressed the SPACE key after the lights switched OFF. Their score will be the difference between the "GameTime" and the "PlayerTime", their "Reaction Time"! We do this with:

We add another broadcast and wait block (to run our new "SCORE" block) to the main "START" broadcast group block.

4. Who is the fastest? Next we work out if the "Reaction Time"* faster than the "Fastest Score", if it is we can set a new "Fastest Score".

We do this with:

5. Next round! Finally, we tell the player "Press UP arrow to START" and restart (without resetting the "Fastest Score"). We do this with:

NOTE: This block will restart as soon as the player presses the UP arrow. By breaking our game into smaller tasks, it was a lot easier to make! Amazing, you have created your first game in Scratch!

WORKSHEET: Tick the checkbox marked "I've created the Pi-Stop Reaction Game". Don't forget to write down your best score!

Can you make this game more challenging? Try making this game more difficult by randomly picking a different LED each time, and make the player will need to select the correct LED (1, 2 or 3) in order to score!

You are now ready to move onto the next guide: Explore and Challenge Scratch GPIO: Pi-Stop Simon Memory Game.

Explore and Challenge - GitHub

Explore and Challenge Scratch GPIO: Pi-Stop Traffic Sequence - Create your own ... Once you have started the Raspberry Pi desktop, open Scratch using the ...

432KB Sizes 3 Downloads 330 Views

Recommend Documents

Explore and Challenge - GitHub
Open Scratch GPIO from the desktop using the Scratch GPIO icon (we do not need the ... This is where you build your scripts by locking various blocks together.

Explore and Challenge - GitHub
Select the Variables tab and add a new variable by pressing the "Make a variable" button, call it Score and set it to be For all sprites. We will also need to create a list to hold our sequence of lights, we will call it GameList: Press the "Make a l

Explore and Challenge - GitHub
WORKSHEET: Tick the checkbox marked "I've created the Pi-Stop STOP and GO sequences". The Final Program - Changing Lights. At the moment our program ...

DIACC Design Challenge - GitHub
Pain Point 1: If an authorized user loses the original PDF certificate (along with the certificate number and access code) they cannot ... Designing for Opportunity (1 of 3). 4. Challenge .... verified as authentic against the blockchain using the mo

Loan Repayment Challenge - GitHub
necessary manipulations or aggregations, generate visualizations, and reach conclusions or insights. The most important thing to remember is that we are evaluating your thought process and ideas! The more you explain your thinking, in a clear and suc

Challenge to Excellence Charter School students explore the world ...
students explore the world using Android tablets with Google Play for Education. About Challenge to Excellence. Charter School. • Charter school serving 510 ...

Solution for the Search Results Relevance Challenge - GitHub
Jul 17, 2015 - They call such method as semi-supervised learning. ... 2. calculate the pdf/cdf of each median relevance level, 1 is about 7.6%, 1 + 2 is ..... Systems: Proceedings of the 2011 Conference (NIPS '11), pages 2546–2554, 2011.

Explore 18.1.5 ANSWERS.pdf
Download. Connect more apps... Try one of the apps below to open or edit this item. Explore 18.1.5 ANSWERS.pdf. Explore 18.1.5 ANSWERS.pdf. Open. Extract.

Explore Performance Task.pdf
Consumes, produces, and/or transforms data. ○ Raises at least one data storage concern, data privacy concern, or data security concern. You are also required ...

Gold nanoparticles explore cells: Cellular uptake and ...
For tracking nanoparticles, bright field images of live cells were. 209 obtained in ..... Using particle. 343 tracking software as described in Section 2.1, 150 particle aggre-. 344 ...... figure in (D) shows the PC1 loadings plot for single cells (t

014-underwater-school-in-archaeology-in-sanitja-and-explore ...
Page 1. Whoops! There was a problem loading more pages. 014-underwater-school-in-archaeology-in-sanitja-and-explore-underwater-pompeii.pdf.

014-underwater-school-in-archaeology-in-sanitja-and-explore ...
Page 1 of 6. Course 014 ... The aim of this project. is to identify .... 014-underwater-school-in-archaeology-in-sanitja-and-explore-underwater-pompeii.pdf.

EXPLORE NE India - Manipur - E-Pao!
Apr 1, 2010 - Production Manager: Kh. Vupendra Singh ... Advertising Manager: Mohd. ... Education and Research, Imphal (Manipur, India) is to prom.

adidas and iProspect explore an innovative ... - Services
We had to look at things a different way, using different data points; ... on that device type than any other,” said Chris Sinclair, Client Services Director,. iProspect. ... Drive sales to adidas brick and mortar stores. • Assign a value for mob

Clojure and Android - GitHub
Improving the Clojure/Android experience. Closing thoughts. Page 5. Clojure and. Android. Daniel Solano. Gómez. Android and the. Dalvik VM ... Page 10 ...

Categories and Haskell - GitHub
This is often summarized as a side-effect free function. More generally ... The composition g ◦ f is only defined on arrows f and g if the domain of g is equal to the codomain of f. ...... http://files.meetup.com/3866232/foldListProduct.pdf ... Pag

Explore the Admin console - G Suite
G Suite services. Add your billing details, add or remove users, set sharing preferences, manage security settings, and more. The Admin console is only available to administrators. When you sign in to your ... see billing details in your Admin consol

Explore Transformations of Rational Functions.pdf
Page 1 of 3. Explore Transformations of Rational Functions! Go to: https://www.desmos.com/calculator. 1. Graph. a. As x gets larger (approaches infinity) what ...