Go Down

Topic: Arduino Uno - as Microcontroller without computer possible? (Read 982 times) previous topic - next topic


May 04, 2012, 04:27 pm Last Edit: May 04, 2012, 04:36 pm by monoaural Reason: 1
Hello folks,
i have an idea and i´m not to sure if this is do-able without an computer.
I would like to use  a arduino uno behaving pretty much like an quad-theremin. The ideas is to have an plattform with four marked areas. Each of the four areas is connected to a corresponding loudpseaker. when approaching with the hand to one of the area, there should be simple tone/sound comming out of the corresponding speaker. the closer the hand reaches the actual area, the louder the sound comming from the loudspeakers should be.

two reason why not using a computer.
first. for asthetic reason. everything should be as minimalistic as possible.
second. i heard, that when doing a project like that, all cables can/will act as big antennas with weird sound results.

the patches will be written from a friend of use.
it will probably written in max/msp. but suggestions for any other programming languages are very welcome.
because we are using this installation for an exhibition, which will take place only once, we want to avoid to buy an license (300US $ as far as i heard)

would that be possible without using an computer?
woud it be possible in another language rather than max/msp

any help is highly appreciated!

Udo Klein


would that be possible without using an computer?



woud it be possible in another language rather than max/msp

Yes - what is max/msp anyway? Arduino is usually programmed in C.
Check out my experiments http://blog.blinkenlight.net


hi udo.

thanks a lot for this quick answer.

could you please be little more specific what exactly i would need and how this will work?


thanks in advance.

p.s. falls dir deutsch lieber ist, können wir auch ins deutsche forum übersiedeln.

beste grüße ais berlin

Udo Klein

It appears to me that Max/Msp is intended for "visual programming". Since I have no clue of this abstraction I can give you no hints at all. I can only tell that Arduino can do it if you understand how to code in C. The way you are asking indicates that you might face a steep learning curve.
Check out my experiments http://blog.blinkenlight.net


Have you put any thought into the design aspect yet?  There are several ways to sense proximity (light, ultrasonic, capacitance) with tons of examples of each in the Arduino playground, in the forums, and generally online.

If you're new to the Arduino, look through some of the simple Playground sketches to get an idea how it all works.  www.ladyada.net has some good tutorials too.

Well, there's this:  http://www.arduino.cc/playground/Interfacing/MaxMSP

The first thing to do is here search the web for "<whatever> Arduino".  Doing so for "Max/MSP Arduino" pulled up quite a list of hits.

Udo Klein

The playground example will need a computer. He was asking about a setup without a computer. I suspect that it will be possible but only WITHOUT MaxMSP. Most probably MaxMSP would need to much resources for an Arduino.
Check out my experiments http://blog.blinkenlight.net


you could use a 9v power adapter that fits in the black socket and plug it in the wall I do it all the time and it works perfectly because when I download the program to the arduino it saves it to the flash which is non-volatile meaning that it will be saved on the chip even after a power off and also here is some code I wrote a while ago that uses one wire for a therium like thing just one note: I have looked at what happens to a wire when you move your hand closer to a long wire and it looks like a square and when you move your hand closer the peak gets taller however my code just gets the median of a sample because I wrote this code before doing that and forgot to rewrite it.Also as you can tell by the program I did NOT write the median algorithm and also this contains alot of commented code but lacks of actual comments so sorry about that.
Code: [Select]

//1 wire insterment

*  This Quickselect routine is based on the algorithm described in
*  "Numerical recipes in C", Second Edition,
*  Cambridge University Press, 1992, Section 8.5, ISBN 0-521-43108-5
*  This code by Nicolas Devillard - 1998. Public domain.

#define ELEM_SWAP(a,b) { register unsigned int t=(a);(a)=(b);(b)=t; }

unsigned int quick_select(unsigned int arr[], int n)
    int low, high ;
    int median;
    int middle, ll, hh;

    low = 0 ; high = n-1 ; median = (low + high) / 2;
    for (;;) {
        if (high <= low) /* One element only */
            return arr[median] ;

        if (high == low + 1) {  /* Two elements only */
            if (arr[low] > arr[high])
                ELEM_SWAP(arr[low], arr[high]) ;
            return arr[median] ;

    /* Find median of low, middle and high items; swap into position low */
    middle = (low + high) / 2;
    if (arr[middle] > arr[high])    ELEM_SWAP(arr[middle], arr[high]) ;
    if (arr[low] > arr[high])       ELEM_SWAP(arr[low], arr[high]) ;
    if (arr[middle] > arr[low])     ELEM_SWAP(arr[middle], arr[low]) ;

    /* Swap low item (now in position middle) into position (low+1) */
    ELEM_SWAP(arr[middle], arr[low+1]) ;

    /* Nibble from each end towards middle, swapping items when stuck */
    ll = low + 1;
    hh = high;
    for (;;) {
        do ll++; while (arr[low] > arr[ll]) ;
        do hh--; while (arr[hh]  > arr[low]) ;

        if (hh < ll)

        ELEM_SWAP(arr[ll], arr[hh]) ;

    /* Swap middle item (in position low) back into correct position */
    ELEM_SWAP(arr[low], arr[hh]) ;

    /* Re-set active partition */
    if (hh <= median)
        low = ll;
        if (hh >= median)
        high = hh - 1;

#undef ELEM_SWAP
#define speaker 3
#define wire 0
//#define outlier_low 250
//#define outlier_high 800
#define sample_size 32
unsigned int sample_data[sample_size];
  unsigned int loop_avg;
    unsigned int pitch_temp;
//#define uled
//uled=using led
#define led_green 8
#define led_red 7
void setup()
  #ifdef uled
  pinMode(led_green, OUTPUT);
  pinMode(led_red, OUTPUT);

void loop()
  //get wire value
  unsigned int pitch;

  for (loop_avg=0;loop_avg <= sample_size ;loop_avg++)
    #ifdef uled
   digitalWrite(led_green, LOW);   // sets the LED off
   digitalWrite(led_red, LOW);   // sets the LED off
    #ifdef outlier_low
    if (pitch_temp < outlier_low)
      //Serial.println("pitch too low");
      #ifdef uled
      digitalWrite(led_green, HIGH);   // sets the LED on
     goto re_read2;
    #ifdef outlier_high
    if (pitch_temp > outlier_high)
       // Serial.println("pitch too high");
       #ifdef uled
       digitalWrite(led_red, HIGH);   // sets the LED on
    goto re_read2;
   // pitch=pitch_temp;
   // pitch/=2;
  //now sort array
   pitch=quick_select(sample_data, sample_size);

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131