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
Electronic Toys
  • Challenges & Projects
  • Project14
  • Electronic Toys
  • More
  • Cancel
Electronic Toys
Blog the Rainbow Ukulele
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Electronic Toys to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fmilburn
  • Date Created: 9 Sep 2019 2:09 AM Date Created
  • Views 3576 views
  • Likes 16 likes
  • Comments 24 comments
  • circuitpython
  • neopixel
  • sound
  • toys
  • music
  • feather m4
  • electronictoych
Related
Recommended

the Rainbow Ukulele

fmilburn
fmilburn
9 Sep 2019
image

Electronic Toys

Enter Your Electronics & Design Project for a chance to win a Grand Prize of a SNES Classic and $200 Shopping Cart of Product!

Back to The Project14 homepage image

Project14 Home
Monthly Themes
Monthly Theme Poll

Introduction

I have a 3 year old granddaughter who is now old enough to know she is missing out on something when her older siblings go to Grandad's house for "Robot Summer Camp" but not old enough to attend herself.  So I decided to make something for her. 

 

It should have at least some of the things that make a toy attractive to a 3 year old:

 

  • Buttons
  • Sound
  • LEDs
  • Annoying to parents

 

Unfortunately due to multiple matters including procrastination I was only able to start this last week and so am limited in both time and materials.  A friend recently sent me a link to a site that featured analog synthesizer projects to do with children and it sparked an idea. I could make an analog synthesizer violin with a bow that acted like a potentiometer!  Or something like that.  And here is a favorite book of hers which features animals making music:

image

So somehow the idea for the Rainbow Ukulele gradually formed

 

Where To Start?

Due to the shortage of time it was necessary to work with what was at hand.  It was also time to relearn for the x thousandth time that taking shortcuts does not get things done quicker.  Here is what there was to work with:

 

  • Scrap plywood
  • Adafruit Feather M4 Express
  • Adafruit Prop-Maker Wing (has amplifier and speaker connections)
  • Lots of buttons
  • A ring with WS21812 "NeoPixels"
  • Speaker removed from a junked printer
  • Wire and stuff

 

That should be enough.

 

The Instrument

No time to do proper planning!  Just start building!  Cut out a pattern semi-freehand that fits the plywood:

image

This is the cheapest, crummiest plywood ever... Cut out the pieces and rasp them to shape:

image

That doesn't look too bad:

image

How to make the body? Could sandwich foamboard...

image

That is the crummiest material to cut to shape and work with ever... Glue and clamp:

image

 

Firmware Development

I simultaneously blundered through the firmware (is CircuitPython firmware?) while doing the build above.  The Adafruit Prop-Maker FeatherWing is a reasonably priced daughter board for the Feather series that provides support for NeoPixels and a Class D amplifier.  Audio is only available with the M0 Express and M4 series Feathers and needs to be tested.

 

The first surprise is that according to Adafruit:

 

"Arduino does not have great audio playback support. So we don't recommend using Arduino if you need to play audio.  If you'd like to use the Adafruit Prop-Maker FeatherWing's Audio capabilities, check out the CircuitPython code."

 

OK, I don't fully buy that, but I checked out the CircuitPython code.  Unfortunately the examples and libraries seem to be blocking.  Worst of all it is not possible to use interrupts and according to this pull request closed by ladyada there is no plan to have interrupts.  There is an issue discussion here which seems to go around in circles with no resolution so I guess we are reduced to polling with blocking code.  There are other issues with Python and microcontrollers but lack of interrupts is a non-starter for me.  (MicroPython, from which Adafruit forked CircuitPython, does support some form of interrupts though).

 

To get something started I took a simple NeoPixel example that rotates through a color wheel and poll for button pushes inside the for loop to play a wav file.  The "pass" feature that is supposed to keep the audio from blocking does not seem to work and the NeoPixels do not change color until the wav file is finished.  In addition, I could not get the mixer or volume features to work properly (or at least the way I needed) even using the example code provided by Adafruit.  The wav files are limited to 22 kHz or less and 16 bit wav format.  Should I continue development in future I would use C/C++ on another microcontroller or possibly a Pi Zero.

 

To use the Python code below it is only necessary to place animal sounds (or whatever sounds are desired) on the Feather M4 Express which shows up as a drive when connected.

"""
Plays  files in WAV_FILE on Adafruit M4 Express with
Prop-Maker FeatherWing when the PINs are pulled high
Version 0.2   F Milburn  September 2019
"""
# import time
import digitalio
import board
import audioio
import neopixel
NUM_PIXELS = 24  # NeoPixel strip length (in pixels)
BRIGHTNESS = 0.2 # NeoPixel brightness
enable = digitalio.DigitalInOut(board.D10)
enable.direction = digitalio.Direction.OUTPUT
enable.value = True
strip = neopixel.NeoPixel(board.D5, NUM_PIXELS, brightness=BRIGHTNESS)
def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if pos < 0 or pos > 255:
        return (0, 0, 0)
    if pos < 85:
        return (255 - pos * 3, pos * 3, 0)
    if pos < 170:
        pos -= 85
        return (0, 255 - pos * 3, pos * 3)
    pos -= 170
    return (pos * 3, 0, 255 - pos * 3)
# define wave files
WAV_FILE = ("Burp.wav",
            "Coo.wav",
            "frog.wav",
            "cow-moo3.wav",
            "cricket-1.wav",
            "goat.wav",
            "Snore.wav")
# map switches to board pins, comment gives wire color
PIN = (board.D4,   # purple
       board.TX,   # gray/black
       board.RX,   # white/green
       board.SCK,  # gray
       board.A4,   # gray/orange
       board.A3,   # white
       board.A2)   # white/yellow
