Lesson 8: Simon - Arrays



Similar documents
#include <Gamer.h> Gamer gamer; void setup() { gamer.begin(); } void loop() {

Arduino Lesson 1. Blink

The first program: Little Crab

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game

2 The first program: Little Crab

QaTraq Pro Scripts Manual - Professional Test Scripts Module for QaTraq. QaTraq Pro Scripts. Professional Test Scripts Module for QaTraq

Programming in Access VBA

TUTORIAL FOR INITIALIZING BLUETOOTH COMMUNICATION BETWEEN ANDROID AND ARDUINO

TUTORIAL: Marketing Automation Gold-Vision 7

Arduino Lesson 5. The Serial Monitor

DTN AP Invoice Transaction Import

Drawing a histogram using Excel

Manual. OIRE Escuela de Profesiones de la Salud. Power Point 2007

Speed Based on Volume Values & Assignment (Part 1)

How to Build a Simple Pac-Man Game

An Introduction To Simple Scheduling (Primarily targeted at Arduino Platform)

Excel 2003: Ringtones Task

Administrator Quick Start Guide

AUTHENTICATION... 2 Step 1:Set up your LDAP server... 2 Step 2: Set up your username... 4 WRITEBACK REPORT... 8 Step 1: Table structures...

Sharing a Screen, Documents or Whiteboard in Cisco Unified MeetingPlace

Code Kingdoms Learning a Language

Welcome! Want to find out more? Follow this tutorial, then launch Part 1 to get started.

Advanced Presentation Features and Animation

Use fireworks and Bonfire night as a stimulus for programming

Line Tracking Basic Lesson

How to see the market context using CCI Written by Buzz

Interaction: Mouse and Keyboard DECO1012

Programming the VEX Robot

Arduino Lesson 16. Stepper Motors

Create a Presentation on Marketing. Intel Easy Steps Intel Corporation All rights reserved.

MailChimp Instruction Manual

3. Add an Event: Alarm Alarm 0 a. Add an Action: Set Variable i. Applies to: Self ii. Variable: time_left iii. Value: +1 iv. Check the Relative box

User Guide Setup, sales, purchase and support information for your Clear Books account

Table of Contents TASK 1: DATA ANALYSIS TOOLPAK... 2 TASK 2: HISTOGRAMS... 5 TASK 3: ENTER MIDPOINT FORMULAS... 11

the GentInG GUIde to slots

Excel Reports User Guide

User Guide January 10

Simple Cooperative Scheduler for Arduino ARM & AVR. Aka «SCoop»

Outbreak questionnaires and data entry using the new EpiData modules

PARAGRAPH ORGANIZATION 1 Worksheet 1: What is an introductory paragraph?

Shopping Cart Manual. Written by Shawn Xavier Mendoza

Chapter 4: Website Basics

Content Management System User Guide

The BSN Hardware and Software Platform: Enabling Easy Development of Body Sensor Network Applications

NetIQ Advanced Authentication Framework - Administrative Tools. Installation Guide. Version 5.1.0

Microsoft Office 365 Portal

smarshencrypt User s Guide

The Richard Pate School. Draft Year 4 Scheme of Work for Scratch

CONTENTS. What is ROBOTC? Section I: The Basics

WebPlus X7. Quick Start Guide. Simple steps for designing your site and getting it online.

Arduino Lesson 14. Servo Motors

HandPunch. Overview. Biometric Recognition. Installation. Is it safe?

HEALTH MANAGEMENT SYSTEM RESISTANCE EXERCISE MODULE TABLE OF CONTENTS

HP StorageWorks Modular Smart Array 1000 Small Business SAN Kit Hardware and Software Demonstration

X-Trade Brokers Dom Maklerski S.A. XTB Expert Builder. Tutorial. Michał Zabielski

Advanced Topics: IP Subnetting A WHITE PAPER PREPARED FOR ASPE TECHNOLOGY. toll-free:

R.T.S. - MY TRADING PLAN

DS1307 Real Time Clock Breakout Board Kit

Introduction to Arduino

Connecting Arduino to Processing a

Microsoft Access 2010 Overview of Basics

ECDL. European Computer Driving Licence. Spreadsheet Software BCS ITQ Level 2. Syllabus Version 5.0

My EA Builder 1.1 User Guide

MICROSOFT POWERPOINT STEP BY STEP GUIDE

Marist School Computational Media. Processing Exercise 01 Bouncing Ball Animation. Description:

Look in the top right of the screen and located the "Create an Account" button.

