Loading...
  Show Posts
Pages: [1] 2 3 ... 6
1  International / Deutsch / arduino zum simulieren von PC Tastaturtasten on: December 05, 2012, 04:16:54 am
Hallo,

kann ich mit dem Arduino bestimmte Tasten wie 1,2,3,4 einer PC Tastatur simulieren.

Es geht darum ein kleines Interface für reaktionstests zu basteln, der Nutzer soll zu einem bestimmten Zeitpunkt eine bestimmte Taste drücken.

Würde ich den normal USB Port des arduino dafür nutzen können?


vielen Dank

rupi
2  Using Arduino / Audio / Re: quantizing midi notes on: January 12, 2012, 01:17:08 am
Well,
i ment i updated the above post with more comments, but here we go again:


i read a value from a potentiometer, put the value into an array " AnalogValue[stepnr] ", divide that by 8 and
put it into another array "note[stepnr]", which represents the note to be played(this one I want to quantize),
than i simply sent that note to the serial port, which is connected to midi, the noteOn function i posted below.


Code:
void playstep(int stepnr) {
  
  if (currentSwitchState[stepnr] == 1) {
    
//this reads a potentiometer and defines the pitch of the note to be played
    AnalogValue[stepnr] = analogRead(stepnr);
    note[stepnr] = AnalogValue[stepnr]/8 ;
//this is optional if the played note should be turned of on the next step
     holdState = digitalRead(holdPin);
    if (holdState == 1) {
         noteOn(0xB0, 0x7B, 0x00);  // all notes off    
    }  
//this plays the actuall note, first midi than analog
    noteOn(0x90, note[stepnr], 0x7F); // play note
    write_value(AnalogValue[stepnr] * 4);
//this blinks the LED when the current step is played    
    for (int i=0; i<=15; i++) {
      digitalWrite(LEDpins[i], i==stepnr);
    }
  }
}

Code:
void noteOn(byte cmd, byte data1, byte  data2) {
  Serial.print(cmd, BYTE);
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
}
3  Using Arduino / Audio / Re: quantizing midi notes on: January 11, 2012, 03:16:05 am
I did write some comments to the code, hope thats enough.
With quantizing the pitch I mean that the played note matches a note from the scale or a chord,
thats how I understand quantizing.

this is the wikipedia article on quantizing:
http://en.wikipedia.org/wiki/Quantization_%28music%29
4  Using Arduino / Audio / Re: quantizing midi notes on: January 10, 2012, 09:34:08 am
Hello,

this time i would like to quantize the note/pitch/frequency,
the sequencer runs to an external clock, so quantizing the time would not be neccesary., i think.

cheers
5  Using Arduino / Audio / quantizing midi notes on: January 10, 2012, 03:07:19 am
Hello,

is it possible to quantize the midi notes send by a arduino sequencer?
Right now I only take the analogvalue and send that to the midi device:

Code:
void playstep(int stepnr) {
  
  if (currentSwitchState[stepnr] == 1) {
    
//this reads a potentiometer and defines the pitch of the note to be played
    AnalogValue[stepnr] = analogRead(stepnr);
    note[stepnr] = AnalogValue[stepnr]/8 ;
//this is optional if the played note should be turned of on the next step
     holdState = digitalRead(holdPin);
    if (holdState == 1) {
         noteOn(0xB0, 0x7B, 0x00);  // all notes off    
    }  
//this plays the actuall note, first midi than analog
    noteOn(0x90, note[stepnr], 0x7F); // play note
    write_value(AnalogValue[stepnr] * 4);
//this blinks the LED when the current step is played    
    for (int i=0; i<=15; i++) {
      digitalWrite(LEDpins[i], i==stepnr);
    }
  }
}
6  Using Arduino / Audio / Re: midi in debugging on: January 09, 2012, 04:47:50 am
ok, i got a signal now and the sequencer runs according to the sequencer, but its far to fast, how can and have I to devide the incoming signal?

