Services
Spiderweb Phototransistor Teensy 2.0 Code#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE(); int const numTouchPins =11; // number of pins to use as touchpins, sending note values int touch[numTouchPins]; int touchon[numTouchPins]; int touchpin[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // which digital pins to use as touch pins //int channel[] = { 1,2,3,4,5,6,7,8,9,10,11 }; int touchpitch[] = { 10, 13, 1, 3, 6, 8, 15, 18, 20, 22, 34}; // which midi notes to send from the touch pins int touchThreshold[] = { 1, 1, 1, 1, 2, 1, 1, 1, 10, 1, 24 }; //which thresholds value for the touch pins int touchMax = 5000; // the MIDI channel number to send messages //const int channel = 1; const int velocity = 127; // Max velocity void setup() { MIDI.begin(MIDI_CHANNEL_OMNI); } void loop() { // touchpads int i = random(0, numTouchPins); touch[i] = analogRead(touchpin[i]); if (touch[i] > touchThreshold[i] && touchon[i] == 0) { usbMIDI.sendNoteOn(touchpitch[i], velocity, 1); MIDI.sendNoteOn(touchpitch[i], velocity, 1); delay(10); usbMIDI.sendNoteOff(touchpitch[i], velocity, 1); MIDI.sendNoteOff(touchpitch[i], velocity, 1); touchon[i] = 1; } if (touch[i] < touchThreshold[i] && touchon[i] == 1) { usbMIDI.sendNoteOff(touchpitch[i], velocity, 1); MIDI.sendNoteOff(touchpitch[i], velocity, 1); touchon[i] = 0; } // i think if you remove these last two lines everything breaks and things are sad and people cry while (usbMIDI.read()); // read and discard any incoming MIDI messages delay(10); } |
Servo Motor Codevoid setup() {
// put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly: analogWrite(9,200); } |