My Guitar Project

So many here have helped me with many questions and curiosities, and I am getting close to a complete project. I would like to share what I am doing, because its a fun project. I have taken LED's and put them into a guitar, making it a fretless guitar. Follow the little red dots to what key and mode it is set to and whala, good lead guitar teacher all built in. I have actually got all my LED's into the fret board and am currently wiring it up in a test domain, to make sure my soldering is good to go. Well setting up 4 different patterns to every key is what I have accomplished so far, and I have tested it well on 3 8x8 led grids with 3 max 7219. (much thanks to Nick Gammon, and CrossRoads, and a few others here). All of that code works, and now I am on part 2. The intent is to set up scales and perhaps songs of which one can follow the LED's as they flash on, to help themselves learn a song, or scale. I have started with a simple scale, well technically its a pentatonic, as a scale has 8 notes and a pentatonic has 5. I started here as it is simple. What I have done on my bread board is hook up 1 max7219, 1 8x8 LED grid, and 1 potentiometer. I am unsure if I can do this digitally yet, so I started with what I know. My pentatonic scale is adjustable by the potentiometer to allow a variable speed. I am trying to figure out how to set up timing on this, aka 120 bmp (Beats Per Minute), as an example. This is what I have done and here is my code, it works to the point it can speed up or slow down the LED flashing in a pattern based on the pentatonic. It is not quite what I am looking for, so I seek more help from the masters out there. I am using delay, which I think is the wrong way to go, hence I look for help. Below is the code I use to vary the speed of LED flashing, however I am unsure how to time this up to bpm.

#include "binary.h"  //Use this include for writing a byte in binary
#include "LedControl.h"//Use this include for controling LED's
LedControl lc=LedControl(13,12,11,1); /// Arduino data pin,clock pin,device selecting pin, number of max7219's


void setup()
{

  lc.shutdown(0,false);
  lc.setIntensity(0,5);

} 

void loop()
{

  ledPattern();


}

void ledPattern()
{
  int potValue = analogRead(A0);
  int delayValue = potValue;

  lc.setRow(0,5,B10000000); 
  delay(delayValue);
  lc.setRow(0,5,B00000000);

  lc.setRow(0,5,B00010000);
  delay(delayValue);
  lc.setRow(0,5,B00000000);

  lc.setRow(0,4,B10000000);
  delay(delayValue);
  lc.setRow(0,4,B00000000);

  lc.setRow(0,4,B00100000);
  delay(delayValue); 
  lc.setRow(0,4,B00000000);

  lc.setRow(0,3,B10000000);
  delay(delayValue);
  lc.setRow(0,3,B00000000);

  lc.setRow(0,3,B00100000);
  delay(delayValue);
  lc.setRow(0,3,B00000000);

  lc.setRow(0,2,B10000000);
  delay(delayValue);
  lc.setRow(0,2,B00000000);

  lc.setRow(0,2,B00100000);
  delay(delayValue);
  lc.setRow(0,2,B00000000);

  lc.setRow(0,1,B10000000);
  delay(delayValue);
  lc.setRow(0,1,B00000000);

  lc.setRow(0,1,B00010000);
  delay(delayValue);
  lc.setRow(0,1,B00000000);

  lc.setRow(0,0,B10000000);
  delay(delayValue);
  lc.setRow(0,0,B00000000);

  lc.setRow(0,0,B00010000);
  delay(delayValue);
  lc.setRow(0,0,B00000000);

}

I would like to thank everyone in advance for their help, this has been a fun first arduino project.

Hi sensai. I cannot offer you any help here as I am always getting advice from Crossroads, Nick and many other fine minds here on the forum. I just wanted to say that I am very interested in watching the progress of your project. Well before I had even heard of Arduino and micro controllers, and also being a guitarist, I had thought of this too. Stick with it the sky is the limit with this idea. Just think of all the different scales, and different positions of those scales. Then as you point out there is also the potential for indicating chord shapes, lead runs ... the mind boggles. Grumpy Mike of this forum is a smart fellow who also has a history of developing some interesting musical projects so maybe he can offer you some advice. Don't get me started on using different coloured LED's to indicate the root notes of scales, degrees of chords etc.

I for one would be very interested in seeing any photos of the construction of the fretboard LED lighting etc. Good luck and keep us posted, Pedro.

p.s. - In regard to the use of delay, which some here refer to as "the devils function" ]:) ]:) ]:D take a look at blink without delay

Thank you, I really appreciate your enthusiasm to this project. I may yet end up building a fretboard... my solder skills are less then ideal, and if I take the peice of mahogany I got sitting in the garage and hit it up with a cnc router, I can "trench" where LED leads run to, which may be just the plan, currently I have LED's in a fret board, but I am having issues as of yet. I will sort it out, I am rather obsessed with this project. Thanks for the hint on blink without delay... Ill go have another look at that, I did do that example when I started playing with Arduino a few months ago. Thank you

Hey sensai, check this out

http://news.cnet.com/8301-17938_105-20073086-1/fretlight-learn-to-play-guitar-10-times-faster/

Not trying to put you off, but I had a vague recollection that I had seen a product like this not long after I initially thought of the idea many years ago. Maybe you can sus one out and possibly get a few clues. Pedro

Pedro147, I saw this a month ago, a while after I started my project, there is open source code for this and schematics available, They are using shift registers in their system, they have chords and notes, as well as a flashing root note. I am working on a built in tuner and intonation setting system as well as a metronome. One thing at a time, and it will all fall into place. Oh and I actually do not care much for those guitars themselves, I guess I am too much of a Les Paul fan. Thanks for the link though.

This is a great ideia. Some time ago i thought about something similar, but then i gave up because i thought it would be to expensive.

When i was thinking about it, i thought about using RGB LEDs. RGB LEDS would make possible some very useful features, like for instance showing tonic and dominant for each scale (for instance for C scale all notes would be green, except for C (tonic) red and G (dominant) blue... something like that). Or each color could signal which left hand finger to be used, something like Green = Finger 1, Blue = Finger 2, Yellow = Finger 3 and Red = Finger 4. This would be very helpful for people trying to learn scales (learning with the right fingering is something very important and often over looked).

Well, it was just an idea. I know i would probably make the project even more expensive and the code more complicated, but who knows, maybe someone is interested in having a go... ;)

I think this is surely a very fun project and i wish you luck with it! =)

It really isn't that expensive of a project. Getting tools I did not have was probably the biggest cost. Being a carpenter and a guitar enthusiast, I already had many tools, and of course the guitar. I am using an epiphone sg for this project. I solved my solder problem by getting a new solder rod. I fixed all the dead LED's, and tested each one. So far so go... now to connect it to bread board. If this works I am going to have to purchase a uno pro at some point. There is lots of room in the guitar body to place the uno and since the pick guard is a rather large cover, I can router underneath and cover the chambers with the pick guard. Cost so far for just the parts and pieces are as follows. 1 Guitar 300$ which I already bought its pretty old, and never played. 3 max7219 10$ 200 LED 6000mcd 20$ I also got 1000 out of china for 10$ only 1500 mcd I think Acrylic sheet 30$ this is a 20x24 , enough to cover 9 fret boards. LCD screen 5$ also got a couple shields for 15$ push buttons 4$ hmn I think that is it for cost. I got all the cat 5 wire for free from a friend. So really it isn't that expensive of a project. None the less it is a fun project. I may invest in a cnc router, and just groove out the fretboards backsides, ro easy installation of LED's. Still working on the tempo issue, though I may be on the right track with a rotary encoder.

sensai: It really isn't that expensive of a project.

400$ is still too much for my pockets! =P

Keep us informed. It is a great project! I would love to see some photos of it... ;)

(I am a Classical Music Composer, so if you need maybe i can also give some help with the "musical" side of it... ) =)

Thank you very much for your offer, I may very well take you up on that, as my musical efficiency is from talent, and not skill. I will get some pictures soon enough, and post them up.

fretless guitar.

If you didn’t remove the frets, it’s not fretless. I don’t understand that part, but now here’s some help:

I am unsure if I can do this digitally yet, so I started with what I know. My pentatonic scale is adjustable by the potentiometer to allow a variable speed. I am trying to figure out how to set up timing on this, aka 120 bmp (Beats Per Minute), as an example.

Tempo control : you could use a rotary encoder hooked up via interrupt so that your code isn’t constantly polling for pin change within the main loop. There are lots of tutorials on interrupts floating around here, and there are multiple libraries for encoders, although writing your own code may help in understanding how timers work.

As far as metronomic beating or a regular trigger time, you can use the Interval_Timer library to precisely control when an event occurs at a regularly spaced time, i.e. a beat. You could also set up your own interrupt using the internal timers of the arduino without the library…now here comes the challenge.

Competing interrupts - if your encoders are on an interrupt that is triggered externally, but you have a periodic event driven by timer interrupt you may miss a turn of the encoder, or things could get funky. You need to dig into the internals of your specific chip to answer this, and the data sheet is a good starting point. Atmel documentation is amazing in comparison to some other manufacturers, so don’t be intimidated by the 1000 pages. Just use ctrl+F and find the keyword you’re looking for.

Depending on which timer you use, there are a host of modes and you should also read about those - some timers require the counter to overflow prior to accepting a new value, etc…

One advantage of something that uses an ARM core, I know this is true for sure with the Cortex M series, they use an NVIC - Nested Vector Interrupt Controller which allows you to say “this thing is the most important, this is the second, etc…” so that if you turn the encoder in the middle of a pulse, it sets a flag saying, “hey the encoder was turned so finish the pulse, then adjust the encoder value.”

Programming advice: COMMENT EVERYTHING - so that in two days when you forget what something did, you know, and so that when others read your code, it’s very, very clear what is happening. Beacause your code is simple, it’s readable/understandable, but when you get more complex, it likely won’t be anymore, and your comments are invaluable.
Programming advice II: Instead of mapping each pitch to a set of values like you have, abstract your pitches to a lookup table (array) or #define so that all you see is a note - it will make your code easier to work through, add scales, etc…without having to rewrite your pitches every time you add a new scale, full chord, etc…You could also use standard midi note numbers, ints, which are universal, you can do everything relative to the open strings MIDI note values so that you could easily modify tuning and still have it work, and also you could read tables circularly (like a circular buffer, but no new values being added) so that when you change the root, you can always use the same lookup table. Having MIDI be part of your code would allow you to easily adapt it to MIDI control, thus giving you the ability to use a standard MIDI file playing back say through the speakers of a computer, to be closely synced with your device…I suspect something like that could be down the road for you when you get the other parts working.

Below is the code I use to vary the speed of LED flashing, however I am unsure how to time this up to bpm.

Reading about how timers work - clock, prescaler, etc… will answer this question for you. Basically, just start doing timer tutorials and I bet you’ll have a great finished project in no time.

I have started with a simple scale, well technically its a pentatonic, as a scale has 8 notes and a pentatonic has 5. I started here as it is simple.

Side note music theory and history lesson : Scales don’t have 8 notes - major scales, modes, and other derivatives of common practice Western theory have 7 pitch classes, and the 8th note is a repeat of the 1st. In the late 19th century you start to see the wider use of octotonic which actually has 8 pitch classes (Scriabin, Debussy, Bartok, King Crimson, etc…), along with other non-*8 note" pitch collections like whole-tone. Then you have the blues and be-bop scales, which are still scales. Realize that the pentatonic you are likely talking about is one of many pentatonic variations -(Anche Hoye (Ethiopia), Hiraj?shi (Japan), etc…) -and is most certainly still a scale.

Good luck.

Yes the frets are no longer on the guitar, hence fretless. wow nice list of information there, I will have to go over it a couple times, as for scales, when I took my classical piano back in the day, If I never played the 8th note, which yes is the first note in the next octave, I would fail. I understand there are really only 7 notes and 13 in a chromatic scale. Good information you have supplied for me Thanks boselymusic.