Code:
if(Serial.available() > 0) {
  data = Serial.read();
  if(data == midi_start) {
    play_flag = 1;
  }
  else if(data == midi_continue) {
    play_flag = 1;
  }
  else if(data == midi_stop) {
    play_flag = 0;
  }
  else if((data == midi_clock) && (play_flag == 1)) {
  //
//here are my steps...

EDIT:

when I only do every 4 ticks something the timing seems right:

Code:
if(counter < 5) {
  counter++;
  } else {
  counter = 0; 
  currentSwitchState[step] = digitalRead(switchPins[step]);
7  Using Arduino / Audio / midi in debugging on: January 07, 2012, 03:50:32 am
HEllo,
im creating a midi in circuit for my sequencer, the question ist
how can I check if my circuit is right and the code also.
I use this circuit adn the code below:
http://www.instructables.com/file/FUJ0J5BFPBKZZB1/

The arduino is a mega and the midi in ist connected to RX0.

Code:
byte midi_start = 0xfa;
byte midi_stop = 0xfc;
byte midi_clock = 0xf8;
byte midi_continue = 0xfb;
int play_flag = 0;
byte data;
//midi in end

void setup() {
  //  set the states of the I/O pins:
  for (int x = 0;x<16;x++) {
    pinMode(LEDpins[x], OUTPUT);
    pinMode(switchPins[x], INPUT);
  }
                   
  pinMode(timePin1, INPUT);
  pinMode(timePin2, INPUT);
  pinMode(playPin, INPUT);
   pinMode(holdPin, INPUT);
    pinMode(dualPin, INPUT);
    pinMode(midiin, INPUT);
  //  Set MIDI baud rate:
  Serial.begin(31250);
  Serial1.begin(31250);
  // turn all notes off
  noteOn(0xB00, 0x7B, 0x00);
  noteOn(0xB01, 0x7B, 0x00);
  noteOn(0xB02, 0x7B, 0x00);
  noteOn(0xB03, 0x7B, 0x00);
  noteOn(0xB04, 0x7B, 0x00);
  noteOn(0xB05, 0x7B, 0x00);
  noteOn(0xB06, 0x7B, 0x00);
  noteOn(0xB07, 0x7B, 0x00);
  blink(3);
  timer_start = millis();
  //------------------------------
  // Control Voltage Section start
  byte clr;
  pinMode(DATAOUT, OUTPUT);
  pinMode(DATAIN, INPUT);
  pinMode(SPICLOCK,OUTPUT);
  pinMode(SLAVESELECT,OUTPUT);
  digitalWrite(SLAVESELECT,HIGH); //disable device
 
  SPCR = (1<<SPE)|(1<<MSTR);
  //SPCR = B01010000;
  clr=SPSR;
  clr=SPDR;
  delay(10);
  // Control Voltage Section end
  //------------------------------
  //---analog read timing
  sbi(ADCSRA,ADPS2) ;
  cbi(ADCSRA,ADPS1) ;
  sbi(ADCSRA,ADPS0) ;
  //-----------------------------
}

void loop() {

 
 
//Main sequence
 
//begin midi in here
if(Serial.available() > 0) {
  data = Serial.read();
  if(data == midi_start) {
    play_flag = 1;
  }
  else if(data == midi_continue) {
    play_flag = 1;
  }
  else if(data == midi_stop) {
    play_flag = 0;
  }
  else if((data == midi_clock) && (play_flag == 1)) {
  //
  currentSwitchState[step] = digitalRead(switchPins[step]);

     //mopdes are:
     // normal sequencer
     
     modeState = digitalRead(modePin);
     
     if (modeState == 0) {
   
       
        dualState = digitalRead(dualPin);
        if (dualState == 1) {
           currentSwitchState[step] = digitalRead(switchPins[step]);
           playstep1(step, 8, 0);
           if (step < 8) {
              step++;
           } else {
              step = 0;
           }
           currentSwitchState[step2] = digitalRead(switchPins[step2]);
           playstep2(step2, 15, 8);
            if (step2 < 15) {
              step2++;
           } else {
              step2 = 8;
           }
        } else {
           playstep(step);
           if (step < 15) {
              step++;
           } else {
              step = 0;
        }
        }
     } else {
       loopstep(step);
        if (step < 8) {
        step++;
      } else {
        step = 0;
      }
     }

    }
  //else { blink(1); }
   //
   
    }

   

}
8  International / Deutsch / Bastler im Raum Göttingen on: January 06, 2012, 11:18:32 am
Hallo,

gibs in Göttingen eine Arduino User Group oder ähnliches,
 habe ein Midi Projekt relativ weit gebracht, jetzt fehlt mir noch die Midi In Schaltung an
der ich auf dem Steckbrett verzweifele und eine Schaltung per Netz zu debuggen stell ich mir schwer vor.
Daher die Frage nach Leuten in Göttingen die ein wenig freie Zeit zu opfern hätten.

Dank und Gruß
9  Using Arduino / Audio / mcp4921 crashing arduino on: December 09, 2011, 12:19:41 am
Hello,

i created a CV output for my midi sequencer.
I get the wanted Voltage on Pin8 of the mcp4921.
I connected pin8 to the tip and the arduino GND to the ring.

When I now connect the mcp4921 to my synth the arduino crashes.

When I remove GND from the plug it works like it should be, is it 100% neccesary to
connect the GND and why does it crash?


thnx


EDIT:
i had to put a 220Ohm Resistor between ground and plug, than it works fine.
10  Using Arduino / Audio / Re: Analog CV output? on: November 11, 2011, 09:15:20 am
mmh, i dont really got your answer, i would like to send a CV, which is usually a current from 0-8V if i remeber correct to be sent instead
of this midi playnote: 

 noteOn(channel2[stepnr], note[stepnr], 0x7F);  //play note+

how would i line for CV out look?


Im not really into the whole IC/electrical stuff, do
you mean that when I connect a lowpasss filter i can adjust the voltage?
11  Using Arduino / Audio / Analog CV output? on: November 11, 2011, 04:44:06 am
Hello,

can I use the Arduino to output control voltage that is used in modular synthesizers?
I created a analog style Midi sequencer and would like to add CV output, i still have some PWM Ports free on my Arduinio Mega.


thnx a lot
12  Using Arduino / Audio / Re: converting standalone midi sequencer to midi in on: October 02, 2011, 03:08:36 am
Do I have to declare the Serial In port somewhere?
I only have the Serial.beginn().
13  Using Arduino / Audio / Re: control voltage sequencer on: September 30, 2011, 03:09:24 pm
nice,
do you need any extra equipment to generate CV with the arduino?
14  Using Arduino / Audio / Re: converting standalone midi sequencer to midi in on: September 29, 2011, 10:13:08 am
Ah ic, i thought something like that, I have to add a switch to my curccuit as well.
I also forgot the picture, i did talk to someone here about that drawing, so I gues my code is somewhere wrong
15  Using Arduino / Audio / converting standalone midi sequencer to midi in on: September 29, 2011, 03:28:10 am
Hello,

i have a midi sequencer which used an "internal clock", now i want to sync this to my other midi sequencer.
I followd this guide http://little-scale.blogspot.com/2008/05/how-to-deal-with-midi-clock-signals-in.html.
And I used the attached curcuit to create the midi in port.

Right now the sequencer does not start, im not even shure if I can just exchange my  "timing IF" with the
code from the example. Please have a look and maybe you have an idea

Code:
int switchPins[] = {38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53};
int LEDpins[] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37};
int currentSwitchState[] = {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0};
int currentSwitchState2[] = {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0};
byte channel[] = {0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7};
byte channel2[] = {0x90, 0x91, 0xB92, 0x93, 0x94, 0x95, 0x96, 0x97};
byte note[] = {0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A};
int volume[] = {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0};
int loopnr = 0;
int AnalogValue[] = {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0};
int lastNotePlayed[] = {0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0};    
int lastSwitchState[] ={0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0};


const int timePin1 = 9;  
const int timePin2 = 10;
const int playPin = 8;
const int modePin = 11;
const int dualPin = 13;
const int holdPin = 12;

const int middleC = 60;    // Middle C (MIDI note value 60) is the lowest note we'll play

byte kanal = 0xB1;

int currentTimeState = 0;
int currentTimeStateDown = 0;


int playState = 0;
int modeState = 0;
int holdState = 0;
int dualState = 0;
int dualnr = 0;
int lastplayState = 0;
int playing = 0;

int aktiv = 0;
int buttonCounter = 0;
int delaypause = 1000;
unsigned long timercount = 0;
unsigned long timer_start = 0;
unsigned long wartezeit = 5000; //1000ms = 1 sekunde
unsigned long currentTime = 250;
unsigned long Timer = 0;
int step = 0;
int step2 = 8;
int startdual = 0;
boolean button_up = true;
boolean button_down = true;

//midi in settings
byte midi_start = 0xfa;
byte midi_stop = 0xfc;
byte midi_clock = 0xf8;
byte midi_continue = 0xfb;
int play_flag = 0;
byte data;


void setup() {
  //  set the states of the I/O pins:
  for (int x = 0;x<16;x++) {
    pinMode(LEDpins[x], OUTPUT);
    pinMode(switchPins[x], INPUT);
  }
                    
  pinMode(timePin1, INPUT);
  pinMode(timePin2, INPUT);
  pinMode(playPin, INPUT);
   pinMode(holdPin, INPUT);
    pinMode(dualPin, INPUT);
  //  Set MIDI baud rate:
  Serial.begin(31250);
  // turn all notes off
  noteOn(0xB00, 0x7B, 0x00);
  noteOn(0xB01, 0x7B, 0x00);
  noteOn(0xB02, 0x7B, 0x00);
  noteOn(0xB03, 0x7B, 0x00);
  noteOn(0xB04, 0x7B, 0x00);
  noteOn(0xB05, 0x7B, 0x00);
  noteOn(0xB06, 0x7B, 0x00);
  noteOn(0xB07, 0x7B, 0x00);
  blink(3);
  timer_start = millis();
}

void loop() {

//timing settings  begin
  if (digitalRead(timePin1)== HIGH) {
    if (button_up == true) {
      currentTimeState = digitalRead(timePin1);
      if (currentTimeState == 1) {
        currentTime = currentTime + 5;
      }
    }
    button_up = false;
} else {
button_up = true; // wenn digitalRead nicht LOW war
}

  if (digitalRead(timePin2)== HIGH) {
    if (button_down == true) {
      currentTimeStateDown = digitalRead(timePin2);
      if (currentTimeStateDown == 1) {      
        if (currentTime <= 10) {
          currentTime = 10;
        } else {    
          currentTime = currentTime - 5;
        }
      }
   }
   button_down = false;
} else {
button_down = true; // wenn digitalRead nicht LOW war
}
//timing settings end

      
//play button action
  playState = digitalRead(playPin);
  
  if (playState != lastplayState) {
    
    // change the state of the led when someone pressed the button
    if (playState == 1) {
      if(playing==1) {
        playing=0;
        noteOn(0xB0, 0x78, 0x00);
      } else {
        playing=1;        
      }
    }
    // remember the current state of the button
    lastplayState = playState;
  }

 //midi in stuff

if(Serial.available() > 0) {
  data = Serial.read();
  
  if(data == midi_start) {
    play_flag = 1;
  }
  else if(data == midi_continue) {
    play_flag = 1;
  }
  else if(data == midi_stop) {
    play_flag = 0;
  }
  else if((data == midi_clock) && (play_flag == 1)) {
  //  Sync();
//  }
  
//}
//midi in end

 
//Main sequence. old standalone sequencer
//  if (playing == 1) {
//begin midi in here
//    if ((millis() - Timer) > currentTime) {

      Timer = millis();
      currentSwitchState[step] = digitalRead(switchPins[step]);

     //mopdes are:
     // normal sequencer
     // loopmode, 8 droneloops, upper row is pitch, lower row volume
     modeState = digitalRead(modePin);
    
     if (modeState == 0) {
    
        
        dualState = digitalRead(dualPin);
        if (dualState == 1) {
           currentSwitchState[step] = digitalRead(switchPins[step]);
           playstep2(step, 8, 0);
           if (step < 8) {
              step++;
           } else {
              step = 0;
           }
           currentSwitchState[step2] = digitalRead(switchPins[step2]);
           playstep2(step2, 15, 8);
            if (step2 < 15) {
              step2++;
           } else {
              step2 = 8;
           }
        } else {
           playstep(step);
           if (step < 15) {
              step++;
           } else {
              step = 0;
        }
        }
     } else {
       loopstep(step);
        if (step < 8) {
        step++;
      } else {
        step = 0;
      }
     }

//    }
//}  
//midi in if
}
  
}
//midi in end    

}

//****************************************************************
//****************************************************************
// Functions
//****************************************************************
//****************************************************************


void noteOn(byte cmd, byte data1, byte  data2) {
  Serial.print(cmd, BYTE);
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
}

// Blinks an LED 3 times
void blink(int howManyTimes){
  int i;
  for (i=0; i< howManyTimes; i++) {
    digitalWrite(LEDpins[0], HIGH);
    digitalWrite(LEDpins[8], HIGH);
    delay(100);
    digitalWrite(LEDpins[0], LOW);
    digitalWrite(LEDpins[8], LOW);
    delay(100);
  }
  for (int i=0; i<16; i++) {
      digitalWrite(LEDpins[i], HIGH);
    }
    delay(1500);
      for (int i=0; i<16; i++) {
      digitalWrite(LEDpins[i], LOW);
    }
}


void playstep(int stepnr) {
  
  if (currentSwitchState[stepnr] == 1) {
    
    AnalogValue[stepnr] = analogRead(stepnr);
    note[stepnr] = AnalogValue[stepnr]/8 ;
     holdState = digitalRead(holdPin);
    if (holdState == 1) {
         noteOn(0xB0, 0x7B, 0x00);  // all notes off    
    }  
    noteOn(0x90, note[stepnr], 0x7F); // play note

    for (int i=0; i<=15; i++) {
      digitalWrite(LEDpins[i], i==stepnr);
    }
  }
}

void loopstep(int stepnr) {
 
//unfinished
}

void playstep2(int stepnr, int dualnr, int startdual) {
  

  if (currentSwitchState[stepnr] == 1) {
    
    AnalogValue[stepnr] = analogRead(stepnr);
    note[stepnr] = AnalogValue[stepnr]/8 ;
     holdState = digitalRead(holdPin);
    if (holdState == 1) {
         noteOn(0xB0, 0x7B, 0x00);  // all notes off    
    }  
    noteOn(0x90, note[stepnr], 0x7F); // play note

    for (int i=startdual; i<=dualnr; i++) {
      digitalWrite(LEDpins[i], i==stepnr);
    }
  }
}

when I connect the midi In i cant upload any more sketches, does that mean my curciut is wrong?

thnx
Pages: [1] 2 3 ... 6