Rebuilding for teensy - unfinished

This commit is contained in:
Lukas Bachschwell 2016-07-15 13:37:39 +02:00
parent f95db9c535
commit 8307efce95

View File

@ -1,8 +1,24 @@
#include <Adafruit_NeoPixel.h>
#include <MIDI.h>
// Currently always asume with 2 pedals
//8 LEDs and Pin is 11
Adafruit_NeoPixel leds = Adafruit_NeoPixel(8, 11, NEO_GRB + NEO_KHZ800);
bool oldValues[9] = {
1, 1, 1, 1, 1, 1, 1, 1, 1};
bool oldValues[8] = {
1, 1, 1, 1, 1, 1, 1, 1
};
//byte counter;
byte CLOCK = 248;
byte START = 250;
byte CONTINUE = 251;
byte STOP = 252;
uint8_t pins[8] = {
17, 16, 15, 14, 2, 4, 3, 5
};
int tempState = 1;
int time = 0;
int bar = 1;
@ -51,40 +67,55 @@ void stopClock()
digitalWrite(12, LOW);
}
void setup() {
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
MIDI.begin(MIDI_CHANNEL_OMNI);
MIDI.setHandleClock(tick);
MIDI.setHandleStart(goClock);
// MIDI.setHandleContinue(goClock);
MIDI.setHandleStop(stopClock);
void RealTimeSystem(byte realtimebyte) {
if (realtimebyte == 248) {
tick();
}
if (realtimebyte == START || realtimebyte == CONTINUE) {
goClock();
}
if (realtimebyte == STOP) {
stopClock();
}
}
void setup() {
for (int i = 0; i < 8; i++) {
pinMode(pins[i], INPUT_PULLUP);
}
pinMode(13, OUTPUT); //LED
//MIDI.begin(MIDI_CHANNEL_OMNI);
// MIDI.setHandleClock(tick);
//MIDI.setHandleStart(goClock);
// // MIDI.setHandleContinue(goClock);
//MIDI.setHandleStop(stopClock);
//Modeled
digitalWrite(11,HIGH);
// digitalWrite(11,HIGH);
usbMIDI.setHandleRealTimeSystem(RealTimeSystem);
leds.begin();
leds.show();
}
void loop() {
MIDI.read();
usbMIDI.read();
for (int i = 0; i < 8; i++) {
//Ned ganz
tempState = digitalRead(pins[i]);
for(int i = 2; i <= 10; i++) {
tempState = digitalRead(i);
if (tempState != oldValues[i - 2])
{
// debouncetime
delay(1);
tempState = digitalRead(i);
tempState = digitalRead(pins[i]);
if (tempState != oldValues[i - 2]) {
/* if(i == 10)
@ -120,10 +151,11 @@ void loop() {
}
else
{*/
if(tempState == 0)
MIDI.sendNoteOn(i, 127, 1);
else
MIDI.sendNoteOff(i, 0, 1);
if (tempState == 0) {
usbMIDI.sendNoteOn(i, 127, 1);
} else {
usbMIDI.sendNoteOff(i, 0, 1);
}
// }
}