Guest User

Full Code

a guest
May 17th, 2012
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.08 KB | None | 0 0
  1.  
  2. // this constant won't change:
  3. const byte buttonPin[30] = {
  4. 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};
  5. const byte Power [5] = {
  6. 2,3,4,5,6};
  7.  
  8.  
  9.  
  10. // Variables will change:
  11. byte buttonPushCounter[30] = {
  12. 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
  13. byte buttonState[30] = {
  14. 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
  15. byte lastButtonState[30] = {
  16. 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
  17.  
  18. int analogValue1 = 0; // value read from the pot;
  19. const byte numReadings = 50;
  20. int inputPin = A0;
  21. byte oldBellowPressurePush = 0;
  22. int BellowPressurePush = 0;
  23. int BellowPressurePull = 0;
  24. byte Old = 0;
  25. byte Current = 0;
  26. byte readings[numReadings]; // the readings from the analog input
  27. byte index = 0; // the index of the Currentrent reading
  28. int total = 0; // the running total
  29. int average = 0; // the average
  30.  
  31. void setup() {
  32. // initialize the button pin as a input:
  33. pinMode(buttonPin[0], INPUT);
  34. pinMode(buttonPin[1], INPUT);
  35. pinMode(buttonPin[2], INPUT);
  36. pinMode(buttonPin[3], INPUT);
  37. pinMode(buttonPin[4], INPUT);
  38. pinMode(buttonPin[5], INPUT);
  39. pinMode(Power[0], OUTPUT);
  40. pinMode(Power[1], OUTPUT);
  41. pinMode(Power[2], OUTPUT);
  42. pinMode(Power[3], OUTPUT);
  43. pinMode(Power[4], OUTPUT);
  44.  
  45. // initialize serial communication:
  46. Serial.begin(31250);
  47. }
  48.  
  49.  
  50. void loop() {
  51.  
  52.  
  53. total= total - readings[index]; // subtract the last reading:
  54. readings[index] = analogRead(inputPin); // read from the sensor:
  55. total= total + readings[index]; // add the reading to the total:
  56. index = index + 1; // advance to the next position in the array:
  57. if (index >= numReadings) // if we're at the end of the array...
  58. index = 0; // ...wrap around to the beginning:
  59. average = total / numReadings; // calculate the average and send it to the computer as ASCII digits
  60. Current = total / numReadings;
  61.  
  62. BellowPressurePush = 120;
  63. BellowPressurePull = 120;
  64.  
  65. delay(10);
  66.  
  67. // read the pushbutton input pin:
  68. buttonState[0] = digitalRead(buttonPin[0]);
  69. buttonState[1] = digitalRead(buttonPin[1]);
  70. buttonState[2] = digitalRead(buttonPin[2]);
  71. buttonState[3] = digitalRead(buttonPin[3]);
  72. buttonState[4] = digitalRead(buttonPin[4]);
  73. buttonState[5] = digitalRead(buttonPin[5]);
  74. digitalWrite (Power[0], HIGH);
  75. digitalWrite (Power[1], LOW);
  76. digitalWrite (Power[2], LOW);
  77. digitalWrite (Power[3], LOW);
  78. digitalWrite (Power[4], LOW);
  79.  
  80. // compare the buttonState to its previous state
  81. if (buttonState[0] != lastButtonState[0]) {
  82. // if the state has changed, increment the counter
  83. if (buttonState[0] == HIGH) {
  84. if (Current < Old){
  85. SendMidi (0x90, 45, BellowPressurePull); //A
  86. SendMidi (0x80, 42, BellowPressurePush); //Fsharp
  87. }
  88. if (Current >= Old){
  89. SendMidi (0x80, 45, BellowPressurePull); //A
  90. SendMidi (0x90, 42, BellowPressurePush); //Fsharp
  91. }
  92.  
  93. }
  94. if (buttonState[0] == LOW) {
  95. // if the Currentrent state is LOW then the button
  96. // wend from on to off:
  97. SendMidi (0x80, 45, BellowPressurePush); //A
  98. SendMidi (0x80, 42, BellowPressurePush); //Fsharp
  99. }
  100. }
  101. // save the Currentrent state as the last state,
  102. //for next time through the loop
  103. lastButtonState[0] = buttonState[0];
  104.  
  105. //HERE
  106.  
  107. // compare the buttonState to its previous state
  108. if (buttonState[1] != lastButtonState[1]) {
  109. // if the state has changed, increment the counter
  110. if (buttonState[1] == HIGH) {
  111. if (Current < Old){
  112. SendMidi (0x90, 49, BellowPressurePull); //Csharp
  113. SendMidi (0x80, 45, BellowPressurePush); //A
  114. }
  115. if (Current >= Old){
  116. SendMidi (0x80, 49, BellowPressurePull); //Csharp
  117. SendMidi (0x90, 45, BellowPressurePush); //A
  118. }
  119.  
  120. }
  121. if (buttonState[1] == LOW) {
  122. // if the Currentrent state is LOW then the button
  123. // wend from on to off:
  124. SendMidi (0x80, 49, BellowPressurePush); //Csharp
  125. SendMidi (0x80, 45, BellowPressurePush); //A
  126. }
  127. }
  128. // save the Currentrent state as the last state,
  129. //for next time through the loop
  130. lastButtonState[1] = buttonState[1];
  131.  
  132. //HERE
  133.  
  134. // compare the buttonState to its previous state
  135. if (buttonState[2] != lastButtonState[2]) {
  136. // if the state has changed, increment the counter
  137. if (buttonState[2] == HIGH) {
  138. if (Current < Old){
  139. SendMidi (0x90, 52, BellowPressurePull); //E
  140. SendMidi (0x80, 50, BellowPressurePush); //D
  141. }
  142. if (Current >= Old){
  143. SendMidi (0x80, 52, BellowPressurePull); //E
  144. SendMidi (0x90, 50, BellowPressurePush); //D
  145. }
  146.  
  147. }
  148. if (buttonState[2] == LOW) {
  149. // if the Currentrent state is LOW then the button
  150. // wend from on to off:
  151. SendMidi (0x80, 52, BellowPressurePush); //E
  152. SendMidi (0x80, 50, BellowPressurePush); //D
  153. }
  154. }
  155. // save the Currentrent state as the last state,
  156. //for next time through the loop
  157. lastButtonState[2] = buttonState[2];
  158.  
  159. //HERE
  160.  
  161. // compare the buttonState to its previous state
  162. if (buttonState[3] != lastButtonState[3]) {
  163. // if the state has changed, increment the counter
  164. if (buttonState[3] == HIGH) {
  165. if (Current < Old){
  166. SendMidi (0x90, 55, BellowPressurePull); //G
  167. SendMidi (0x80, 54, BellowPressurePush); //Fsharp
  168. }
  169. if (Current >= Old){
  170. SendMidi (0x80, 55, BellowPressurePull); //G
  171. SendMidi (0x90, 54, BellowPressurePush); //Fsharp
  172. }
  173.  
  174. }
  175. if (buttonState[3] == LOW) {
  176. // if the Currentrent state is LOW then the button
  177. // wend from on to off:
  178. SendMidi (0x80, 55, BellowPressurePush); //G
  179. SendMidi (0x80, 54, BellowPressurePush); //Fsharp
  180. }
  181. }
  182. // save the Currentrent state as the last state,
  183. //for next time through the loop
  184. lastButtonState[3] = buttonState[3];
  185.  
  186. //HERE
  187.  
  188. // compare the buttonState to its previous state
  189. if (buttonState[4] != lastButtonState[4]) {
  190. // if the state has changed, increment the counter
  191. if (buttonState[4] == HIGH) {
  192. if (Current < Old){
  193. SendMidi (0x90, 59, BellowPressurePull); //B
  194. SendMidi (0x80, 57, BellowPressurePush); //A
  195. }
  196. if (Current >= Old){
  197. SendMidi (0x80, 59, BellowPressurePull); //B
  198. SendMidi (0x90, 57, BellowPressurePush); //A
  199. }
  200.  
  201. }
  202. if (buttonState[4] == LOW) {
  203. // if the Currentrent state is LOW then the button
  204. // wend from on to off:
  205. SendMidi (0x80, 59, BellowPressurePush); //B
  206. SendMidi (0x80, 57, BellowPressurePush); //A
  207. }
  208. }
  209. // save the Currentrent state as the last state,
  210. //for next time through the loop
  211. lastButtonState[4] = buttonState[4];
  212.  
  213. //HERE
  214.  
  215. // compare the buttonState to its previous state
  216. if (buttonState[5] != lastButtonState[5]) {
  217. // if the state has changed, increment the counter
  218. if (buttonState[5] == HIGH) {
  219. if (Current < Old){
  220. SendMidi (0x90, 61, BellowPressurePull); //Csharp
  221. SendMidi (0x80, 62, BellowPressurePush); //D
  222. }
  223. if (Current >= Old){
  224. SendMidi (0x80, 61, BellowPressurePull); //Csharp
  225. SendMidi (0x90, 62, BellowPressurePush); //D
  226. }
  227.  
  228. }
  229. if (buttonState[3] == LOW) {
  230. // if the Currentrent state is LOW then the button
  231. // wend from on to off:
  232. SendMidi (0x80, 61, BellowPressurePush); //Csharp
  233. SendMidi (0x80, 62, BellowPressurePush); //D
  234. }
  235. }
  236. // save the Currentrent state as the last state,
  237. //for next time through the loop
  238. lastButtonState[5] = buttonState[5];
  239.  
  240. delay(10);
  241.  
  242. //HERE AGAIN//
  243.  
  244. buttonState[6] = digitalRead(buttonPin[6]);
  245. buttonState[7] = digitalRead(buttonPin[7]);
  246. buttonState[8] = digitalRead(buttonPin[8]);
  247. buttonState[9] = digitalRead(buttonPin[9]);
  248. buttonState[10] = digitalRead(buttonPin[10]);
  249. buttonState[11] = digitalRead(buttonPin[11]);
  250.  
  251.  
  252. digitalWrite (Power[0], LOW);
  253. digitalWrite (Power[1], HIGH);
  254. digitalWrite (Power[2], LOW);
  255. digitalWrite (Power[3], LOW);
  256. digitalWrite (Power[4], LOW);
  257.  
  258. // compare the buttonState to its previous state
  259. if (buttonState[6] != lastButtonState[6]) {
  260. // if the state has changed, increment the counter
  261. if (buttonState[6] == HIGH) {
  262. if (Current < Old){
  263. SendMidi (0x90, 64, BellowPressurePull); //E
  264. SendMidi (0x80, 66, BellowPressurePush); //Fsharp
  265. }
  266. if (Current >= Old){
  267. SendMidi (0x80, 64, BellowPressurePull); //E
  268. SendMidi (0x90, 66, BellowPressurePush); //Fsharp
  269. }
  270.  
  271. }
  272. if (buttonState[6] == LOW) {
  273. // if the Currentrent state is LOW then the button
  274. // wend from on to off:
  275. SendMidi (0x80, 66, BellowPressurePush); //E
  276. SendMidi (0x80, 64, BellowPressurePush); //Fsharp
  277. }
  278. }
  279. // save the Currentrent state as the last state,
  280. //for next time through the loop
  281. lastButtonState[6] = buttonState[6];
  282.  
  283. //HERE
  284.  
  285. // compare the buttonState to its previous state
  286. if (buttonState[7] != lastButtonState[7]) {
  287. // if the state has changed, increment the counter
  288. if (buttonState[7] == HIGH) {
  289. if (Current < Old){
  290. SendMidi (0x90, 67, BellowPressurePull); //G
  291. SendMidi (0x80, 69, BellowPressurePush); //A
  292. }
  293. if (Current >= Old){
  294. SendMidi (0x80, 67, BellowPressurePull); //G
  295. SendMidi (0x90, 69, BellowPressurePush); //A
  296. }
  297.  
  298. }
  299. if (buttonState[7] == LOW) {
  300. // if the Currentrent state is LOW then the button
  301. // wend from on to off:
  302. SendMidi (0x80, 67, BellowPressurePush); //G
  303. SendMidi (0x80, 69, BellowPressurePush); //A
  304. }
  305. }
  306. // save the Currentrent state as the last state,
  307. //for next time through the loop
  308. lastButtonState[7] = buttonState[7];
  309.  
  310. //HERE
  311.  
  312. // compare the buttonState to its previous state
  313. if (buttonState[8] != lastButtonState[8]) {
  314. // if the state has changed, increment the counter
  315. if (buttonState[8] == HIGH) {
  316. if (Current < Old){
  317. SendMidi (0x90, 71, BellowPressurePull); //B
  318. SendMidi (0x80, 74, BellowPressurePush); //D
  319. }
  320. if (Current >= Old){
  321. SendMidi (0x80, 71, BellowPressurePull); //B
  322. SendMidi (0x90, 74, BellowPressurePush); //D
  323. }
  324.  
  325. }
  326. if (buttonState[8] == LOW) {
  327. // if the Currentrent state is LOW then the button
  328. // wend from on to off:
  329. SendMidi (0x80, 71, BellowPressurePush); //B
  330. SendMidi (0x80, 74, BellowPressurePush); //D
  331. }
  332. }
  333. // save the Currentrent state as the last state,
  334. //for next time through the loop
  335. lastButtonState[8] = buttonState[8];
  336.  
  337. //HERE
  338.  
  339. // compare the buttonState to its previous state
  340. if (buttonState[9] != lastButtonState[9]) {
  341. // if the state has changed, increment the counter
  342. if (buttonState[9] == HIGH) {
  343. if (Current < Old){
  344. SendMidi (0x90, 73, BellowPressurePull); //Csharp
  345. SendMidi (0x80, 78, BellowPressurePush); //Fsharp
  346. }
  347. if (Current >= Old){
  348. SendMidi (0x80, 73, BellowPressurePull); //Csharp
  349. SendMidi (0x90, 78, BellowPressurePush); //Fsharp
  350. }
  351.  
  352. }
  353. if (buttonState[9] == LOW) {
  354. // if the Currentrent state is LOW then the button
  355. // wend from on to off:
  356. SendMidi (0x80, 73, BellowPressurePush); //Csjarp
  357. SendMidi (0x80, 78, BellowPressurePush); //Fsharp
  358. }
  359. }
  360. // save the Currentrent state as the last state,
  361. //for next time through the loop
  362. lastButtonState[9] = buttonState[9];
  363.  
  364. //HERE
  365.  
  366. // save the Currentrent state as the last state,
  367. //for next time through the loop
  368. lastButtonState[10] = buttonState[10];
  369.  
  370. //HERE
  371.  
  372. // compare the buttonState to its previous state
  373. if (buttonState[11] != lastButtonState[11]) {
  374. // if the state has changed, increment the counter
  375. if (buttonState[11] == HIGH) {
  376. if (Current < Old){
  377. SendMidi (0x90, 78, BellowPressurePull); //Fsharp
  378. SendMidi (0x80, 83, BellowPressurePush); //B
  379. }
  380. if (Current >= Old){
  381. SendMidi (0x80, 78, BellowPressurePull); //Fsharp
  382. SendMidi (0x90, 83, BellowPressurePush); //B
  383. }
  384.  
  385. }
  386. if (buttonState[11] == LOW) {
  387. // if the Currentrent state is LOW then the button
  388. // wend from on to off:
  389. SendMidi (0x80, 78, BellowPressurePush); //Fsharp
  390. SendMidi (0x80, 83, BellowPressurePush); //B
  391. }
  392. }
  393. // save the Currentrent state as the last state,
  394. //for next time through the loop
  395. lastButtonState[11] = buttonState[11];
  396.  
  397. delay(10);
  398.  
  399. //HERE AGAIN//
  400.  
  401. buttonState[12] = digitalRead(buttonPin[12]);
  402. buttonState[13] = digitalRead(buttonPin[13]);
  403. buttonState[14] = digitalRead(buttonPin[14]);
  404. buttonState[15] = digitalRead(buttonPin[15]);
  405. buttonState[16] = digitalRead(buttonPin[16]);
  406. buttonState[17] = digitalRead(buttonPin[17]);
  407.  
  408.  
  409. digitalWrite (Power[0], LOW);
  410. digitalWrite (Power[1], LOW);
  411. digitalWrite (Power[2], HIGH);
  412. digitalWrite (Power[3], LOW);
  413. digitalWrite (Power[4], LOW);
  414.  
  415. // compare the buttonState to its previous state
  416. if (buttonState[12] != lastButtonState[12]) {
  417. // if the state has changed, increment the counter
  418. if (buttonState[12] == HIGH) {
  419. if (Current < Old){
  420. SendMidi (0x90, 76, BellowPressurePull); //E
  421. SendMidi (0x80, 79, BellowPressurePush); //G
  422. }
  423. if (Current >= Old){
  424. SendMidi (0x80, 76, BellowPressurePull); //E
  425. SendMidi (0x90, 79, BellowPressurePush); //G
  426. }
  427.  
  428. }
  429. if (buttonState[12] == LOW) {
  430. // if the Currentrent state is LOW then the button
  431. // wend from on to off:
  432. SendMidi (0x80, 76, BellowPressurePush); //E
  433. SendMidi (0x80, 79, BellowPressurePush); //G
  434. }
  435. }
  436. // save the Currentrent state as the last state,
  437. //for next time through the loop
  438. lastButtonState[12] = buttonState[12];
  439.  
  440. //HERE
  441.  
  442. // compare the buttonState to its previous state
  443. if (buttonState[13] != lastButtonState[13]) {
  444. // if the state has changed, increment the counter
  445. if (buttonState[13] == HIGH) {
  446. if (Current < Old){
  447. SendMidi (0x90, 72, BellowPressurePull); //C
  448. SendMidi (0x80, 74, BellowPressurePush); //D
  449. }
  450. if (Current >= Old){
  451. SendMidi (0x80, 72, BellowPressurePull); //C
  452. SendMidi (0x90, 74, BellowPressurePush); //D
  453. }
  454.  
  455. }
  456. if (buttonState[13] == LOW) {
  457. // if the Currentrent state is LOW then the button
  458. // wend from on to off:
  459. SendMidi (0x80, 72, BellowPressurePush); //C
  460. SendMidi (0x80, 74, BellowPressurePush); //D
  461. }
  462. }
  463. // save the Currentrent state as the last state,
  464. //for next time through the loop
  465. lastButtonState[13] = buttonState[13];
  466.  
  467. //HERE
  468.  
  469. // compare the buttonState to its previous state
  470. if (buttonState[14] != lastButtonState[14]) {
  471. // if the state has changed, increment the counter
  472. if (buttonState[14] == HIGH) {
  473. if (Current < Old){
  474. SendMidi (0x90, 69, BellowPressurePull); //A
  475. SendMidi (0x80, 71, BellowPressurePush); //B
  476. }
  477. if (Current >= Old){
  478. SendMidi (0x80, 69, BellowPressurePull); //A
  479. SendMidi (0x90, 71, BellowPressurePush); //B
  480. }
  481.  
  482. }
  483. if (buttonState[14] == LOW) {
  484. // if the Currentrent state is LOW then the button
  485. // wend from on to off:
  486. SendMidi (0x80, 69, BellowPressurePush); //A
  487. SendMidi (0x80, 71, BellowPressurePush); //B
  488. }
  489. }
  490. // save the Currentrent state as the last state,
  491. //for next time through the loop
  492. lastButtonState[14] = buttonState[14];
  493.  
  494. //HERE
  495.  
  496. // compare the buttonState to its previous state
  497. if (buttonState[15] != lastButtonState[15]) {
  498. // if the state has changed, increment the counter
  499. if (buttonState[15] == HIGH) {
  500. if (Current < Old){
  501. SendMidi (0x90, 66, BellowPressurePull); //Fsharp
  502. SendMidi (0x80, 67, BellowPressurePush); //G
  503. }
  504. if (Current >= Old){
  505. SendMidi (0x80, 66, BellowPressurePull); //Fsharp
  506. SendMidi (0x90, 67, BellowPressurePush); //G
  507. }
  508.  
  509. }
  510. if (buttonState[15] == LOW) {
  511. // if the Currentrent state is LOW then the button
  512. // wend from on to off:
  513. SendMidi (0x80, 66, BellowPressurePush); //Fsjarp
  514. SendMidi (0x80, 67, BellowPressurePush); //G
  515. }
  516. }
  517. // save the Currentrent state as the last state,
  518. //for next time through the loop
  519. lastButtonState[15] = buttonState[15];
  520.  
  521. //HERE
  522.  
  523. // compare the buttonState to its previous state
  524. if (buttonState[16] != lastButtonState[16]) {
  525. // if the state has changed, increment the counter
  526. if (buttonState[16] == HIGH) {
  527. if (Current < Old){
  528. SendMidi (0x90, 64, BellowPressurePull); //E
  529. SendMidi (0x80, 62, BellowPressurePush); //D
  530. }
  531. if (Current >= Old){
  532. SendMidi (0x80, 64, BellowPressurePull); //E
  533. SendMidi (0x90, 62, BellowPressurePush); //D
  534. }
  535.  
  536. }
  537. if (buttonState[16] == LOW) {
  538. // if the Currentrent state is LOW then the button
  539. // wend from on to off:
  540. SendMidi (0x80, 64, BellowPressurePush); //E
  541. SendMidi (0x80, 62, BellowPressurePush); //D
  542. }
  543. }
  544. // save the Currentrent state as the last state,
  545. //for next time through the loop
  546. lastButtonState[16] = buttonState[16];
  547.  
  548. //HERE
  549.  
  550. // compare the buttonState to its previous state
  551. if (buttonState[17] != lastButtonState[17]) {
  552. // if the state has changed, increment the counter
  553. if (buttonState[17] == HIGH) {
  554. if (Current < Old){
  555. SendMidi (0x90, 60, BellowPressurePull); //C
  556. SendMidi (0x80, 59, BellowPressurePush); //B
  557. }
  558. if (Current >= Old){
  559. SendMidi (0x80, 60, BellowPressurePull); //C
  560. SendMidi (0x90, 59, BellowPressurePush); //B
  561. }
  562.  
  563. }
  564. if (buttonState[17] == LOW) {
  565. // if the Currentrent state is LOW then the button
  566. // wend from on to off:
  567. SendMidi (0x80, 60, BellowPressurePush); //C
  568. SendMidi (0x80, 59, BellowPressurePush); //B
  569. }
  570. }
  571. // save the Currentrent state as the last state,
  572. //for next time through the loop
  573. lastButtonState[17] = buttonState[17];
  574.  
  575. delay(10);
  576.  
  577. //HERE AGAIN//
  578.  
  579. buttonState[18] = digitalRead(buttonPin[18]);
  580. buttonState[19] = digitalRead(buttonPin[19]);
  581. buttonState[20] = digitalRead(buttonPin[20]);
  582. buttonState[21] = digitalRead(buttonPin[21]);
  583. buttonState[22] = digitalRead(buttonPin[22]);
  584. buttonState[23] = digitalRead(buttonPin[23]);
  585.  
  586.  
  587. digitalWrite (Power[0], LOW);
  588. digitalWrite (Power[1], LOW);
  589. digitalWrite (Power[2], LOW);
  590. digitalWrite (Power[3], HIGH);
  591. digitalWrite (Power[4], LOW);
  592.  
  593. // compare the buttonState to its previous state
  594. if (buttonState[18] != lastButtonState[18]) {
  595. // if the state has changed, increment the counter
  596. if (buttonState[18] == HIGH) {
  597. if (Current < Old){
  598. SendMidi (0x90, 57, BellowPressurePull); //A
  599. SendMidi (0x80, 55, BellowPressurePush); //G
  600. }
  601. if (Current >= Old){
  602. SendMidi (0x80, 57, BellowPressurePull); //A
  603. SendMidi (0x90, 55, BellowPressurePush); //G
  604. }
  605.  
  606. }
  607. if (buttonState[18] == LOW) {
  608. // if the Currentrent state is LOW then the button
  609. // wend from on to off:
  610. SendMidi (0x80, 57, BellowPressurePush); //A
  611. SendMidi (0x80, 55, BellowPressurePush); //G
  612. }
  613. }
  614. // save the Currentrent state as the last state,
  615. //for next time through the loop
  616. lastButtonState[18] = buttonState[18];
  617.  
  618. //HERE
  619.  
  620. // compare the buttonState to its previous state
  621. if (buttonState[19] != lastButtonState[19]) {
  622. // if the state has changed, increment the counter
  623. if (buttonState[19] == HIGH) {
  624. if (Current < Old){
  625. SendMidi (0x90, 54, BellowPressurePull); //Fsharp
  626. SendMidi (0x80, 50, BellowPressurePush); //D
  627. }
  628. if (Current >= Old){
  629. SendMidi (0x80, 54, BellowPressurePull); //Fsharp
  630. SendMidi (0x90, 50, BellowPressurePush); //D
  631. }
  632.  
  633. }
  634. if (buttonState[19] == LOW) {
  635. // if the Currentrent state is LOW then the button
  636. // wend from on to off:
  637. SendMidi (0x80, 54, BellowPressurePush); //Fsharp
  638. SendMidi (0x80, 50, BellowPressurePush); //D
  639. }
  640. }
  641. // save the Currentrent state as the last state,
  642. //for next time through the loop
  643. lastButtonState[19] = buttonState[19];
  644.  
  645. //HERE
  646.  
  647. // compare the buttonState to its previous state
  648. if (buttonState[20] != lastButtonState[20]) {
  649. // if the state has changed, increment the counter
  650. if (buttonState[20] == HIGH) {
  651. if (Current < Old){
  652. SendMidi (0x90, 50, BellowPressurePull); //D
  653. SendMidi (0x80, 47, BellowPressurePush); //B
  654. }
  655. if (Current >= Old){
  656. SendMidi (0x80, 50, BellowPressurePull); //D
  657. SendMidi (0x90, 47, BellowPressurePush); //B
  658. }
  659.  
  660. }
  661. if (buttonState[20] == LOW) {
  662. // if the Currentrent state is LOW then the button
  663. // wend from on to off:
  664. SendMidi (0x80, 50, BellowPressurePush); //D
  665. SendMidi (0x80, 47, BellowPressurePush); //B
  666. }
  667. }
  668. // save the Currentrent state as the last state,
  669. //for next time through the loop
  670. lastButtonState[20] = buttonState[20];
  671.  
  672. //HERE
  673.  
  674. // compare the buttonState to its previous state
  675. if (buttonState[21] != lastButtonState[21]) {
  676. // if the state has changed, increment the counter
  677. if (buttonState[21] == HIGH) {
  678. if (Current < Old){
  679. SendMidi (0x90, 43, BellowPressurePull); //Eminor
  680. SendMidi (0x90, 47, BellowPressurePull);
  681. SendMidi (0x90, 52, BellowPressurePull);
  682. SendMidi (0x80, 47, BellowPressurePush); //Bmajor
  683. SendMidi (0x80, 50, BellowPressurePush);
  684. SendMidi (0x80, 54, BellowPressurePush);
  685.  
  686.  
  687. }
  688. if (Current >= Old){
  689. SendMidi (0x80, 43, BellowPressurePull); //Eminor
  690. SendMidi (0x80, 47, BellowPressurePull);
  691. SendMidi (0x80, 52, BellowPressurePull);
  692. SendMidi (0x90, 47, BellowPressurePush); //Bmajor
  693. SendMidi (0x90, 50, BellowPressurePush);
  694. SendMidi (0x90, 54, BellowPressurePush);
  695. }
  696.  
  697. }
  698. if (buttonState[21] == LOW) {
  699. // if the Currentrent state is LOW then the button
  700. // wend from on to off:
  701. SendMidi (0x80, 43, BellowPressurePull); //Eminor
  702. SendMidi (0x80, 47, BellowPressurePull);
  703. SendMidi (0x80, 52, BellowPressurePull);
  704. SendMidi (0x80, 47, BellowPressurePush); //Bmajor
  705. SendMidi (0x80, 50, BellowPressurePush);
  706. SendMidi (0x80, 54, BellowPressurePush);
  707. }
  708. }
  709. // save the Currentrent state as the last state,
  710. //for next time through the loop
  711. lastButtonState[21] = buttonState[21];
  712.  
  713. //HERE
  714.  
  715. // compare the buttonState to its previous state
  716. if (buttonState[22] != lastButtonState[22]) {
  717. // if the state has changed, increment the counter
  718. if (buttonState[22] == HIGH) {
  719. if (Current < Old){
  720. SendMidi (0x90, 40, BellowPressurePull); //E
  721. SendMidi (0x80, 35, BellowPressurePush); //B
  722. }
  723. if (Current >= Old){
  724. SendMidi (0x80, 40, BellowPressurePull); //E
  725. SendMidi (0x90, 35, BellowPressurePush); //B
  726. }
  727.  
  728. }
  729. if (buttonState[22] == LOW) {
  730. // if the Currentrent state is LOW then the button
  731. // wend from on to off:
  732. SendMidi (0x80, 40, BellowPressurePush); //E
  733. SendMidi (0x80, 35, BellowPressurePush); //B
  734. }
  735. }
  736. // save the Currentrent state as the last state,
  737. //for next time through the loop
  738. lastButtonState[22] = buttonState[22];
  739.  
  740. //HERE
  741.  
  742. // compare the buttonState to its previous state
  743. if (buttonState[23] != lastButtonState[23]) {
  744. // if the state has changed, increment the counter
  745. if (buttonState[23] == HIGH) {
  746. if (Current < Old){
  747. SendMidi (0x90, 43, BellowPressurePush); //Cmajor
  748. SendMidi (0x90, 48, BellowPressurePush); //
  749. SendMidi (0x90, 52, BellowPressurePush); //
  750. }
  751. if (Current >= Old){
  752. SendMidi (0x90, 43, BellowPressurePush); //Cmajor
  753. SendMidi (0x90, 48, BellowPressurePush); //
  754. SendMidi (0x90, 52, BellowPressurePush); //
  755. }
  756.  
  757. }
  758. if (buttonState[23] == LOW) {
  759. // if the Currentrent state is LOW then the button
  760. // wend from on to off:
  761. SendMidi (0x80, 43, BellowPressurePush); //Cmajor
  762. SendMidi (0x80, 48, BellowPressurePush); //
  763. SendMidi (0x80, 52, BellowPressurePush); //
  764. }
  765. }
  766. // save the Currentrent state as the last state,
  767. //for next time through the loop
  768. lastButtonState[23] = buttonState[23];
  769.  
  770. delay(10);
  771.  
  772. //HERE AGAIN//
  773.  
  774. buttonState[24] = digitalRead(buttonPin[24]);
  775. buttonState[25] = digitalRead(buttonPin[25]);
  776. buttonState[26] = digitalRead(buttonPin[26]);
  777. buttonState[27] = digitalRead(buttonPin[27]);
  778. buttonState[28] = digitalRead(buttonPin[28]);
  779. buttonState[29] = digitalRead(buttonPin[29]);
  780.  
  781.  
  782. digitalWrite (Power[0], LOW);
  783. digitalWrite (Power[1], LOW);
  784. digitalWrite (Power[2], LOW);
  785. digitalWrite (Power[3], LOW);
  786. digitalWrite (Power[4], HIGH);
  787.  
  788. // compare the buttonState to its previous state
  789. if (buttonState[24] != lastButtonState[24]) {
  790. // if the state has changed, increment the counter
  791. if (buttonState[24] == HIGH) {
  792.  
  793. if (Current < Old){
  794. SendMidi (0x90, 36, BellowPressurePush); //C
  795. }
  796. if (Current >= Old){
  797. SendMidi (0x90, 36, BellowPressurePush); //C
  798. }
  799. }
  800. if (buttonState[24] == LOW) {
  801. // if the Currentrent state is LOW then the button
  802. // wend from on to off:
  803. SendMidi (0x80, 36, BellowPressurePush); //C
  804.  
  805. }
  806. }
  807.  
  808. // save the Currentrent state as the last state,
  809. //for next time through the loop
  810. lastButtonState[24] = buttonState[24];
  811.  
  812. //HERE
  813.  
  814. // compare the buttonState to its previous state
  815. if (buttonState[25] != lastButtonState[25]) {
  816. // if the state has changed, increment the counter
  817. if (buttonState[25] == HIGH) {
  818. if (Current < Old){
  819. SendMidi (0x90, 38, BellowPressurePull); //D
  820. SendMidi (0x80, 31, BellowPressurePush); //G
  821. }
  822. if (Current >= Old){
  823. SendMidi (0x80, 38, BellowPressurePull); //D
  824. SendMidi (0x90, 31, BellowPressurePush); //G
  825. }
  826.  
  827. }
  828. if (buttonState[25] == LOW) {
  829. // if the Currentrent state is LOW then the button
  830. // wend from on to off:
  831. SendMidi (0x80, 31, BellowPressurePush); //D
  832. SendMidi (0x80, 38, BellowPressurePush); //G
  833. }
  834. }
  835. // save the Currentrent state as the last state,
  836. //for next time through the loop
  837. lastButtonState[25] = buttonState[25];
  838.  
  839. //HERE
  840.  
  841. // compare the buttonState to its previous state
  842. if (buttonState[26] != lastButtonState[26]) {
  843. // if the state has changed, increment the counter
  844. if (buttonState[26] == HIGH) {
  845. if (Current < Old){
  846. SendMidi (0x90, 45, BellowPressurePush); //Dmajor
  847. SendMidi (0x90, 50, BellowPressurePush); //
  848. SendMidi (0x90, 54, BellowPressurePush); //
  849. SendMidi (0x80, 43, BellowPressurePush); //Gmajor
  850. SendMidi (0x80, 47, BellowPressurePush); //
  851. SendMidi (0x80, 50, BellowPressurePush); //
  852. }
  853. if (Current >= Old){
  854. SendMidi (0x80, 45, BellowPressurePush); //Dmajor
  855. SendMidi (0x80, 50, BellowPressurePush); //
  856. SendMidi (0x80, 54, BellowPressurePush); //
  857. SendMidi (0x90, 43, BellowPressurePush); //Gmajor
  858. SendMidi (0x90, 47, BellowPressurePush); //
  859. SendMidi (0x90, 50, BellowPressurePush); //
  860. }
  861.  
  862. }
  863. if (buttonState[26] == LOW) {
  864. // if the Currentrent state is LOW then the button
  865. // wend from on to off:
  866. SendMidi (0x80, 45, BellowPressurePush); //Dmajor
  867. SendMidi (0x80, 50, BellowPressurePush); //
  868. SendMidi (0x80, 54, BellowPressurePush); //
  869. SendMidi (0x80, 43, BellowPressurePush); //Gmajor
  870. SendMidi (0x80, 47, BellowPressurePush); //
  871. SendMidi (0x80, 50, BellowPressurePush); //
  872. }
  873. }
  874. // save the Currentrent state as the last state,
  875. //for next time through the loop
  876. lastButtonState[26] = buttonState[26];
  877.  
  878. //HERE
  879.  
  880. // compare the buttonState to its previous state
  881. if (buttonState[27] != lastButtonState[27]) {
  882. // if the state has changed, increment the counter
  883. if (buttonState[27] == HIGH) {
  884. if (Current < Old){
  885. SendMidi (0x90, 34, BellowPressurePull); //A
  886. SendMidi (0x80, 38, BellowPressurePush); //D
  887. }
  888. if (Current >= Old){
  889. SendMidi (0x80, 34, BellowPressurePull); //A
  890. SendMidi (0x90, 38, BellowPressurePush); //D
  891. }
  892.  
  893. }
  894. if (buttonState[27] == LOW) {
  895. // if the Currentrent state is LOW then the button
  896. // wend from on to off:
  897. SendMidi (0x80, 34, BellowPressurePush); //A
  898. SendMidi (0x80, 38, BellowPressurePush); //D
  899. }
  900. }
  901. // save the Currentrent state as the last state,
  902. //for next time through the loop
  903. lastButtonState[27] = buttonState[27];
  904.  
  905. //HERE
  906.  
  907. // compare the buttonState to its previous state
  908. if (buttonState[28] != lastButtonState[28]) {
  909. // if the state has changed, increment the counter
  910. if (buttonState[28] == HIGH) {
  911. if (Current < Old){
  912. SendMidi (0x90, 45, BellowPressurePull); //Amajor
  913. SendMidi (0x90, 59, BellowPressurePull); //
  914. SendMidi (0x90, 52, BellowPressurePull); //
  915. SendMidi (0x80, 50, BellowPressurePush); //Dmajor
  916. SendMidi (0x80, 42, BellowPressurePush); //
  917. SendMidi (0x80, 57, BellowPressurePush); //
  918. }
  919. if (Current >= Old){
  920. SendMidi (0x80, 45, BellowPressurePull); //Amajor
  921. SendMidi (0x80, 59, BellowPressurePull); //
  922. SendMidi (0x80, 52, BellowPressurePull); //
  923. SendMidi (0x90, 50, BellowPressurePush); //Dmajor
  924. SendMidi (0x90, 42, BellowPressurePush); //
  925. SendMidi (0x90, 57, BellowPressurePush); //
  926. }
  927.  
  928. }
  929. if (buttonState[28] == LOW) {
  930. // if the Currentrent state is LOW then the button
  931. // wend from on to off:
  932. SendMidi (0x80, 45, BellowPressurePull); //Amajor
  933. SendMidi (0x80, 59, BellowPressurePull); //
  934. SendMidi (0x80, 52, BellowPressurePull); //
  935. SendMidi (0x80, 50, BellowPressurePush); //Dmajor
  936. SendMidi (0x80, 42, BellowPressurePush); //
  937. SendMidi (0x80, 57, BellowPressurePush); //
  938. }
  939. }
  940. // save the Currentrent state as the last state,
  941. //for next time through the loop
  942. lastButtonState[28] = buttonState[28];
  943.  
  944.  
  945. delay(10);
  946.  
  947.  
  948.  
  949. Old = Current;
  950.  
  951.  
  952. }
  953.  
  954. void SendMidi (int cmd, int value, int vel) {
  955. Serial.write (cmd);
  956. Serial.write (value);
  957. Serial.write (vel);
  958. }
Add Comment
Please, Sign In to add comment