kramann.info
© Guido Kramann

Login: Passwort:










kramann.info
© Guido Kramann

Login: Passwort:




Beispiele zur Verwendung verschiedener Sensoren mit einem Arduino-Micro

(EN google-translate)

(PL google-translate)

Simple scheme for an interactive installation.

Bild 0-1: Simple scheme for an interactive installation.

Durch die Verwendung von Sensoren kann eine langweilige Sache plötzlich sehr interessant werden. Jetzt ist der Mensch nicht mehr nur passiver Betrachter, sondern kann selber in die Installation eingreifen. Wir betreten das Gebiet der Mensch - Maschine - Schnittstellen. Hier ist ein Beispiel, bei man selber spielerisch komponieren kann:

http://www.kramann.info/___downloads/kiba_komponieren_mit_cpe_bach.ogg

Im folgenden werden kleine Sensor - Aktuator - Varianten auf der Basis des Arduino Micro vorgestellt. Hierbei werden auch die im vorangehenden Kapitel aufgezeigten Ideen für die Klangerzeugung aufgegriffen.

Sound Installation 1

Diese Klanginstallation imitiert den Rhythmus vom Händeklatschen Man klatscht während die LED leuchtet. Der Rhythmus wird wiederholt während die LED aus ist.

sheme of sound installation 1

Bild 0-2: sheme of sound installation 1

foto of sound installation 1

Bild 0-3: foto of sound installation 1

#define MEMORY 1000

int mic = 0;
bool REC = false;
unsigned long time=0;
bool arr[MEMORY];
int i=0;
void setup() 
{
    pinMode(12,OUTPUT);
    for(i=0;i<MEMORY;i++)
        arr[i]=false;
}


void loop() 
{
    time = millis()%(2*MEMORY);

    if(time<MEMORY)
    {
        digitalWrite(12,HIGH);
        mic = analogRead(0);
        if(mic<50)
           arr[time]=true;
    }
    else
    {
        digitalWrite(12,LOW);
        if(arr[time-MEMORY]==true)
        {
           arr[time-MEMORY]=false;
           tone(13,440,20);
        }   
    }
    delay(1);          
}

Code 0-1: sound_installation_01

sound_installation_01.zip

Sound Installation 2

Eine Rassel wird abhängig von den Werten eines Abstandssensors schneller oder langsamer geschüttelt.

sheme of sound installation 1

Bild 0-4: sheme of sound installation 1

foto of sound installation 1

Bild 0-5: foto of sound installation 1


//See also: File ... Examples ... Servo
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
int sensor=0;
int inkrement = 1;
int angle = 0;
int direction = 1;
void setup() 
{
  myservo.attach(13);  // attaches the servo on pin 13 to the servo object
  Serial.begin(9600);
}


void loop() 
{
     sensor = analogRead(0);

     inkrement = sensor/5;
     if(inkrement>180)
         inkrement=180;
     if(inkrement<5)
         inkrement=0;

     angle+=direction*inkrement;
     if(angle>=180)    
     {
         direction=-1;         
     }
     if(angle<=0)    
     {
         direction=1;         
     }

     myservo.write(angle);

     delay(60);
}

Code 0-2: sound_installation_02

sound_installation_02.zip

Sound Installation 3

Ein Sensor vom Typ MPU6050 wird verwendet, um die zwei orthogonalen Richtungen die Beschleunigung zu messen. Der erste Wert steuert den Grad an Chaos in einer Chaos-Funktion. Der andere Wert kontrolliert die Geschwindigkeit der Tonabfolge, die mit den Chaoswerten gespielt wird.

sheme of sound installation 1

Bild 0-6: sheme of sound installation 1

foto of sound installation 1

Bild 0-7: foto of sound installation 1

//Mittelwert omega=0.0348
//0.0485
//-0.0063

#include<math.h>
#include<Wire.h>

#define GYROSCALE 131.0
#define GYROOFFSET 2.71 //korrigierter Gyrooffset

//4.294.967.295  unsigned long
//    1.000.000  == 1s
//4.000.000.000  == 4000s
//1s == 1000ms == 1.000.000us


const int MPU=0x68;  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ;

double ax,ay,az;

double stellgroesse;
double m=0.0;

bool SERIELL = false;

//CHAOS FUNCTION

double y_old = 0.56;
double y_new = 0.0;
int value=0;
int i;
double r=3.5;

void setup() 
{  
  // put your setup code here, to run once:
  Wire.begin();
  Wire.beginTransmission(MPU);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);

  if(SERIAL==true)
      Serial.begin(9600);

}

void loop() 
{
  // put your main code here, to run repeatedly:
  Wire.beginTransmission(MPU);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU,6,true);  // request a total of 14 registers
  AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)     
  AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  
  ax = (double)AcX;
  ay = (double)AcY;
  az = (double)AcZ;

  if(ax>15000.0)   //limitate
      ax=15000.0;
  if(ax<-15000.0)
      ax=-15000.0;

  if(ay>15000.0)  //scale
      ay=15000.0;
  if(ay<-15000.0)
      ay=-15000.0;

  ax+=15000.0;
  ay+=15000.0;

  ax/=30000.0;  //scale to [0,1]
  ay/=30000.0;

  r = 3.0 + ax;

  y_new = r*y_old*(1.0 - y_old);

  value = (int)(100.0*y_new);

  y_old = y_new;


  tone(13, 200 + 2*value);
  
  delay(10 + (int)(100.0*ay));

  if(SERIELL)
  {
      Serial.print(" arx = "); 
      Serial.print(ax,DEC);
      Serial.print(" ary = "); 
      Serial.println(ay,DEC);
      delay(333);
  }
}

Code 0-3: sound_installation_03

sound_installation_03.zip

Sound Installation 4

Indem ein digitaler Eingang ohne pull up Widerstand konfiguriert wird, entsteht ein sehr empflindlicher Eingang. Die Anzahl der Einser über ein festes Zeitintervall wird gezählt und als Grundlage für die Tonhöhe verwendet.

sheme of sound installation 4

Bild 0-8: sheme of sound installation 4

foto of sound installation 4

Bild 0-9: foto of sound installation 4


bool SERIELL = false;
int x=0;
int y=0;

void setup() 
{  
    DDRB &= 0b01111111;
    PORTB &= 0b01111111;

    if(SERIELL==true)
        Serial.begin(9600);
}

void loop() 
{
    if(y<1000)
    {
        if( (PINB & 0b10000000) == 0 )
        {
            x++;
        }
    }
    else
    {
        y=0;

        if(SERIELL==true)
           Serial.println(x);
        x=0;
    }
    y++;

    tone(13,x);

    if(SERIELL==true)
       delay(1);
}

Code 0-4: sound_installation_04

sound_installation_04.zip

Verwendung besonderer Mittel für die Datenverarbeitung

Aber nicht nur auf Seiten von Sensor und Aktuator kann man über Alternativen nachdenken. Es existieren auch Beispiele dafür, wo zur Datenverarbeitung statt eines Computers etwas anderes verwendet wurde:

Eduardo Miranda, Peninsula Arts Contemporary Music Festival Biocomputer
Guy Plays Piano With His Brain
Physarum Music