# function to generate sounds from wav files
def make_sound(sound_file):
    with audioio.AudioOut(board.A0) as audio:  # Speaker connector
        wave_file = open(sound_file, "rb")
        wave = audioio.WaveFile(wave_file)
        audio.play(wave)
        while audio.playing:
            pass
# Set input pins up
SOUND0 = digitalio.DigitalInOut(PIN[0])
SOUND0.pull = digitalio.Pull.UP
SOUND1 = digitalio.DigitalInOut(PIN[1])
SOUND1.pull = digitalio.Pull.UP
SOUND2 = digitalio.DigitalInOut(PIN[2])
SOUND2.pull = digitalio.Pull.UP
SOUND3 = digitalio.DigitalInOut(PIN[3])
SOUND3.pull = digitalio.Pull.UP
SOUND4 = digitalio.DigitalInOut(PIN[4])
SOUND4.pull = digitalio.Pull.UP
SOUND5 = digitalio.DigitalInOut(PIN[5])
SOUND5.pull = digitalio.Pull.UP
SOUND6 = digitalio.DigitalInOut(PIN[6])
SOUND6.pull = digitalio.Pull.UP
while True:
    for i in range(255):
        strip.fill((wheel(i)))
        # Buttons that are pushed read as 0 or false
        if not SOUND0.value:
            make_sound(WAV_FILE[0])
        if not SOUND1.value:
            make_sound(WAV_FILE[1])
        if not SOUND2.value:
            make_sound(WAV_FILE[2])
        if not SOUND3.value:
            make_sound(WAV_FILE[3])
        if not SOUND4.value:
            make_sound(WAV_FILE[4])
        if not SOUND5.value:
            make_sound(WAV_FILE[5])
        if not SOUND6.value:
            make_sound(WAV_FILE[6])

Different sounds in wav format are available in many places on the internet.

 

The Electronics

Very simple...

image

The pins used are documented in the Python script above and the board connections for Neopixels and the speaker are given in the Adafruit Prop-Maker documentation (links at end of blog).

 

Putting It All Together

Soldered everything up and then hollowed out the interior with a box cutter and a kitchen knife.  Affixed the microcontroller, button switches, and speaker with hot glue and super glue.

image

The Feather M4 Express has a built in 100 mA Lipo battery charger which worked well and was easy to use.  There is room in the body for the battery and an on / off switch which is currently not used since I elected not to leave the battery in.  The demonstration unit is shown below:

 

image

Unfortunately for you the element14 rules require that a video be posted.  But I am going to spare you somewhat and not go through the whole barnyard menagerie.

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

Sorry for that... the 3 year old liked it :-)

 

Beta Testing

This was my first attempt to add music to a project and was a lot of fun.  I had a chance to show it to my granddaughter and she really enjoyed it.

image

One of the things she enjoys is picking out different sounds for it, adding them with my help, and then playing them back.  That is one of the things that distinguishes it from some commercial products.  Since this is more of a concept demonstration I did not leave it with her.  But since she seemed to really enjoy it I plan to revisit the project and investigate the following improvements:

 

  • Use a teensy or Raspberry Pi
  • Improve the build of the ukulele body
  • Change button position to better fit little hands
  • Add a microphone to capture sounds
  • Make it easier to download and add sounds from the internet
  • Add a multipole switch to go from say wav files to different synthesized sounds
  • Look at the violin and bow idea some more with a more analogish approach
  • Allow a way for parents to more easily control volume

 

Thanks for reading!  Comments and suggestions are always welcome.

 

Edits

15 Sep 2019:  Documented Beta Testing

 

Useful Links

Adafruit Feather M4 Express

Adafruit Prop-Maker FeatherWing

  • Sign in to reply

Top Comments

  • 14rhb
    14rhb over 5 years ago +8
    fmilburn that is really awesome and great write up. I thought you were going to pull the book apart and substitute the membrane switches for better ones etc but it seems the book survived. You mention…
  • balearicdynamics
    balearicdynamics over 5 years ago +7
    Frank! One of those projects I think you enjoyed making and thinking to the surprise of the young user then enjoyed playing it and made the user happy and a great fan of you. It's magic. And the video…
  • ralphjy
    ralphjy over 5 years ago +7
    Very nice quick build. I’m sure your granddaughter will love it. Especially the ability to customize the music. I agree that adding veneer would both improve the appearance and durability. I wonder if…
Parents
  • 14rhb
    14rhb over 5 years ago

    fmilburn that is really awesome and great write up. I thought you were going to pull the book apart and substitute the membrane switches for better ones etc but it seems the book survived.

     

    You mention the foam board being crummy but at least it kept the finish product to a reasonable weight. I'm sure many of us have built something and at the end realised how 'over engineered' it had become.

    • Cancel
    • Vote Up +8 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fmilburn
    fmilburn over 5 years ago in reply to 14rhb

    Thanks for the kind words!  I could never pull her favorite book apart :-).  The foam just wouldn’t cut cleanly but you are correct about weight and it is strong enough to take some abuse when glued together.  But really I just like working with wood.

    • Cancel
    • Vote Up +5 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • fmilburn
    fmilburn over 5 years ago in reply to 14rhb

    Thanks for the kind words!  I could never pull her favorite book apart :-).  The foam just wouldn’t cut cleanly but you are correct about weight and it is strong enough to take some abuse when glued together.  But really I just like working with wood.

    • Cancel
    • Vote Up +5 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • 14rhb
    14rhb over 5 years ago in reply to fmilburn

    fmilburn  wrote:

    But really I just like working with wood.

    I do too. It obviously can be removed, added to (using glues, fillers, fixings), get painted up, adjusted and sustainable/eco....and what I like best is that wood is easy to obtain (often for free in small amounts).

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