element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • 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
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Project Flor(a) piano: part 2
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: charlotte_godley
  • Date Created: 3 Mar 2015 11:49 AM Date Created
  • Views 554 views
  • Likes 4 likes
  • Comments 2 comments
  • adafruit_flora
  • charlotte_godley
  • circuits_with_charlotte
  • arduino
Related
Recommended

Project Flor(a) piano: part 2

charlotte_godley
charlotte_godley
3 Mar 2015

In the previous post, we decided to start making a floor piano using a FLORA and some other bits. Here we're going to improve on the code and make it more permanent!


Step 3: improving the code

Before we go any further into making the sensors a permanent installation, we should fix the bugs I mentioned in step 2. We're going to do this using an averaging algorithm which applies a low pass filter.

Basically, this means that the baseline value of "pressed" or "not pressed" alters as time continues - whilst we could just use a regular average for this, the average could be affected by the second problem I mentioned regarding sensor value time delay, so the low pass filter will mean that changes to the sensor value don't change the average by a sufficient amount to be altered by this resistance problem.

The idea is pretty simple:

  • Read in a value
  • check it against the current average (with a small margin of error because 1 or 2 values either side could still be counted as "unpressed")
  • if it's below it, play the note
  • at the end of the loop, recalculate the average: this uses a "k" value, meaning that we take a certain amount of the old average into consideration, and a certain amount of the new sensor value into consideration when recalculating

This particular method is a form of windowing average, but one that works very well on micro controllers because we don't have to store all of the sensor values to figure out the current windowed average.

The code is below, or you can clone it from my Codebender sketch:

 

 

Step 4: Making the keys more permanent

Next up, we're going to lay the keys we made earlier onto a mat and make it permanent so that we don't have to carry around 4 sensors and use alligator clips for everything.

- Begin by cutting the right size material for the mat, including sufficient space to be able to position the FLORA and sew from the keys to the FLORA

- Spray adhesive over each area of the mat you're going to position the keys and stick the key sensors onto the adhesive, taking care to make sure the conductive threads coming from each key do not get stuck to the mat.

- Sew each pair of conductive threads into the mat, connecting one of each thread pairs to one of the Analog pins on the flora (D6-D10) and the other of the thread pairs to GND on the flora. I personally used Sewable snaps so that I could remove the FLORA for other projects, which you can read about on the Adafruit blog.

image

Your final mat should look something like this:

image

 

I haven't shown the buzzer here, or in the code, but that should plug in to a ground and the pin marked "SCL" on your flora - you can either solder this in or alligator clip it if you intend to reuse the FLORA for something else.

Step 5: the final code

Lastly, we need to modify the code written in step 4 so that it applies to each of the 4 keys - this is as simple as setting up a few new variables, as you can see below:

-

I will note that this still isn't completely bug free, and it will be a bit jittery - part of this is fiddling with margin of error and k values. If anyone lands on the perfect solution to make it not jitter so much, do let me know in the comments section!

image

Happy hacking!

 

PS: You can see the video of this project here:

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

  • Sign in to reply
Parents
  • neilk
    neilk over 10 years ago

    charlotte_godley Nice project, Charlotte. Keep up the good work.

     

    Neil

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • neilk
    neilk over 10 years ago

    charlotte_godley Nice project, Charlotte. Keep up the good work.

     

    Neil

    • Cancel
    • Vote Up 0 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