Arduino Lesson 13. DC Motors. Created by Simon Monk

IE Class Web Design Curriculum

Slave Computer 1 Slave Computer 2

Enhancing Your Smart Board Lessons

m ac romed ia Fl a s h Curriculum Guide

Power Tools for Pivotal Tracker

ISO 14001:2004 EMS Internal Audit Guidance

Creating a 2D Game Engine for Android OS. Introduction

USING WINDOWS MOVIE MAKER TO CREATE THE MOMENT BEHIND THE PHOTO STORY PART 1

TUTORIAL 3 :: ETHERNET SHIELD AND TWITTER.COM

An Introduction To The Web File Manager

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

Creating trouble-free numbering in Microsoft Word

Document Management User Guide

How To Build An List Of Customers

Mojo Surveys 2.6 Getting Started Guide

BBC micro:bit Cookbook Using the Code Kingdoms JavaScript editor

MAKE YOUR FIRST A-MAZE-ING GAME IN GAME MAKER 7

Amusement Park Project

Creating Online Surveys with Qualtrics Survey Tool

Putting on an exhibition about your research

Netigate User Guide. Setup Introduction Questions Text box Text area Radio buttons Radio buttons Weighted...

This article Includes:

Virtual Integrated Design Getting started with RS232 Hex Com Tool v6.0

CATIA V5 Tutorials. Mechanism Design & Animation. Release 18. Nader G. Zamani. University of Windsor. Jonathan M. Weaver. University of Detroit Mercy

How To Insert Hyperlinks In Powerpoint Powerpoint

Transcription:

Lesson 8: Simon - Arrays Introduction: As Arduino is written in a basic C programming language, it is very picky about punctuation, so the best way to learn more complex is to pick apart existing ones. In this session, you are going to hack the game Simon so you can re design the images. You will start by working on a stripped backed version, giving you the opportunity to write some to get it working and change its functionality. Once working, you can then pick it apart further and try to work out the logic. Goals Play Simon Look at the logic of some of the Re design the game interface images using arrays this Test your Project Save Save your project Page 1 - Lesson 8: Simon - Arrays

Step 1: Play the game 1. Open the game Simon then CodeClub > SimonSays 2. Play Simon Says Whats your top score? Write it here Step 2: Understanding the 1. Open the game Simon then CodeClub > Simon00 2. Find the inclusion of the gamer library This is included in every DIY Gamer sketch and should now look quite familiar /* * SIMON SAYS! (images) * A TWSU Gamer game by YOU! * This lesson is about arrays and images! */ #include <Gamer.h> // Include the Gamer library Page 2 - Lesson 7: Simon - Arrays

