Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // this constant won't change:
- const byte buttonPin[30] = {
- 7,8,9,10,11,12,7,8,9,10,11,12,7,8,9,10,11,12,7,8,9,10,11,12,7,8,9,10,11,12};
- const byte Power [5] = {
- 2,3,4,5,6};
- // Variables will change:
- byte buttonPushCounter[30] = {
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // counter for the number of button presses
- byte buttonState[30] = {
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // Currentrent state of the button
- byte lastButtonState[30] = {
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // previous state of the button
- int analogValue1 = 0; // value read from the pot;
- const byte numReadings = 50;
- int inputPin = A0;
- byte oldBellowPressurePush = 0;
- int BellowPressurePush = 0;
- int BellowPressurePull = 0;
- byte Old = 0;
- byte Current = 0;
- byte readings[numReadings]; // the readings from the analog input
- byte index = 0; // the index of the Currentrent reading
- int total = 0; // the running total
- int average = 0; // the average
- void setup() {
- // initialize the button pin as a input:
- pinMode(buttonPin[0], INPUT);
- pinMode(buttonPin[1], INPUT);
- pinMode(buttonPin[2], INPUT);
- pinMode(buttonPin[3], INPUT);
- pinMode(buttonPin[4], INPUT);
- pinMode(buttonPin[5], INPUT);
- pinMode(Power[0], OUTPUT);
- pinMode(Power[1], OUTPUT);
- pinMode(Power[2], OUTPUT);
- pinMode(Power[3], OUTPUT);
- pinMode(Power[4], OUTPUT);
- // initialize serial communication:
- Serial.begin(31250);
- }
- void loop() {
- total= total - readings[index]; // subtract the last reading:
- readings[index] = analogRead(inputPin); // read from the sensor:
- total= total + readings[index]; // add the reading to the total:
- index = index + 1; // advance to the next position in the array:
- if (index >= numReadings) // if we're at the end of the array...
- index = 0; // ...wrap around to the beginning:
- average = total / numReadings; // calculate the average and send it to the computer as ASCII digits
- Current = total / numReadings;
- BellowPressurePush = 120;
- BellowPressurePull = 120;
- delay(10);
- // read the pushbutton input pin:
- buttonState[0] = digitalRead(buttonPin[0]);
- buttonState[1] = digitalRead(buttonPin[1]);
- buttonState[2] = digitalRead(buttonPin[2]);
- buttonState[3] = digitalRead(buttonPin[3]);
- buttonState[4] = digitalRead(buttonPin[4]);
- buttonState[5] = digitalRead(buttonPin[5]);
- digitalWrite (Power[0], HIGH);
- digitalWrite (Power[1], LOW);
- digitalWrite (Power[2], LOW);
- digitalWrite (Power[3], LOW);
- digitalWrite (Power[4], LOW);
- // compare the buttonState to its previous state
- if (buttonState[0] != lastButtonState[0]) {
- // if the state has changed, increment the counter
- if (buttonState[0] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 45, BellowPressurePull); //A
- SendMidi (0x80, 42, BellowPressurePush); //Fsharp
- }
- if (Current >= Old){
- SendMidi (0x80, 45, BellowPressurePull); //A
- SendMidi (0x90, 42, BellowPressurePush); //Fsharp
- }
- }
- if (buttonState[0] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 45, BellowPressurePush); //A
- SendMidi (0x80, 42, BellowPressurePush); //Fsharp
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[0] = buttonState[0];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[1] != lastButtonState[1]) {
- // if the state has changed, increment the counter
- if (buttonState[1] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 49, BellowPressurePull); //Csharp
- SendMidi (0x80, 45, BellowPressurePush); //A
- }
- if (Current >= Old){
- SendMidi (0x80, 49, BellowPressurePull); //Csharp
- SendMidi (0x90, 45, BellowPressurePush); //A
- }
- }
- if (buttonState[1] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 49, BellowPressurePush); //Csharp
- SendMidi (0x80, 45, BellowPressurePush); //A
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[1] = buttonState[1];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[2] != lastButtonState[2]) {
- // if the state has changed, increment the counter
- if (buttonState[2] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 52, BellowPressurePull); //E
- SendMidi (0x80, 50, BellowPressurePush); //D
- }
- if (Current >= Old){
- SendMidi (0x80, 52, BellowPressurePull); //E
- SendMidi (0x90, 50, BellowPressurePush); //D
- }
- }
- if (buttonState[2] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 52, BellowPressurePush); //E
- SendMidi (0x80, 50, BellowPressurePush); //D
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[2] = buttonState[2];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[3] != lastButtonState[3]) {
- // if the state has changed, increment the counter
- if (buttonState[3] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 55, BellowPressurePull); //G
- SendMidi (0x80, 54, BellowPressurePush); //Fsharp
- }
- if (Current >= Old){
- SendMidi (0x80, 55, BellowPressurePull); //G
- SendMidi (0x90, 54, BellowPressurePush); //Fsharp
- }
- }
- if (buttonState[3] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 55, BellowPressurePush); //G
- SendMidi (0x80, 54, BellowPressurePush); //Fsharp
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[3] = buttonState[3];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[4] != lastButtonState[4]) {
- // if the state has changed, increment the counter
- if (buttonState[4] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 59, BellowPressurePull); //B
- SendMidi (0x80, 57, BellowPressurePush); //A
- }
- if (Current >= Old){
- SendMidi (0x80, 59, BellowPressurePull); //B
- SendMidi (0x90, 57, BellowPressurePush); //A
- }
- }
- if (buttonState[4] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 59, BellowPressurePush); //B
- SendMidi (0x80, 57, BellowPressurePush); //A
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[4] = buttonState[4];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[5] != lastButtonState[5]) {
- // if the state has changed, increment the counter
- if (buttonState[5] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 61, BellowPressurePull); //Csharp
- SendMidi (0x80, 62, BellowPressurePush); //D
- }
- if (Current >= Old){
- SendMidi (0x80, 61, BellowPressurePull); //Csharp
- SendMidi (0x90, 62, BellowPressurePush); //D
- }
- }
- if (buttonState[3] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 61, BellowPressurePush); //Csharp
- SendMidi (0x80, 62, BellowPressurePush); //D
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[5] = buttonState[5];
- delay(10);
- //HERE AGAIN//
- buttonState[6] = digitalRead(buttonPin[6]);
- buttonState[7] = digitalRead(buttonPin[7]);
- buttonState[8] = digitalRead(buttonPin[8]);
- buttonState[9] = digitalRead(buttonPin[9]);
- buttonState[10] = digitalRead(buttonPin[10]);
- buttonState[11] = digitalRead(buttonPin[11]);
- digitalWrite (Power[0], LOW);
- digitalWrite (Power[1], HIGH);
- digitalWrite (Power[2], LOW);
- digitalWrite (Power[3], LOW);
- digitalWrite (Power[4], LOW);
- // compare the buttonState to its previous state
- if (buttonState[6] != lastButtonState[6]) {
- // if the state has changed, increment the counter
- if (buttonState[6] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 64, BellowPressurePull); //E
- SendMidi (0x80, 66, BellowPressurePush); //Fsharp
- }
- if (Current >= Old){
- SendMidi (0x80, 64, BellowPressurePull); //E
- SendMidi (0x90, 66, BellowPressurePush); //Fsharp
- }
- }
- if (buttonState[6] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 66, BellowPressurePush); //E
- SendMidi (0x80, 64, BellowPressurePush); //Fsharp
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[6] = buttonState[6];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[7] != lastButtonState[7]) {
- // if the state has changed, increment the counter
- if (buttonState[7] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 67, BellowPressurePull); //G
- SendMidi (0x80, 69, BellowPressurePush); //A
- }
- if (Current >= Old){
- SendMidi (0x80, 67, BellowPressurePull); //G
- SendMidi (0x90, 69, BellowPressurePush); //A
- }
- }
- if (buttonState[7] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 67, BellowPressurePush); //G
- SendMidi (0x80, 69, BellowPressurePush); //A
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[7] = buttonState[7];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[8] != lastButtonState[8]) {
- // if the state has changed, increment the counter
- if (buttonState[8] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 71, BellowPressurePull); //B
- SendMidi (0x80, 74, BellowPressurePush); //D
- }
- if (Current >= Old){
- SendMidi (0x80, 71, BellowPressurePull); //B
- SendMidi (0x90, 74, BellowPressurePush); //D
- }
- }
- if (buttonState[8] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 71, BellowPressurePush); //B
- SendMidi (0x80, 74, BellowPressurePush); //D
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[8] = buttonState[8];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[9] != lastButtonState[9]) {
- // if the state has changed, increment the counter
- if (buttonState[9] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 73, BellowPressurePull); //Csharp
- SendMidi (0x80, 78, BellowPressurePush); //Fsharp
- }
- if (Current >= Old){
- SendMidi (0x80, 73, BellowPressurePull); //Csharp
- SendMidi (0x90, 78, BellowPressurePush); //Fsharp
- }
- }
- if (buttonState[9] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 73, BellowPressurePush); //Csjarp
- SendMidi (0x80, 78, BellowPressurePush); //Fsharp
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[9] = buttonState[9];
- //HERE
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[10] = buttonState[10];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[11] != lastButtonState[11]) {
- // if the state has changed, increment the counter
- if (buttonState[11] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 78, BellowPressurePull); //Fsharp
- SendMidi (0x80, 83, BellowPressurePush); //B
- }
- if (Current >= Old){
- SendMidi (0x80, 78, BellowPressurePull); //Fsharp
- SendMidi (0x90, 83, BellowPressurePush); //B
- }
- }
- if (buttonState[11] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 78, BellowPressurePush); //Fsharp
- SendMidi (0x80, 83, BellowPressurePush); //B
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[11] = buttonState[11];
- delay(10);
- //HERE AGAIN//
- buttonState[12] = digitalRead(buttonPin[12]);
- buttonState[13] = digitalRead(buttonPin[13]);
- buttonState[14] = digitalRead(buttonPin[14]);
- buttonState[15] = digitalRead(buttonPin[15]);
- buttonState[16] = digitalRead(buttonPin[16]);
- buttonState[17] = digitalRead(buttonPin[17]);
- digitalWrite (Power[0], LOW);
- digitalWrite (Power[1], LOW);
- digitalWrite (Power[2], HIGH);
- digitalWrite (Power[3], LOW);
- digitalWrite (Power[4], LOW);
- // compare the buttonState to its previous state
- if (buttonState[12] != lastButtonState[12]) {
- // if the state has changed, increment the counter
- if (buttonState[12] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 76, BellowPressurePull); //E
- SendMidi (0x80, 79, BellowPressurePush); //G
- }
- if (Current >= Old){
- SendMidi (0x80, 76, BellowPressurePull); //E
- SendMidi (0x90, 79, BellowPressurePush); //G
- }
- }
- if (buttonState[12] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 76, BellowPressurePush); //E
- SendMidi (0x80, 79, BellowPressurePush); //G
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[12] = buttonState[12];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[13] != lastButtonState[13]) {
- // if the state has changed, increment the counter
- if (buttonState[13] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 72, BellowPressurePull); //C
- SendMidi (0x80, 74, BellowPressurePush); //D
- }
- if (Current >= Old){
- SendMidi (0x80, 72, BellowPressurePull); //C
- SendMidi (0x90, 74, BellowPressurePush); //D
- }
- }
- if (buttonState[13] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 72, BellowPressurePush); //C
- SendMidi (0x80, 74, BellowPressurePush); //D
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[13] = buttonState[13];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[14] != lastButtonState[14]) {
- // if the state has changed, increment the counter
- if (buttonState[14] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 69, BellowPressurePull); //A
- SendMidi (0x80, 71, BellowPressurePush); //B
- }
- if (Current >= Old){
- SendMidi (0x80, 69, BellowPressurePull); //A
- SendMidi (0x90, 71, BellowPressurePush); //B
- }
- }
- if (buttonState[14] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 69, BellowPressurePush); //A
- SendMidi (0x80, 71, BellowPressurePush); //B
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[14] = buttonState[14];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[15] != lastButtonState[15]) {
- // if the state has changed, increment the counter
- if (buttonState[15] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 66, BellowPressurePull); //Fsharp
- SendMidi (0x80, 67, BellowPressurePush); //G
- }
- if (Current >= Old){
- SendMidi (0x80, 66, BellowPressurePull); //Fsharp
- SendMidi (0x90, 67, BellowPressurePush); //G
- }
- }
- if (buttonState[15] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 66, BellowPressurePush); //Fsjarp
- SendMidi (0x80, 67, BellowPressurePush); //G
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[15] = buttonState[15];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[16] != lastButtonState[16]) {
- // if the state has changed, increment the counter
- if (buttonState[16] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 64, BellowPressurePull); //E
- SendMidi (0x80, 62, BellowPressurePush); //D
- }
- if (Current >= Old){
- SendMidi (0x80, 64, BellowPressurePull); //E
- SendMidi (0x90, 62, BellowPressurePush); //D
- }
- }
- if (buttonState[16] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 64, BellowPressurePush); //E
- SendMidi (0x80, 62, BellowPressurePush); //D
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[16] = buttonState[16];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[17] != lastButtonState[17]) {
- // if the state has changed, increment the counter
- if (buttonState[17] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 60, BellowPressurePull); //C
- SendMidi (0x80, 59, BellowPressurePush); //B
- }
- if (Current >= Old){
- SendMidi (0x80, 60, BellowPressurePull); //C
- SendMidi (0x90, 59, BellowPressurePush); //B
- }
- }
- if (buttonState[17] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 60, BellowPressurePush); //C
- SendMidi (0x80, 59, BellowPressurePush); //B
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[17] = buttonState[17];
- delay(10);
- //HERE AGAIN//
- buttonState[18] = digitalRead(buttonPin[18]);
- buttonState[19] = digitalRead(buttonPin[19]);
- buttonState[20] = digitalRead(buttonPin[20]);
- buttonState[21] = digitalRead(buttonPin[21]);
- buttonState[22] = digitalRead(buttonPin[22]);
- buttonState[23] = digitalRead(buttonPin[23]);
- digitalWrite (Power[0], LOW);
- digitalWrite (Power[1], LOW);
- digitalWrite (Power[2], LOW);
- digitalWrite (Power[3], HIGH);
- digitalWrite (Power[4], LOW);
- // compare the buttonState to its previous state
- if (buttonState[18] != lastButtonState[18]) {
- // if the state has changed, increment the counter
- if (buttonState[18] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 57, BellowPressurePull); //A
- SendMidi (0x80, 55, BellowPressurePush); //G
- }
- if (Current >= Old){
- SendMidi (0x80, 57, BellowPressurePull); //A
- SendMidi (0x90, 55, BellowPressurePush); //G
- }
- }
- if (buttonState[18] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 57, BellowPressurePush); //A
- SendMidi (0x80, 55, BellowPressurePush); //G
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[18] = buttonState[18];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[19] != lastButtonState[19]) {
- // if the state has changed, increment the counter
- if (buttonState[19] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 54, BellowPressurePull); //Fsharp
- SendMidi (0x80, 50, BellowPressurePush); //D
- }
- if (Current >= Old){
- SendMidi (0x80, 54, BellowPressurePull); //Fsharp
- SendMidi (0x90, 50, BellowPressurePush); //D
- }
- }
- if (buttonState[19] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 54, BellowPressurePush); //Fsharp
- SendMidi (0x80, 50, BellowPressurePush); //D
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[19] = buttonState[19];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[20] != lastButtonState[20]) {
- // if the state has changed, increment the counter
- if (buttonState[20] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 50, BellowPressurePull); //D
- SendMidi (0x80, 47, BellowPressurePush); //B
- }
- if (Current >= Old){
- SendMidi (0x80, 50, BellowPressurePull); //D
- SendMidi (0x90, 47, BellowPressurePush); //B
- }
- }
- if (buttonState[20] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 50, BellowPressurePush); //D
- SendMidi (0x80, 47, BellowPressurePush); //B
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[20] = buttonState[20];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[21] != lastButtonState[21]) {
- // if the state has changed, increment the counter
- if (buttonState[21] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 43, BellowPressurePull); //Eminor
- SendMidi (0x90, 47, BellowPressurePull);
- SendMidi (0x90, 52, BellowPressurePull);
- SendMidi (0x80, 47, BellowPressurePush); //Bmajor
- SendMidi (0x80, 50, BellowPressurePush);
- SendMidi (0x80, 54, BellowPressurePush);
- }
- if (Current >= Old){
- SendMidi (0x80, 43, BellowPressurePull); //Eminor
- SendMidi (0x80, 47, BellowPressurePull);
- SendMidi (0x80, 52, BellowPressurePull);
- SendMidi (0x90, 47, BellowPressurePush); //Bmajor
- SendMidi (0x90, 50, BellowPressurePush);
- SendMidi (0x90, 54, BellowPressurePush);
- }
- }
- if (buttonState[21] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 43, BellowPressurePull); //Eminor
- SendMidi (0x80, 47, BellowPressurePull);
- SendMidi (0x80, 52, BellowPressurePull);
- SendMidi (0x80, 47, BellowPressurePush); //Bmajor
- SendMidi (0x80, 50, BellowPressurePush);
- SendMidi (0x80, 54, BellowPressurePush);
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[21] = buttonState[21];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[22] != lastButtonState[22]) {
- // if the state has changed, increment the counter
- if (buttonState[22] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 40, BellowPressurePull); //E
- SendMidi (0x80, 35, BellowPressurePush); //B
- }
- if (Current >= Old){
- SendMidi (0x80, 40, BellowPressurePull); //E
- SendMidi (0x90, 35, BellowPressurePush); //B
- }
- }
- if (buttonState[22] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 40, BellowPressurePush); //E
- SendMidi (0x80, 35, BellowPressurePush); //B
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[22] = buttonState[22];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[23] != lastButtonState[23]) {
- // if the state has changed, increment the counter
- if (buttonState[23] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 43, BellowPressurePush); //Cmajor
- SendMidi (0x90, 48, BellowPressurePush); //
- SendMidi (0x90, 52, BellowPressurePush); //
- }
- if (Current >= Old){
- SendMidi (0x90, 43, BellowPressurePush); //Cmajor
- SendMidi (0x90, 48, BellowPressurePush); //
- SendMidi (0x90, 52, BellowPressurePush); //
- }
- }
- if (buttonState[23] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 43, BellowPressurePush); //Cmajor
- SendMidi (0x80, 48, BellowPressurePush); //
- SendMidi (0x80, 52, BellowPressurePush); //
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[23] = buttonState[23];
- delay(10);
- //HERE AGAIN//
- buttonState[24] = digitalRead(buttonPin[24]);
- buttonState[25] = digitalRead(buttonPin[25]);
- buttonState[26] = digitalRead(buttonPin[26]);
- buttonState[27] = digitalRead(buttonPin[27]);
- buttonState[28] = digitalRead(buttonPin[28]);
- buttonState[29] = digitalRead(buttonPin[29]);
- digitalWrite (Power[0], LOW);
- digitalWrite (Power[1], LOW);
- digitalWrite (Power[2], LOW);
- digitalWrite (Power[3], LOW);
- digitalWrite (Power[4], HIGH);
- // compare the buttonState to its previous state
- if (buttonState[24] != lastButtonState[24]) {
- // if the state has changed, increment the counter
- if (buttonState[24] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 36, BellowPressurePush); //C
- }
- if (Current >= Old){
- SendMidi (0x90, 36, BellowPressurePush); //C
- }
- }
- if (buttonState[24] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 36, BellowPressurePush); //C
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[24] = buttonState[24];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[25] != lastButtonState[25]) {
- // if the state has changed, increment the counter
- if (buttonState[25] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 38, BellowPressurePull); //D
- SendMidi (0x80, 31, BellowPressurePush); //G
- }
- if (Current >= Old){
- SendMidi (0x80, 38, BellowPressurePull); //D
- SendMidi (0x90, 31, BellowPressurePush); //G
- }
- }
- if (buttonState[25] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 31, BellowPressurePush); //D
- SendMidi (0x80, 38, BellowPressurePush); //G
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[25] = buttonState[25];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[26] != lastButtonState[26]) {
- // if the state has changed, increment the counter
- if (buttonState[26] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 45, BellowPressurePush); //Dmajor
- SendMidi (0x90, 50, BellowPressurePush); //
- SendMidi (0x90, 54, BellowPressurePush); //
- SendMidi (0x80, 43, BellowPressurePush); //Gmajor
- SendMidi (0x80, 47, BellowPressurePush); //
- SendMidi (0x80, 50, BellowPressurePush); //
- }
- if (Current >= Old){
- SendMidi (0x80, 45, BellowPressurePush); //Dmajor
- SendMidi (0x80, 50, BellowPressurePush); //
- SendMidi (0x80, 54, BellowPressurePush); //
- SendMidi (0x90, 43, BellowPressurePush); //Gmajor
- SendMidi (0x90, 47, BellowPressurePush); //
- SendMidi (0x90, 50, BellowPressurePush); //
- }
- }
- if (buttonState[26] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 45, BellowPressurePush); //Dmajor
- SendMidi (0x80, 50, BellowPressurePush); //
- SendMidi (0x80, 54, BellowPressurePush); //
- SendMidi (0x80, 43, BellowPressurePush); //Gmajor
- SendMidi (0x80, 47, BellowPressurePush); //
- SendMidi (0x80, 50, BellowPressurePush); //
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[26] = buttonState[26];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[27] != lastButtonState[27]) {
- // if the state has changed, increment the counter
- if (buttonState[27] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 34, BellowPressurePull); //A
- SendMidi (0x80, 38, BellowPressurePush); //D
- }
- if (Current >= Old){
- SendMidi (0x80, 34, BellowPressurePull); //A
- SendMidi (0x90, 38, BellowPressurePush); //D
- }
- }
- if (buttonState[27] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 34, BellowPressurePush); //A
- SendMidi (0x80, 38, BellowPressurePush); //D
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[27] = buttonState[27];
- //HERE
- // compare the buttonState to its previous state
- if (buttonState[28] != lastButtonState[28]) {
- // if the state has changed, increment the counter
- if (buttonState[28] == HIGH) {
- if (Current < Old){
- SendMidi (0x90, 45, BellowPressurePull); //Amajor
- SendMidi (0x90, 59, BellowPressurePull); //
- SendMidi (0x90, 52, BellowPressurePull); //
- SendMidi (0x80, 50, BellowPressurePush); //Dmajor
- SendMidi (0x80, 42, BellowPressurePush); //
- SendMidi (0x80, 57, BellowPressurePush); //
- }
- if (Current >= Old){
- SendMidi (0x80, 45, BellowPressurePull); //Amajor
- SendMidi (0x80, 59, BellowPressurePull); //
- SendMidi (0x80, 52, BellowPressurePull); //
- SendMidi (0x90, 50, BellowPressurePush); //Dmajor
- SendMidi (0x90, 42, BellowPressurePush); //
- SendMidi (0x90, 57, BellowPressurePush); //
- }
- }
- if (buttonState[28] == LOW) {
- // if the Currentrent state is LOW then the button
- // wend from on to off:
- SendMidi (0x80, 45, BellowPressurePull); //Amajor
- SendMidi (0x80, 59, BellowPressurePull); //
- SendMidi (0x80, 52, BellowPressurePull); //
- SendMidi (0x80, 50, BellowPressurePush); //Dmajor
- SendMidi (0x80, 42, BellowPressurePush); //
- SendMidi (0x80, 57, BellowPressurePush); //
- }
- }
- // save the Currentrent state as the last state,
- //for next time through the loop
- lastButtonState[28] = buttonState[28];
- delay(10);
- Old = Current;
- }
- void SendMidi (int cmd, int value, int vel) {
- Serial.write (cmd);
- Serial.write (value);
- Serial.write (vel);
- }
Add Comment
Please, Sign In to add comment