Lesson 45--Microduino Electric Guitar

From Microduino Wiki
Revision as of 09:12, 12 September 2016 by Fengfeng (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Objective

This tutorial will show you how to use ultrasonic sensor to make an electric guitar.

Equipment

  • Other harware equipment
    • USB cable One
    • Ultrasonic sensor One
    • Loudspeaker One
    • 10KΩ resistor One
    • Breadboard jumpers several
    • Battery One


Note Frequency

We all know that the notes Do - Re - Mi - Fa - Sol - La - Si/Te have their corresponding frequencies, seeing at the two tables below:

NoteFrequency1.jpg
NoteFrequency2.jpg


Schematic

ElectricGuitarSchematics.jpg


Program

guitar

In the program,int toneFrequency[]={415,440,466,494,523,554,587,622};

It is used to define the range and number that can generate notes. You can adjust the note frequency range according to individual needs.


Debugging

1. Download Tone library: Tone, and put it into libraries of IDE and then restart IDE. Compared with the built-in Tone, this Tone library can output waves with different frequency at the same time.


Caution: Decompress and change #include <wiring.h> in Tone.cpp to #include <Arduino.h>, or it'll cause errors.

2. Build the circuit according to schematic:

ElectricGuitarConnect.jpg

You can mark the location of notes according to note frequency on the battery.

3. Download and run the code

4. Move the obstruction in front of ultrasonic and pay attention to the loudspeaker.

Result

The loudspeaker will generate different notes according to different locations of the obstruction, which is basically the same with the note on the battery.


Video