Step 2: Understanding the 3. Find the referencing of the gamer library This is where the gamer library is called upon to do its magic /* Create an object - a copy of the DIY Gamer library, which contains commands for controlling the display, buttons, and everything else on your console. */ Gamer gamer; 4. Find the referencing of the gamer library This happens once at the beginning. void setup() { gamer.begin(); // Fire up the Gamer! } Page 3 - Lesson 7: Simon - Arrays

Step 2: Understanding the 5. Find the void loop function This happens again and again as long as the gamer has power. void loop() { for(int i=0;i<4;i++) { gamer.clear(); //clear delay(100); //wait gamer.printimage(framessimon[i]); //print delay(300); //wait } //and so on! 6. Code comprehension Let s look at that bit of in detail, it is called a for loop. It is a neat way of compacting a lot of repetitive into a few lines. This will in effect display all 4 arrow images one after the other. Lets break it down line by line: for(int i=0;i<4;i++) { This line starts the for loop and creates a variable called i that will hold the frame number of the animation to display. It keeps adding 1 to the value of i, until it gets to 4. gamer.clear(); //clear This line clears the gamer screen. delay(100); //wait This line makes the gamer wait for 100 milliseconds. gamer.printimage(framessimon[i]); //print This line makes the gamer display the frame of the animation held by the variable i delay(300); //wait This line makes the gamer wait for 300 milliseconds. } //and so on! After the closed bracket, it then returns to the top of the for loop and checks the value of variable i again. Page 4 - Lesson 7: Simon - Arrays

Step 3: Re-design the arrows screens 1. Find the up, down, left and right arrays that are used in the game Remember these from the earlier sessions. You should be able to read the ones and zeros as on and off LEDs. This one is the image for the up button. { // up 2. Design your new screens for arrows on the paper game design worksheets Use the squares array templates to design your own personal version of the up, down, left and right buttons. They could be smaller, bigger, to the edge, full screen. The choice is yours. Page 5 - Lesson 7: Simon - Arrays

Step 3: Re-design the arrows screens 3. Open the arrays sketch then CodeClub > Arrays Change the up array to your design { // up { // up Test your project 4. Test your This will just check that the first edited array for the up arrow is understood. 5. Not compiling? Check your array is still 8 by 8 and that you have not deleted anything other than the array ones and zeros. If you can t solve it, simply re-open the sketch and start again. Page 6 - Lesson 7: Simon - Arrays

Step 3: Re-design the arrows screens 6. Find the down array in the Change the down array to your design { // down { // down B00011000 Test your project 7. Test your This will just check that the first edited array for the down arrow is understood. Page 7 - Lesson 7: Simon - Arrays

Step 3: Re-design the arrows screens 8. Find the left array in the Edit the ones and zeros to display the new design you have just created. { // left B00010000, B00110000, B00110000, B00010000, { // left B00100000, B01100000, B11100000, B11100000, B01100000, B00100000, Test your project 9. Test your This will just check that the first edited array for the left arrow is understood. Page 8 - Lesson 7: Simon - Arrays

Step 3: Re-design the arrows screens 10. Find the right array in the Edit the ones and zeros to display the new design you have just created. { // right B00001000, B00001100, B00001100, B00001000, { // right B00000100, B00000110, B00000111, B00000111, B00000110, B00000100, Test your project 11. Test your This will just check that the first edited array for the up right is understood. 12. Remember If things go really wrong, reopen the sketch and try again 13. Upload and Test to transfer the onto the Arduino in the DIY Gamer. Is it now displaying your versions of the arrows one after the other? 14. Save your sketch Go to File > Save as. Save your Sketch as SimonYourName Page 9 - Lesson 7: Simon - Arrays

Step 4: Design the Go, Right and Wrong screens 1. Find the arrays for; go, tick and cross This has the term byte at the beginning and a name. A byte is a the term for one single image or chunk of information. The name will be used to summon this particular array. // This is our GO! image byte go[8] = { B01101110, B10001010, B10001010, B10001010, B10101010, B01101110, B00100000 }; 2. Re-design the arrays for; go, tick and cross Edit just the same as you did for the arrow arrays. Page 10 - Lesson 7: Simon - Arrays

Step 4: Design the Go, Right and Wrong screens Test your project 3. Test your Happy with everything? 4. Upload and Test to transfer the onto the Arduino in the DIY Gamer. You should now have your DIY Gamer displaying all the images you have designed for your version of Simon Says. Next you need to get the buttons working. Save Save your project 5. Save your sketch Go to File > Save as. Save your Sketch as SimonYourName Well done! You have used your knowledge of arrays to start to design your own game assets. Challenge: Find the delays and alter them to change the speed of playback. Page 11 - Lesson 7: Simon - Arrays

Annotated sketch Your should now look like this... /* * SIMON SAYS! (images) * A TWSU Gamer game by YOU! * This lesson is about arrays and images! */ #include <Gamer.h> // Include the Gamer library /* Create an object - a copy of the DIY Gamer library, which contains commands for controlling the display, buttons, and everything else on your console. */ Gamer gamer; /* You should create your own arrays with your own images! */ // These are our arrow images byte framessimon[4][8] = { { // up }, { // down Page 12 - Lesson 7: Simon - Arrays

Your should now look like this... { // left B00010000, B00110000, B00110000, B00010000, }, { // right B00001000, B00001100, B00001100, B00001000, } }; // This is our GO! image byte go[8] = { B01101110, B10001010, B10001010, B10001010, B10101010, B01101110, B00100000 }; // This is our tick image byte right[8] = { B00000001, B00000011, B00000111, B00001110, B11011100, B11111000, B01110000, B00100000 Page 13 - Lesson 7: Simon - Arrays

Your should now look like this... }; // This is our cross image byte wrong[8] = { B11000011, B01100110, B01100110, B11000011 }; void setup() { gamer.begin(); // Fire up the Gamer! } void loop() { for(int i=0;i<4;i++) { gamer.clear(); //clear delay(100); //wait gamer.printimage(framessimon[i]); //print delay(300); //wait } //and so on! gamer.clear(); delay(100); gamer.printimage(go); delay(300); gamer.clear(); delay(100); gamer.printimage(right); delay(300); gamer.clear(); delay(100); gamer.printimage(wrong); delay(300); } Page 14 - Lesson 7: Simon - Arrays