element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
CodeBug
  • Learn
  • Learning Center
  • STEM Academy
  • CodeBug
  • More
  • Cancel
CodeBug
Blog 10 CodeBug Projects in 10 Days: Steady Hand Game
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join CodeBug to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: element14Dave
  • Date Created: 25 Sep 2015 8:33 PM Date Created
  • Views 1435 views
  • Likes 20 likes
  • Comments 5 comments
  • codebug_intermediate
Related
Recommended

10 CodeBug Projects in 10 Days: Steady Hand Game

element14Dave
element14Dave
25 Sep 2015
imageIntroducing CodeBug!

image  What is CodeBug

image  10 CodeBug Projects in 10 Days

image  Are You a STEM Educator?

 


We start the project by visiting the CodeBug website http://www.codebug.co.uk and creating animage

account. It only takes a few minutes. While logged in, clock on Create to start a new project. Don't forget to save your work!

 

The interface for CodeBug contains an area to the right of the screen with is the primary programming interface. There are a series of menus that are used to store the blocks with can be dragged from the menus into the coding area. Good blocks are made to connect together, and that is what we intend to do!


Now that you have familiarized yourself with the interface, let's get started on an intermediate project Thomas Macpherson-Pope pulled together from CodeBug.org.uk

 


What you need:

CodeBug

Micro USB Cable

CR2032 Battery

Metal Coat Hanger

Plastincine/Blu-Tac

Crocodile  Clips

Computer


The Project


Would you like to play a game?Let's make one with CodeBug!The Steady hand game involves trying to get a metal wand from one side of a wavy wire to the other, without the two touching. The game works because it is made from an incomplete electrical circuit. When the metal wand touches the metal wire course, the circuit is completed and this triggers an alarm. CodeBug can sense when the circuit is completed using its legs, and can then tell the player that they have lost the game.

 

The Program should simply detect if Leg 1 (attached to the wavy course) has been connected to the Ground Leg (attached to the metal wand). If this happens, you then need to scroll a message telling the player that the game is over.

 

To set the Legs of the CodeBug we will need to first configure the Emulator. To do this we will need to open the emulator configuration via the settings cog on the emulator. Tick the Show Leg Controls box. Click on the Configure Emulator button to complete the settings change. The emulator will now show the status of the CodeBug's legs with blue arrows. The arrow pointing into the legs denotes that it's set as an Input; away from the legs is an Output. When the background of the leg is red, the leg is at Power, when the leg is black, it is Ground.

image


With the program working we can now send that over to the CodeBug.

 

With the code working, click on Download; it's just under the emulator controls. When the code downloads, plug a USB to micro USB cable into your computer. While holding Button A of your CodeBug also insert the micro USB into the CodeBug. The top left LED in the matrix on the CodeBug will flash. Your computer should also recognize the CodeBug as a USB drive on your computer. Copy the downloaded code from the CodeBug website to the USB drive and run the program by pressing Button B. If your CodeBug is on battery power, you can now disconnect the USB cable.


Now that the Emulator has been configured, we can begin programming the legs. To do this we will need to click on the Cog of the Start block. From the popup we can drag the Leg Input/Output block into the Start block on the right. Because we want the Leg to sense a button, we will need to tell CodeBug to use Leg 1 as an Input.


image



We want CodeBug to run different code depending on if a leg's circuit is complete. To do this we will need an If block. From the Inputs/Outputs menu drag a Leg Grounded block and snap it to your If block. Click the block's drop down menu to change the Leg to 1.

image

 

We will need a difference code to run if the circuit is complete. Any code inside the If block we just did will only run if the condition of the If block is True (Leg 1 is connected to Ground). Lets first put a Scroll Sprite block in the If block. Next we can attach a Get String Sprite block into the Scroll Sprite puzzle piece. Next we will change the default "Hello World" to "Game Over". We'll also need to make the code repeat so the CodeBug can continuously detect the input. To do this let's grab a Repeat While True from the Loops menu. We will snap it into the Start block and the If block into the While Loop.



image

Now it's time to see if it works via the Emulator...


You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 


The course consists of a metal wavy path and a metal wand.

  • Break the loop of your coat hanger and then bend it into a fun shape.
  • Attach a croc-clip to one end of your coat hanger and the other clip to Leg 1 on CodeBug.
  • Make a wand with another piece of wire with a loop at one end. Feed the wire through the wand loop.
  • Use plasticine to secure the two ends of the wire course, creating two bases so the course stands upright.
  • Attach a croc-clip from the end of your wand to the Ground Leg on CodeBug.


Make sure your metal wire and wand have no sharp edges!

image



REMIX THIS PROJECT

 

See more CodeBug projects and learn how you can get one of your own by visiting: 10 CodeBug Projects in 10

  • Sign in to reply

Top Comments

  • mcb1
    mcb1 over 9 years ago +3
    This is a relatively easy one to setup for a classroom or tutorial type environment. Place the 'mechanicals' on a board and fit your codebug over a couple of connection points. Mark
  • balearicdynamics
    balearicdynamics over 9 years ago +2
    Hi Dave! Nice project Maybe there is a typo in the text. the title Now it's time to see if it works via the Emulator ... XXX seems before the program is explained, then it is repeated (apparently in the…
  • balearicdynamics
    balearicdynamics over 9 years ago in reply to Jan Cumps +2
    Extremely simple yet efficient
Parents
  • balearicdynamics
    balearicdynamics over 9 years ago

    Hi Dave!

     

    Nice project image

    Maybe there is a typo in the text. the title

    Now it's time to see if it works via the Emulator...

    XXX

    seems before the program is explained, then it is repeated (apparently in the right place) but with plain style. Please take a look to avoid confusions, Thank you.

     

    Enrico

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • balearicdynamics
    balearicdynamics over 9 years ago

    Hi Dave!

     

    Nice project image

    Maybe there is a typo in the text. the title

    Now it's time to see if it works via the Emulator...

    XXX

    seems before the program is explained, then it is repeated (apparently in the right place) but with plain style. Please take a look to avoid confusions, Thank you.

     

    Enrico

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube