Introduction: Arduino Compatible Luna Mod Looper

About: I'm Ben. I'm currently weaseling my way through undergrad at MIT where I'm majoring in physics and nuclear science and engineering. I made this account back in middle school (hence the cheesy name), and I real…
The Luna Mod Looper, basically lets you record a sequence using a potentiometer to control the pitch of the note, and then play it back and add affects. Ever since I saw videos of the Luna Mod being played, I wanted to build my own. However, the project required a picaxe microcontroller, which I have none of, and have no experience with. Fortunately, after a few web searches I came across some code for a Luna Mod for the attiny45 or the arduino. this project requires much less hardware than the original project, and allows you to add much more affects (although for this I chose to just keep it simple and add later) because the arduino still has a lot of unused pins, and a lot of room for more complex code. Along with being pretty easy to build, this is very fun to play with, and works very well.


Step 1: What You Will Need

You will need:
-an arduino uno / clone or an ATtiny 45 and a way to program it (i.e. a programming shield for the arduino)
-two pontentiometers (value does not really matter)
-a buttonswitch (the original project called for momentary but I used a push on push off switch so I wouldn't have to hold it)
-two LEDs and cases 
-resistors to go with the LEDs (i.e 220 ohm)
-spst toggle switch
-1/8" audio jack
-DC female power jack
-project box


Step 2: The Circuit

There is nothing special about this circuit. Using the ATtiny45 you would need to connect everything to the right pins, and connect the 7805 correctly, but if you are using the arduino you probably won't even need a board, sense all the components are for interface. I simply connected all my parts to header pins and attached the headers to the female headers on the arduino board, this way I could easily remove everything when I want to use my arduino for something else in the future. construction of the circuit should be pretty strait forward as you simple connect everything to the right pin, with no need of extra hardware.

on the arduino, the frequency pot goes to A0, the tempo pot goes to A1, the record button goes to pin 9, the tempo LED goes to pin 10 and the speaker goes to pin 11.

On the ATtiny 45, you will have to choose what pins everything will go to since the sketch is setup for the arduino and you will need to change the pins. be sure to put the speaker and button on either pins 0 or 1 (5 or 6 on the chip). 

If you use the arduino to do this, there are a ton of unused pins and plenty of space in the code for you to add your own personalized affects. Maybe add a glide button, or maybe even an LFO pot. There are practically no limits. Even with the ATtiny45 you could replace the tempo LED with a button/pot and add some extra affects.

Step 3: Program the Arduino

Copy paste the following code to your arduino IDE, compile and then uplode (If you are using the attiny you will need to change the pins that are used in the sketch).




/*
*
* LunaMod for Arduino & Attiny45
* Remix by Rob Miles
* Tacoma, WA August 8th 2011
*
* I saw the original project in Make vol. 26
* by Brian McNamara
* Brian's was running on a PicAxe and I only have attiny45s so.......
*
* The freqout section where the real magic happens is from Paul Badger's synth code on the main Arduino site
*
* I kept this pretty straight forward but with an Arduino this could get a lot more complicated if you like
* Even on an attiny45 if you use you add a button to the led pin you coud sneak in more effects
*
*/

#define frequencyPot   0                              //frequency pot tied to pin 15 which is A1
#define tempoPot       1                              //tempo pot tied to pin 16 which is A2
#define buttonPin      9                              //programming button tied to pin 17 which is A3
#define ledPin         10                             //status led tied to pin 18 which is A4
#define speakerPin     11                             //speaker or output pin 19 whish is A5
                                                      //if you use a speaker it should be at least a 16 ohm speaker an should have a
                                                      //resistor, maybe 200ohm to 1K ohm, between the negative lead and ground.
                                                      //a potentiometer would be even better.

int currentStep = 0;                                  //this is just to track which tone in memory we are currently playing

int steps[] = {500,500,100,100,100,100,100,100,                    // this is our tone storage areae
               100,100,100,100,100,100,100,100,                     //I used 64 tones or 8 tones per beat
               500,500,100,100,100,100,100,100,                     //you can change these manually and experiment if you like
               100,100,100,100,100,100,100,100,    
               500,500,100,100,100,100,100,100,
               100,100,100,100,100,100,100,100,
               500,500,100,100,100,100,100,100,
               100,100,100,100,100,100,100,100};

int tempo = 0;                                      //tempo or speed between tones
int duration = 0;                                   //how long each of the 64 tones plays
int frequency = 0;                                  //current tone
int pitchval = 1;

void setup()                                        //set up your pins....
{
  pinMode (frequencyPot, INPUT);
  pinMode (tempoPot, INPUT);
  pinMode (buttonPin, INPUT);
  digitalWrite(buttonPin, HIGH);

  pinMode (ledPin, OUTPUT);              
  pinMode (speakerPin, OUTPUT); 

}

void loop()
{


  for (int i=0; i<63; i++)                         //64 individual notes played
  {

  currentStep = i;                                 //save our current position in the loop for later

  if (i == 0 || i == 16 || i == 32 || i == 48){    //keep track of the beat on the led
  digitalWrite(ledPin, HIGH);}

  if (i == 7 || i == 23 || i == 39 || i == 55){    //keep track of the beat on the led
  digitalWrite(ledPin, LOW);}





  if (digitalRead(buttonPin) == LOW)               //is the program button being pressed
    {                                              //if so lets write a new tone the this location

    steps[currentStep] = (analogRead(frequencyPot));  //read the frequency pot and set the new tone
    freqout (steps[currentStep], duration);           //set the parameters for frequout below and play it
    freqout (steps[currentStep]+64, duration);       //play another tone a little bit different than the original to give
                                                      //it a little more depth. this can be changed to your liking
    freqout (steps[currentStep]+128, duration);       //play another tone a little bit different than the original to give
                                                      //it a little more depth. this can be changed to your liking

    }

    else {                                            //else play the tone

    freqout (steps[currentStep], duration);           //set the parameters for frequout below and play it
    freqout (steps[currentStep]+64, duration);       //play another tone a little bit different than the original to give
                                                      //it a little more depth. this can be changed to your liking
    freqout (steps[currentStep]+128, duration);       //play another tone a little bit different than the original to give
                                                      //it a little more depth. this can be changed to your liking


  }
    tempo = (analogRead(tempoPot)/4);                    //read the tempo pot
    duration = tempo/8;                                   //set the individual tone durations
    delay(tempo);                                         //wait a bit
}
}


void freqout(int freq, int t)
{
  int hperiod;   
  long cycles, i;

  hperiod = (500000 / ((freq - 7) * pitchval));            

  cycles = ((long)freq * (long)t) / 1000;   

  for (i=0; i<= cycles; i++)
  { 
    digitalWrite(speakerPin, HIGH); 
    delayMicroseconds(hperiod);
    digitalWrite(speakerPin, LOW); 
    delayMicroseconds(hperiod - 1);
  }
}

Step 4: Planning the Enclosure

In order to make this project easy to use, I decided to put it in a project box. You do not have to do this but it makes playing around with it and sharing it with others much easier. using some of the mounting hardware, try to plan where you want to put everything. I didn't want to mark up the box, so I put some masking tape over it and marked on it where I wanted to drill my holes.

Step 5: Drill

Now that you know where you want everything you can drill the holes where you want everything. you will need to find drill bits that are the appropriate size for each of your parts. If you are not sure which size to use, start smaller. It is better for your hole to be too small and you have to widen it than for it to be too big and you end up with a big hole in your box you can't mount anything in.

Step 6: Mount the Parts

Peal off the tape, and begin to mount the parts. this is pretty straight forward. remove the nuts and washers from your switches, pots LEDs and so on, stick the part through the hole, and then put the washers back on and tighten the nuts with some pliers or a socket wrench. Screw on some knobs to the pots with a small flat head screw driver to make them easier to control.

Step 7: Attach to Headers

Solder wires to all of the terminals on the parts, and connect them to the appropriate header pins to go to the pins on the arduino.
connect your header pins to the arduino, and seal up your box. I added some rubber feet so it wouldn't slide around when I was playing it but you do not have to do this. 

Step 8: Finished

Once your box is sealed, plug in a wall wart between 6 and 12 volts to the DC power jack, plug in your speakers to the audio jack, flip the switch and have fun!

If you have any problems leave a comment or message me and I will do my best to help you.