Hi everyone. I've been tinkering with the arduino/boarduino/freeduino and put together a pretty cool project i'd like to share. I'd love some pointers on the code as well. I'm sure it can be smaller or better formed, but have no formal training in such things. heres the code for the main program. I also wrote a library for some basic MIDI commands as well as a library for the guitar commands they can be found at...
main program - http://www.dwdesignlabs.com/GuitarHeroMidi.zip
midi library - http://www.dwdesignlabs.com/Midi.zip
wii guitar library - http://www.dwdesignlabs.com/guitar_funcs.zip
& the blog and main page are at Guitar Hero Midi Controller | slapyak: tinkering and fidgeting
the GuitarHeroMidi gets unzipped to the projects folder, the other 2 go into your libraries folder.
/*
This is a program for Arduino written for the purpose of using a Wii Guitar Hero Controller
as a MIDI input device. As with most arduino projects, this is released under the GNU
understanding. The use of and modification of the software for personal use is granted.
however rights of sale of completed Guitar Hero Midi Controllers, or kits for the same is
reserved. any commercialization of this kit may only be with the express written consent of
the original author.
The use of the MIDI library from http://slapyak.wordpress.com/ is required.
author: Dave Wernli (slapyak)
created: April 2008
website: http://slapyak.wordpress.com/
resources:
Midi Guide: http://www.indiana.edu/~emusic/etext/MIDI/chapter3_MIDI.shtml
I2C (wire) library: included with new arduino environment disrtibutions
Wii adaptor/code: Tod Kurt - http://www.todbot.com
Windmeadow labs - http://www.windmeadow.com/node/42
Wii guitar mapping, function basics: Jason Leyrer - http://www.jleyrer.net/
LCD4Bit library: http://www.arduino.cc/playground/Code/LCD4BitLibrary
Arduino Playground: Serial, test library, countless tidbits from the forum posts
*/
/***********************************************************************************************
* guitar Hero Midi Controller.
* By: Dave Wernli (SlapYak)
* http://www.dwdesignlabs.com/projects/
* April 2008
************************************************************************************************/
//includes
#include <Wire.h>
//#include <LCD4Bit.h> // for output to lcd. hooked into pins 4,5,6,7
#include <Midi.h>
#include "guitar_funcs.h" // available at http://googlepages.slapyak.com & http://slapyak.wordpress.com
Midi midi=Midi();
//LCD4Bit lcd = LCD4Bit(2);
#define latchPin 16 // setting up our shift registers
#define dataPin 14 // the input and output registers are connected serially
#define clockPin 15 // we'll only be accessing the input register at startup
#define commandDelay 150 // a variable for experimenting with the loop
// to avoid duplicate commands cancelling each other out.
#define mCC_1 71 // the controller for resonance, changes with joystick X
#define mCC_2 74 // the controller for frequency, chages with joystick Y
uint8_t mode=0; // holds byte indicating mode selection -
// scale is the tonal mode -
// Ionian, Mixolydian, Lydian, Dorian, Aeolian, Phrygian, Locrian, Petatonic(not really a mode, and not in use...)
uint8_t scale=0;
uint8_t scale_chart[8][7]={{0,2,4,5,7,9,11},{0,2,3,5,7,9,10},{0,1,3,5,7,8,10},{0,2,4,6,7,9,11},{0,2,4,5,7,9,10},{0,2,3,5,7,8,10},{0,1,3,5,6,8,10},{0,4,7,9,12,16,19}};
//char scale_name[24] = {"Ion", "Dor", "Phy", "Lyd", "Mix", "Aeo", "Loc", "PET"};
uint8_t octave= 4;
uint8_t key = 0;
// chord will hold our chord patterns and position in the pattern
uint8_t chord = 0;
uint8_t chord_chart[4][4]={{0,0,0,0},{0,4,0,0},{0,3,5,0},{0,7,12,16}};
uint8_t buttonstatus; // button/strum info - referenced in binary (a bit for each button)
uint8_t oldButtonStatus=0; // to compare to avoid duplicate commands from a single action
byte mCC_1val = 64; // controller 1 value xJoy, controlls timbre
byte mCC_2val = 64; // controller 2 value yJoy, controlls resonance
byte wham = 0; // a boolean value to control how often we enter the pitchbend funtion.
uint8_t dipSwitch = 0; // to hold our dipswitch information
uint8_t drumOn = 0; // keeps track of drums that are playing, so we dont just re-trigger the drums over and over
uint8_t drumUp = 0x2E; // sets up strum to open hi-hat
uint8_t drumDn = 0x2A; // sets down strum to closed hi-hat
uint8_t drumGr = 0x24; // sets green button to kick
uint8_t drumRe = 0x26; // sets red button to snare
uint8_t drumYe = 0x30; // sets yellow to high tom
uint8_t drumBl = 0x2D; // sets blue to low tom
uint8_t drumOr = 0x33; // sets orange to ride
uint8_t drumPlus = 0x31; // sets plus to crash one
uint8_t drumMinus = 0x39; // sets minus to crash two