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: Fruit Keyboard
  • 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: 23 Sep 2015 8:16 PM Date Created
  • Views 3577 views
  • Likes 20 likes
  • Comments 16 comments
  • codebug_intermediate
Related
Recommended

10 CodeBug Projects in 10 Days: Fruit Keyboard

element14Dave
element14Dave
23 Sep 2015
imageIntroducing CodeBug!

image  What is CodeBug

image  10 CodeBug Projects in 10 Days

image  Are You a STEM Educator?

 



Getting Started:

image

We start the project by visiting the CodeBug website http://www.codebug.co.uk and creating an 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

Crocodile  Clips

Fruit

Computer


The Project:


CodeBug’s legs have magical properties. They can sense when something conductive is touching them, such as wire, people or even fruit! By connecting different pieces of fruit to CodeBug’s legs, you can get it to say which piece of fruit has been touched.

 

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 to the legs is the Input, away from the legs is the Output. When the background of the leg is red, the leg is at Power, when the leg is at black, it is Ground.

image

 

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.

image

From the If menu, drag in an If block to an empty area of your workspace. From the Inputs/Outputs menu drag a Leg Grounded block and snap it to your If block.Make sure to select from the drop down which leg you will be programming.  From the Sprite menu drag in a Scroll Sprite block and place it inside your If block. Now also from the Sprite menu, drag in a Get String Sprite block and snap it onto your Scroll Sprite block. Change the default "Hello World" to the name of the fruit or vegetiable you will be using in conjunction with the leg ( I used "Apple".  Now from the Loops menu, drag a Repeat While True block and snap it into the Start block. Finally drag the If block into this While loop.

 

image

 

Let's add more fruit the the program. From the If menu drag an If block to an empty space on your workplace. Click on the cog icon on your If block and, in the window that appears, drag an Else If into the If on the right.

image

Repeat the previous steps for adding in the Get String Sprite and Scrolling Sprite for the other Legs. Select from the drop down of the Leg Grounded block which Leg will correspond with what fruit.


image

 


From there we can run the Emulator with the code...


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


With the code working, click on Download, it's just under the simulator controls. When the code downloads, plug in a USB to micro USB into your computer. While holding Button A of your CodeBug also insert the micro USB to 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 code downloaded from the CodeBug website to the USB drive and run the program by pressing Button B.

image




Now let's wire up the fruit!

  • Connect a croc-clip to the leg labeled GND.
  • Connect another croc-clip from leg 0 to a piece of fruit.


Note: If your CodeBug has gone to sleep, wake it up by pressing either button A or B.

  • Test your program by holding the croc-clip connected to ground (make sure you touch the metal part), while pressing the fruit repeatedly. You will see the text scroll as you touch the fruit.


Now you have made a simple fruit input, you can repeat the process by attaching more pieces of fruit with more croc-clips to CodeBug’s other numbered legs.


image


And there you have it a Fruit Keyboard for your CodeBug!

 

 

REMIX THIS PROJECT

 

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

  • Sign in to reply

Top Comments

  • clem57
    clem57 over 9 years ago in reply to fvan +3
    But each clip would be "bananas"! C
  • mcb1
    mcb1 over 9 years ago in reply to fvan +2
    No A pointer which shows which input is grounded. www.codebug.org.uk/explore/codebug/1120/ Hopefully it is public. Mark
  • spannerspencer
    spannerspencer over 9 years ago in reply to mcb1 +2
    I know -- I wish the leg controls were switched on by default. Feels like I'm constantly having to turn them on for the emulator.
Parents
  • mcb1
    mcb1 over 9 years ago

    Very tropical.

     

    I have an alternative idea, that I'll see if I can get up tonight.

     

    Mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fvan
    fvan over 9 years ago in reply to mcb1

    I have an alternative idea, that I'll see if I can get up tonight.

     

    A Minion keyboard ?? image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 9 years ago in reply to fvan

    No

    A pointer which shows which input is grounded.

    www.codebug.org.uk/explore/codebug/1120/

     

    Hopefully it is public.

     

    Mark

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

    Yep, works well in the emulator!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 9 years ago in reply to fvan

    Yep, works well in the emulator!

    How did you simulate the button being grounded ...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 9 years ago in reply to mcb1

    Never mind I didn't have the legs configured in the emulator ... duuh.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • mcb1
    mcb1 over 9 years ago in reply to mcb1

    Never mind I didn't have the legs configured in the emulator ... duuh.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • mcb1
    mcb1 over 9 years ago in reply to mcb1

    It runs slow in the emulator ... real life they flash a little due to the matrixing.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 9 years ago in reply to mcb1

    Me too I have tried to remix the project but the legs won't work. Instead it works fine on the board.

     

    Enrico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • spannerspencer
    spannerspencer over 9 years ago in reply to mcb1

    I know -- I wish the leg controls were switched on by default. Feels like I'm constantly having to turn them on for the emulator.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
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