loading
Picture of Arduino compatible Luna Mod Looper
IMG_1026.JPG
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.

   
 
Remove these adsRemove these ads by Signing Up

Step 1: What you will need

Picture of What you will need
IMG_0990.JPG
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

Picture of the circuit
IMG_1028.JPG
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

Picture of Planning the enclosure
IMG_0986.JPG
IMG_0987.JPG
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

Picture of 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

Picture of 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

Picture of attach to headers
IMG_1017.JPG
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.
dsilva331 year ago

really cool project

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

This actually will play from 0-62 which is 63 notes. I could tell because I made a pseudo-funky-drumbeat with it with this sequence:

int steps[] = {300,100,100,100,500,100,100,100,
100,100,300,100,500,100,100,100,
300,100,300,100,500,100,100,100,
100,1500,100,100,500,100,100,100,
300,100,100,100,500,100,100,100,
100,100,300,100,500,100,100,100,
300,100,100,300,500,100,100,100,
100,1500,300,100,500,100,100,500};

So, to get it to play an even 64 notes, you can do <=63 or <64. I used this:

for (int i=0; i<64; i++)

And it works as it should. Nice 'ible though! Thanks for sharing this!  Remember seeing this Luna Mod and wanted to make it before, now that I have tons of spare parts lying around it is finally mine.  =D  Now to just make a step sequencer that will work with it.  Add a button to go into step mode, and a button to go inbetween the steps, then your momentary can play the current note, hmm, maybe I will work on this for fun today.
konstantino2 years ago
Also, I suspect the issue is rooted in the ATtiny45's clockspeed (1 MHz or 8 MHz vs. the Arduino's ATmega328 which runs at 16 MHz). If you could confirm any of this that would be great
Higgs Boson (author)  konstantino2 years ago
You do need to change the output/input pins in the code for the ATtiny. There are enough I/O pins, but you have to keep in mind that the pin number you see on the chip may not be the number you use to define in the code. Look up the data sheet or pinout diagram of the ATtiny to figure out which pins to use. As for the clock speed, I think it would ultimately be better to have a higher speed, but for the range of notes you would get out of this I don't think it would make too much of a difference.
konstantino2 years ago
Hi there, I'm rocking an ATtiny45 and everything seems to be working functionally. That said, the sound output doesn't sound *nearly* as good as yours -- it sounds more or less like a series of irritating ticks that I can speed up or slow down.

Do you think there are any changes made to the values in the code when using it for the ATtiny rather than the Arduino? I'm also using a 1/4" jack for audio output rather than 3.5mm if that makes any difference. Let me know if you have any thoughts1
yovelba2462 years ago
can you make new scheme about that project?
Because I did not understand the scheme.
thank you. (sorry about my english).
Higgs Boson (author)  yovelba2462 years ago
I'll try to draw one on eagle when I get the time.
agm882 years ago
this project honestly reminded me of skrillex in the video
I LOVE IT
Higgs Boson (author)  agm882 years ago
Thanks!
rarebeasts2 years ago
Awesome project. Thanks for sharing this with us!
Higgs Boson (author)  rarebeasts2 years ago
Thanks!
umfan1103 years ago
im new to the arduino i ordered one for fun and im really flusterd because i dont know the language i know html and thats about it i really want to add more effects synth but i do not know how to
Higgs Boson (author)  umfan1103 years ago
When I first started with arduino I got a book called Getting Started With Arduino. It is very beneficial to anyone getting started. You could also look for some online tutorials on instructables or arduino.cc. If you have the IDE and everything you could try changing some of the parameters on the example sketches to see what they do.
TobaTobias3 years ago
I dont understand pin 1,2,3. Whats N.L?
Higgs Boson (author)  TobaTobias3 years ago
Sorry my hand writing is not the best. It says N.C. meaning not connected, and pins 2 and 3 are connected to the wiper pin of the two pots.
robokid963 years ago
This is great!
one problem im having though. the led blinks regularly when the speaker is not plugged in, but when i plug the speaker in it starts spazzing out.
any idea why?
also just to be sure, when using an atmega 45 what pins should I define in the code?
Thanks!
Higgs Boson (author)  robokid963 years ago
I am not entirely sure why that would happen, but it would be very useful to know how your circuit is setup. If you could show a schematic or something that would be good.

When you say atmega 45 I assume you mean ATtiny45. For that you can use pretty much any pin you want for the different components just as long as the speaker is one of the pwm pins. I included a schematic showing which pins to use on step2. keep in mind that the pin numbers you define in the code are not the same pins you attach everything to. I attached the speaker to pin 0, the button to pin 1, the LED to pin 2 and the two pots to pins 3 and 4. define everything in the code using those pins, but look on the schematic for how to connect everything.
Oh right! That was it, I had the wrong pins defined.
Great project. When I saw the original LunaMod I hoped someone would do it with the arduino.
Thanks!
Higgs Boson (author)  robokid963 years ago
Yeah. That is one thing that is pretty confusing about the attiny. Other than that it is pretty easy to use.
gracesmith3 years ago
Good Idea!
Higgs Boson (author)  gracesmith3 years ago
Thanks!
TobaTobias3 years ago
Nice! Im using an 85, what pins are you using?
Higgs Boson (author)  TobaTobias3 years ago
For the ATtiny85, you would do everything the same as the 45. They are almost identical. Look at the schematic with the ATtiny45 for what pins you can use.
This is so good! Thank you for sharing!
Higgs Boson (author)  audreyobscura3 years ago
Thanks!