Hi All,
This was by far one of the most frustrating things that I have ever done. I was a situation of knowing what the computer had to do in English, but completely over complicating it and forgetting simple stuff when coding. (Ex. “Serial.begin(9600)”) Dumb. Not having power plugged in. Dumb. In the end, with a serious amount of help from Scott, it worked.
There are a whole bunch of next steps. I think the visual feedback is really important as a guide. Like the glove I made, the LED tells you which scale you a playing. Creating a trellis like board that would support the 4 pronged through hole NeoPixels seems like a lot of work and skills that I don’t have, but Mike’s arcade buttons inspired me. An arcade button MIDI controller with customizable LED colors. Get a microSD card reader and a speaker in there. Awesome. Get some bluetooth or other wireless protocol and have two of them talking to each other. Awesome. So many ideas.
Anyway, here is the video:
Here’s the Arduino Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
#include <Adafruit_GFX.h> #include <Adafruit_NeoMatrix.h> #include <Adafruit_NeoPixel.h> #define PIN 6 byte byteCount; byte r = 255; byte g = 0; byte b = 255; byte xStart = 0; byte yStart = 0; byte xEnd = 7; byte yEnd = 0; char colorVals[24]; Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(8, 8, PIN, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE, NEO_GRB + NEO_KHZ800); void setup() { Serial.begin(9600); matrix.begin(); matrix.setBrightness(30); uint32_t color = matrix.Color(r, g, b); matrix.drawLine(xStart, yStart, xEnd, yEnd, color); matrix.show(); } void loop() { while (true) { int bufferPos = 0; while (bufferPos < 24) { int c = Serial.read(); if (c >= 0) { colorVals[bufferPos++] = c; } r = colorVals[0]; g = colorVals[1]; b = colorVals[2]; uint32_t color = matrix.Color(r, g, b); matrix.drawLine(0, 0, 7, 0, color); r = colorVals[3]; g = colorVals[4]; b = colorVals[5]; color = matrix.Color(r, g, b); matrix.drawLine(0, 1, 7, 1, color); r = colorVals[6]; g = colorVals[7]; b = colorVals[8]; color = matrix.Color(r, g, b); matrix.drawLine(0, 2, 7, 2, color); r = colorVals[9]; g = colorVals[10]; b = colorVals[11]; color = matrix.Color(r, g, b); matrix.drawLine(0, 3, 7, 3, color); r = colorVals[12]; g = colorVals[13]; b = colorVals[14]; color = matrix.Color(r, g, b); matrix.drawLine(0, 4, 7, 4, color); r = colorVals[15]; g = colorVals[16]; b = colorVals[17]; color = matrix.Color(r, g, b); matrix.drawLine(0, 5, 7, 5, color); r = colorVals[18]; g = colorVals[19]; b = colorVals[20]; color = matrix.Color(r, g, b); matrix.drawLine(0, 6, 7, 6, color); r = colorVals[21]; g = colorVals[22]; b = colorVals[23]; color = matrix.Color(r, g, b); matrix.drawLine(0, 7, 7, 7, color); } matrix.show(); while (Serial.available()) Serial.read(); } } |
Here’s the processing code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
import processing.serial.*; PImage gradient; PFont letters; Serial neoPort; int counter = 1; float r0 = 0; float g0 = 0; float b0 = 0; float r1 = 0; float g1 = 0; float b1 = 0; float r2 = 0; float g2 = 0; float b2 = 0; float r3 = 0; float g3 = 0; float b3 = 0; float r4 = 0; float g4 = 0; float b4 = 0; float r5 = 0; float g5 = 0; float b5 = 0; float r6 = 0; float g6 = 0; float b6 = 0; float r7 = 0; float g7 = 0; float b7 = 0; void setup () { println(Serial.list()); String portName = Serial.list()[5]; neoPort = new Serial(this, portName, 9600); size(400, 300); background(0); gradient = loadImage("gradient.png"); letters = loadFont("Serif-20.vlw"); textFont(letters); stroke(0); strokeWeight(1); rect(0, 10, 100, 35); rect(0, 45, 100, 35); rect(0, 80, 100, 35); rect(0, 115, 100, 35); rect(0, 150, 100, 35); rect(0, 185, 100, 35); rect(0, 220, 100, 35); rect(0, 255, 100, 35); fill(0); text("1", 45, 35); text("2", 45, 70); text("3", 45, 105); text("4", 45, 140); text("5", 45, 175); text("6", 45, 210); text("7", 45, 245); text("8", 45, 280); } void draw() { gradient.loadPixels(); image(gradient, 100, 0); } void mousePressed() { float r = red(gradient.pixels[(mouseX-100)+mouseY*gradient.width]); float g = green(gradient.pixels[(mouseX-100)+mouseY*gradient.width]); float b = blue(gradient.pixels[(mouseX-100)+mouseY*gradient.width]); if (counter == 1) { stroke(0); fill(r, g, b); rect(0, 10, 100, 35); fill(255); text("1", 45, 35); r0 = r; g0 = g; b0 = b; } else if (counter == 2) { stroke(0); fill(r, g, b); rect(0, 45, 100, 35); fill(255); text("2", 45, 70); r1 = r; g1 = g; b1 = b; } else if (counter == 3) { stroke(0); fill(r, g, b); rect(0, 80, 100, 35); fill(255); text("3", 45, 105); r2 = r; g2 = g; b2 = b; } else if (counter == 4) { stroke(0); fill(r, g, b); rect(0, 115, 100, 35); fill(255); text("4", 45, 140); r3 = r; g3 = g; b3 = b; } else if (counter == 5) { stroke(0); fill(r, g, b); rect(0, 150, 100, 35); fill(255); text("5", 45, 175); r4 = r; g4 = g; b4 = b; } else if (counter == 6) { stroke(0); fill(r, g, b); rect(0, 185, 100, 35); fill(255); text("6", 45, 210); r5 = r; g5 = g; b5 = b; } else if (counter == 7) { stroke(0); fill(r, g, b); rect(0, 220, 100, 35); fill(255); text("7", 45, 245); r6 = r; g6 = g; b6 = b; } else if (counter == 8) { stroke(0); fill(r, g, b); rect(0, 255, 100, 35); fill(255); text("8", 45, 280); r7 = r; g7 = g; b7 = b; } neoPort.write(byte(r0)); neoPort.write(byte(g0)); neoPort.write(byte(b0)); neoPort.write(byte(r1)); neoPort.write(byte(g1)); neoPort.write(byte(b1)); neoPort.write(byte(r2)); neoPort.write(byte(g2)); neoPort.write(byte(b2)); neoPort.write(byte(r3)); neoPort.write(byte(g3)); neoPort.write(byte(b3)); neoPort.write(byte(r4)); neoPort.write(byte(g4)); neoPort.write(byte(b4)); neoPort.write(byte(r5)); neoPort.write(byte(g5)); neoPort.write(byte(b5)); neoPort.write(byte(r6)); neoPort.write(byte(g6)); neoPort.write(byte(b6)); neoPort.write(byte(r7)); neoPort.write(byte(g7)); neoPort.write(byte(b7)); } void keyPressed() { if (key == '1') { counter = 1; } else if (key == '2') { counter = 2; } else if (key == '3') { counter = 3; } else if (key == '4') { counter = 4; } else if (key == '5') { counter = 5; } else if (key == '6') { counter = 6; } else if (key == '7') { counter = 7; } else if (key == '8') { counter = 8; } } |
Thank you all for such an awesome class. I had a bitchin’ time.
🙂