Sunday 27 May 2012

NaV-1 Arduino Soundgin-Babblebot Synth - Part 3

The User Interface


Please go back and read Part 1 and Part 2 if you haven't already. If you want to jump ahead and start building the final hardware go HERE.

Designing the user interface tends to be my favourite part of any project. It is also the most painstaking as it will determine if your project is friendly and intuitive or a total pain to use.

After some thought, I decided to use a less-is-more approach and went with a minimal design. There will be one Rotary Encoder that will choose menu items and adjust parameters. Pressing the encoder knob will act as a Confirm command while pushing the button beside it will act as an Exit command.

The Midi Library has recently been updated to work with the Arduino IDE Version 1.0 so I am going to port this project to this newer IDE. The new IDE uses the suffix .INO for it's files so you won't be able to open them in previous Arduino IDE versions.

Download the latest version of the Midi Library HERE (Version 3.2 as of this post) . Unzip the package and find the folder named "MIDI". Copy this folder and paste into the "libraries" folder inside your Arduino IDE 1.0 installed folder. If all is working, you should find a "MIDI" option listed in the "Sketch>Import Library..." menu of the Arduino IDE.

Here is the circuit schematic

Wiring it up

Notice that I have added a second Breadboard for the interface circuitry. I like having lots of small Breadboard modules that can simply be added as the project grows. If you do this, remember to wire +5V and Ground to the new board. I simply connected two jumper wires from the power strips of the first board to the power strips of the second.

The LCD Display

First we'll get the LCD Display connected. I am using this white on blue, back-lit, 20 X 4 Character display from Adafruit but any standard 20X4 - HD44780 compatible display with back-light should work. Adafruit has a great tutorial for connecting the LCD to an Arduino that you should read. I have soldered a 16 Pin - 0.1" header to the LCD Module so I could plug it into a Breadboard. Here are the LCD Module connections I am using:

LCD Pins

Pin 1 - GND
Pin 2 - +5V
Pin 3 - Center pin of 10K Potentiometer
Pin 4 - Arduino Pin 7
Pin 5 - GND
Pin 6 - Arduino Pin 8
Pin 7,8,9,10 - Not Connected
Pin 11 - Arduino Pin 9
Pin 12 - Arduino Pin 10
Pin 13 - Arduino Pin 11
Pin 14 - Arduino Pin 12
Pin 15 - 100 Ohm Resistor (Other side of the resistor goes to +5V)
Pin 16 - GND

The Rotary Encoder and Buttons

Next we'll connect the Rotary Encoder and Buttons. I am using this Rotary Encoder from Sparkfun as I had it on hand, but will change it to a Panel Mount unit for the final assembly. This Encoder contains a built in switch that is activated by pressing down on the knob.
If you look at the unit you will notice that one edge will have three pins. These are the Encoder pins. Connect the middle pin to Ground, one outside pin to Arduino Pin 5, and the other outside pin to Arduino Pin 6.
The other edge of the Encoder has two pins. These pins connect to the built in switch. Connect one pin to Arduino Pin A0 and the other pin to Ground. (Since we have used all the Arduino Digital Input Pins we will need to steal a couple of Analog Pins for our switches. This is perfectly fine as the software will simply treat them as extra Digital Pins. We are also using the Arduino's built in resistors for these switch inputs so we don't need to add any to the circuit.)
We will connect one more button to our interface. I used a small Breadboard friendly unit similar to this, but will once again replace it with a Panel Mount button for the final assembly. Connect one pin of the button to Arduino pin A1 and the other to Ground.

The Software

Download the code HERE and load into the Arduino. This will allow you to run a simple test to make sure the LCD Display and controls are working properly.

I am using multiple Tabs in the Arduino IDE to break up the code a bit so make sure you open the "NaV1_Interface_Test.ino" file in the IDE. This should automatically open the other files as Tabs.

If all is well, you will see NOTEANDVOLTS.COM on the Display. An Astrix will move across the screen when you turn the rotary encoder and the words "ENTER" and "EXIT" will be displayed when you push the corresponding buttons. You will also be able to play notes from an attached MIDI Keyboard.
NOTE: You will need to adjust the contrast of the display by turning the 10K Potentiometer connected to the LCD until the characters are clearly visible.

The LCD uses the standard Arduino LiquidCrystal library included with the Arduino IDE.

Rotary Encoders are notorious for switch bounce so the software must be ready for this. There are several methods that are floating around but the State Machine method described by Buxtronix seemed to be the most foolproof. The buttons use a simple 300 Millisecond delay to prevent false triggers.

Congratulations if you have made it this far! The basic hardware circuit is near complete. In the next installment, we find a cure for bad memory.

1 comment:

  1. You should take part in a contest for one of the best blogs on the web. I will recommend this site!
    Click Here
    Visit Web