Tedd OKANO / Mbed 2 deprecated uchiwa_tone

Dependencies:   MjGP2Y0E03 mbed

You are viewing an older revision! See the latest version

Homepage

What is this?

Watch this video.

A very simple musical instrument application using pressure and distance measuring sensors.

Haedware

The uchiwa tone has very simple hardware.

  • Microcontroller module : mbed LPC1768)
  • Pressure sensor : Interlink Electronics FSR400
  • Distance measuring sensor : Sharp GP2Y0E03

The two sensor output goes into mbed, the pressure sensor controls the sound amplitude and distance controls frequency.
Sound waveform is stored on RAM in mbed. This waveform is played with those sensor parameters.
Output comes from DAC output of mbed, so the output becomes sound through external amplifier and speaker.

IMPORTANT

The distance measuring sensor GP2Y0E03 uses infra-red light reflection from objects.
In my case, for the reflecting object, I used "uchiwa (a Japanese fan)" is used.

Don't be so pessimistic, if you don't have the uchiwa.
It may be OK to use enough size of cardboard or something ;)

/media/uploads/okano/uchiwa_tone_hardware.png

Software

Some customization can be done in software.

The key of this instrument is made as "C".
When you get the (reflecting object's) distance of the "C", all 3 LED, LED2 and LED3 will be turned-ON. This is a mechanism to help the player who does not have perfect pitch like me ;)
This reference tone can be changed by selecting an item from "Tone_list".

enum Tone_list {
    Tone_A      = 0,
    Tone_Ais,
    Tone_H,
    Tone_C,
    Tone_Cis,
    Tone_D,
    Tone_Dis,
    Tone_E,
    Tone_Eis,
    Tone_F,
    Tone_G,
    Tone_Gis,
};

#define     REFERENCE_TONE  ((float)Tone_C)
#define     REFERENCE_PITCH 442.0

float waveform_generator( int i )
{
#define WAVEFORM_SIN
//#define WAVEFORM_SAWTOOTH
//#define WAVEFORM_CUSTOM_HARMONICS

All wikipages