Components and supplies
Multi-Turn Precision Potentiometer- 10k ohms (25 Turn)
Resistor 10k ohm
Resistor 100k ohm
WS2812 Neopixel string
Resistor 1k ohm
Arduino UNO
General Purpose Quad Op-Amp
Resistor 330 ohm
Tools and machines
Mill
Soldering iron (generic)
Apps and platforms
Arduino IDE
Proteus 8 Pro
Project description
Code
Orion_Box_290915.ino
c_cpp
Our first go at programmings
1/* LedStripRainbow: Example Arduino sketch that shows 2 * how to make a moving rainbow pattern on an 3 * Addressable RGB LED Strip from Pololu. 4 * 5 * To use this, you will need to plug an Addressable RGB LED 6 * strip from Pololu into pin 12. After uploading the sketch, 7 * you should see a moving rainbow. 8 */ 9 10#include <PololuLedStrip.h> 11 12 13// Create an ledStrip object and specify the pin it will use. 14PololuLedStrip<12> ledStrip; 15 16// Create a buffer for holding the colors (3 bytes per color). 17#define LED_COUNT 120 18rgb_color colors[LED_COUNT]; 19 20#define LOG_OUT 1 // use the log output function 21#define LIN_OUT 1 22#define OCTAVE 1 23#define FFT_N 32 // set to 256 point fft 24 25#include <FFT.h> // include the library 26 27int j = 0 ; 28int jLoop = 0 ; 29uint8_t k = 0 ; 30int iMode = 0 ; 31int iHue = 0 ; 32int iLum = 0 ; 33int z = 0 ; 34 35void setup() 36{ 37 pinMode(13, OUTPUT); 38 pinMode(3,OUTPUT); 39 pinMode(5,OUTPUT); 40 pinMode(6,OUTPUT); 41 42 Serial.begin(115200); // use the serial port 43 44 DIDR0 = 0x1F; // 0x01 turn off the digital input for adc0 45 randomSeed(analogRead(4)); 46} 47 48// Converts a color from HSV to RGB. 49// h is hue, as a number between 0 and 360. 50// s is the saturation, as a number between 0 and 255. 51// v is the value, as a number between 0 and 255. 52rgb_color hsvToRgb(uint16_t h, uint8_t s, uint8_t v) 53{ 54 uint8_t f = (h % 60) * 255 / 60; 55 uint8_t p = (255 - s) * (uint16_t)v / 255; 56 uint8_t q = (255 - f * (uint16_t)s / 255) * (uint16_t)v / 255; 57 uint8_t t = (255 - (255 - f) * (uint16_t)s / 255) * (uint16_t)v / 255; 58 uint8_t r = 0, g = 0, b = 0; 59 switch((h / 60) % 6){ 60 case 0: r = v; g = t; b = p; break; 61 case 1: r = q; g = v; b = p; break; 62 case 2: r = p; g = v; b = t; break; 63 case 3: r = p; g = q; b = v; break; 64 case 4: r = t; g = p; b = v; break; 65 case 5: r = v; g = p; b = q; break; 66 } 67 return (rgb_color){r, g, b}; 68} 69 70void loop(){ 71 while(1){ 72 iMode = analogRead(1)/4 ; 73 // Update the colors. 74// uint16_t time = millis() >> 2; 75 switch(iMode){ 76 case 0 ... 4 : // test patern 77 for(uint16_t i = 0; i < LED_COUNT; i++){ 78 byte x = (jLoop) - (i << 3); 79 colors[i] = hsvToRgb((uint32_t)x * 359 / 256, 255, iMode*50+50); 80 } 81 delay(iMode*5); 82 break; 83 case 16 ... 31 : // wave effect 84 for(uint16_t i = 19 ; i > 0 ; i--){ 85 byte x = ( iMode - 221 ) * 16 ; 86 colors[19-i] = colors[20-i]; 87 colors[20+i] = colors[19+i]; 88 colors[59-i] = colors[60-i]; 89 colors[60+i] = colors[59+i]; 90 colors[99-i] = colors[100-i]; 91 colors[100+i] = colors[99+i]; 92 } 93 k = (analogRead(4)/4) ; 94 if ( k > 100 ){ 95 iLum = k ; 96 } 97 iLum-- ; 98 colors[19] = hsvToRgb(analogRead(4)/4 , 255, iLum); 99 colors[20] = hsvToRgb(analogRead(4)/4 , 255, iLum); 100 colors[59] = hsvToRgb(analogRead(4)/4 , 255, iLum); 101 colors[60] = hsvToRgb(analogRead(4)/4 , 255, iLum); 102 colors[99] = hsvToRgb(analogRead(4)/4 , 255, iLum); 103 colors[100] = hsvToRgb(analogRead(4)/4 , 255, iLum); 104 delay(50); 105 break; 106 case 32 ... 47 : // random effect 107 for(uint16_t i = 0 ; i < LED_COUNT ; i++){ 108 colors[random(LED_COUNT)] = hsvToRgb(analogRead(4)/4 , 255, 50); 109 } 110 break; 111 case 48 ... 63 : // equaliser FFT display (first cut) 112 for(int i = 0; i < LED_COUNT; i++){ 113 colors[i].red =0 ; 114 colors[i].green =0 ; 115 colors[i].blue =0 ; 116 } 117 for (uint16_t i = 0 ; i < (FFT_N*2) ; i += 2) { // save 32 samples 118 fft_input[i] = analogRead(4) ; // put real data into even bins 119 fft_input[i+1] = 0; // set odd bins to 0 120 } 121 fft_window(); // window the data for better frequency response 122 fft_reorder(); // reorder the data before doing the fft 123 fft_run(); // process the data in the fft 124 fft_mag_log(); // take the output of the fft 125 fft_mag_lin(); // take the output of the fft 126 127 // z = ( fft_log_out[i]/16 ) 128// for (byte i = 3 ; i < FFT_N/2 ; i++) { 129 for (byte i = 0 ; i < 20 ; i++) { 130 z = fft_log_out[3] / 3 ; 131 if ( i < z ){ 132 colors[119-i].blue = 127 ; 133 } 134 z = fft_log_out[4] / 3 ; 135 if ( i < z ){ 136// colors[119-i].green = 127 ; 137 } 138 z = fft_log_out[5] / 3 ; 139 if ( i < z ){ 140// colors[119-i].red = 127 ; 141 } 142 z = fft_log_out[6] / 3 ; 143 if ( i < z ){ 144 colors[80+i].blue = 127 ; 145 } 146 z = fft_log_out[7] / 3 ; 147 if ( i < z ){ 148// colors[80+i].green = 127 ; 149 } 150 z = fft_log_out[8] / 3 ; 151 if ( i < z ){ 152// colors[80+i].red = 127 ; 153 } 154 z = fft_log_out[9] / 3 ; 155 if ( i < z ){ 156 colors[79-i].blue = 127 ; 157 } 158 z = fft_log_out[10] / 3 ; 159 if ( i < z ){ 160// colors[79-i].green = 127 ; 161 } 162 z = fft_log_out[11] / 3 ; 163 if ( i < z ){ 164// colors[79-i].red = 127 ; 165 } 166 z = fft_log_out[12] / 3 ; 167 if ( i < z ){ 168 colors[40+i].blue = 127 ; 169 } 170 z = fft_log_out[13] / 3 ; 171 if ( i < z ){ 172// colors[40+i].green = 127 ; 173 } 174 z = fft_log_out[14] / 3 ; 175 if ( i < z ){ 176// colors[40+i].red = 127 ; 177 } 178 z = fft_log_out[15] / 3 ; 179 if ( i < z ){ 180 colors[39-i].blue = 127 ; 181 } 182 z = fft_log_out[16] / 3 ; 183 if ( i < z ){ 184// colors[39-i].green = 127 ; 185 } 186 z = fft_log_out[17] / 3 ; 187 if ( i < z ){ 188// colors[39-i].red = 127 ; 189 } 190 z = fft_log_out[18] / 3 ; 191 if ( i < z ){ 192 colors[i].blue = 127 ; 193 } 194 z = fft_log_out[19] / 3 ; 195 if ( i < z ){ 196// colors[i].green = 127 ; 197 } 198 z = fft_log_out[21] / 3 ; 199 if ( i < z ){ 200// colors[i].red = 127 ; 201 } 202 } 203 switch(jLoop/42){ 204 case 0: 205 colors[19].red =255 ; 206 break; 207 case 1: 208 colors[20].red =255 ; 209 break; 210 case 2: 211 colors[59].red =255 ; 212 break; 213 case 3: 214 colors[60].red =255 ; 215 break; 216 case 4: 217 colors[99].red =255 ; 218 break; 219 case 5: 220 colors[100].red =255 ; 221 break; 222 } 223 break; 224 case 64 ... 79 : // color bars 225 for(uint16_t i = 0; i < 20; i++){ 226 int x = (((uint32_t)analogRead(4)/4 * 360 / 256 ) ) % 360 ; 227 colors[i] = hsvToRgb(x , 255, 255); 228 x = (((uint32_t)analogRead(4)/4 * 360 / 256 ) +(360/6 )) % 360 ; 229 colors[i+20] = hsvToRgb(x , 255, 255); 230 x = (((uint32_t)analogRead(4)/4 * 360 / 256 )+ (360/6*2 )) % 360 ; 231 colors[i+40] = hsvToRgb(x , 255, 255); 232 x = (((uint32_t)analogRead(4)/4 * 360 / 256 )+ (360/6*3 ) ) % 360 ; 233 colors[i+60] = hsvToRgb(x , 255, 255); 234 x = (((uint32_t)analogRead(4)/4 * 360 / 256 )+ (360/6*4 ) ) % 360 ; 235 colors[i+80] = hsvToRgb(x , 255, 255); 236 x = (((uint32_t)analogRead(4)/4 * 360 / 256 )+ (360/6*5 ) ) % 360 ; 237 colors[i+100] = hsvToRgb(x , 255, 255); 238 } 239 break; 240 case 80 ... 87 : // color moving 241 for(uint16_t i = 0; i < 20; i++){ 242 int x = (((uint32_t)analogRead(4)/4 * 360 / 256 ) + ((uint32_t)(i * 360 ) / 19 )) % 360 ; 243 colors[i] = hsvToRgb(x , 255, 150); 244 colors[39-i] = hsvToRgb(x , 255, 100); 245 colors[i+40] = hsvToRgb(x , 255, 75); 246 colors[79-i] = hsvToRgb(x , 255, 50); 247 colors[i+80] = hsvToRgb(x , 255, 25); 248 colors[119-i] = hsvToRgb(x , 255, 10); 249 } 250 break; 251 case 88 ... 95 : // color moving 252 for(uint16_t i = 0; i < 20; i++){ 253 int x = (((uint32_t)jLoop * 360 / 256 ) + ((uint32_t)(i * 360 ) / 19 )) % 360 ; 254 colors[i] = hsvToRgb(x , 255, 150); 255 colors[39-i] = colors[i]; 256 colors[i+40] = colors[i]; 257 colors[79-i] = colors[i]; 258 colors[i+80] = colors[i]; 259 colors[119-i] = colors[i]; 260 } 261 break; 262 case 96 ... 111: // god knows 263 k = (analogRead(4)/4) ; 264 if ( k < 50 ){ 265 iHue++ ; 266 if (iHue > 255){ 267 iHue = 0 ; 268 } 269 } 270 if ( k > 100 ){ 271 iLum = k ; 272 } 273 iLum-- ; 274 if ( iLum < 0 ){ 275 iLum = 0 ; 276 } 277 if ( k < 0 ){ 278 k = 0 ; 279 } 280 colors[0] = hsvToRgb(iHue , 255, iLum ); 281 for(uint16_t i = 1 ; i < LED_COUNT ; i++){ 282 colors[i] = colors[0]; 283 } 284 break; 285 case 205 ... 220 : // sparkles 286 for(uint16_t i = 0; i < LED_COUNT; i++){ 287 colors[i].red =0 ; 288 colors[i].green =0 ; 289 colors[i].blue =0 ; 290 } 291 k = (analogRead(4)/5) ; // should be 8 ???? 292 if ((k<120) && (k > 0) ) { 293 colors[k] = hsvToRgb(jLoop , 255, 255); 294 } 295 break; 296 case 221 ... 238 : // solid color 297 for(uint16_t i = 0; i < LED_COUNT; i++){ 298 byte x = ( iMode - 221 ) * 16 ; 299 colors[i] = hsvToRgb((uint32_t)x , 255, 255); 300 } 301 break; 302 case 239 ... 256 : // white light - work light 303 for(uint16_t i = 0; i < LED_COUNT; i++){ 304 k = (( iMode - 238 ) * 15 ) ; 305 colors[i].red = k ; 306 colors[i].blue = k ; 307 colors[i].green = k ; 308 } 309 break; 310 default: 311 Serial.print(jLoop) ; 312 Serial.println(" no Mode"); 313 for(uint16_t i = 0; i < LED_COUNT; i++){ 314 colors[i].red = 0 ; 315 colors[i].blue = 0 ; 316 colors[i].green = 0 ; 317 } 318 break; 319 } 320 // Write the colors to the LED strip. 321 ledStrip.write(colors, LED_COUNT); 322 analogWrite(5, analogRead(4)/4); // speaker leds 323 324 if ( jLoop > 127 ){ // flash the built in Arduino board 325 digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) 326 }else{ // wait for a second 327 digitalWrite(13, LOW); // turn the LED off by making the voltage LOW 328 } // wait for a second 329 if ( jLoop > 255 ){ 330 jLoop=0 ; 331 } 332 jLoop++ ; 333 } 334} 335
Downloadable files
Boom box amplifier schematic
Grand designs bit in the end we only loaded a fraction of the circuit
Boom box amplifier schematic
Boom box amplifier schematic
Grand designs bit in the end we only loaded a fraction of the circuit
Boom box amplifier schematic
Documentation
Circuit Board made from the circuit
Circuit Board made from the circuit
Circuit Board made from the circuit
Circuit Board made from the circuit
Comments
Only logged in users can leave comments
dougal
0 Followers
•0 Projects
+1
Work attribution
Table of contents
Intro
5
0