Components and supplies
1
Teensy 3.5
Tools and machines
1
3D Printer (generic)
Project description
Code
LED Gyro Sphere
c_cpp
A unique, cool interactive LED Sphere using a Gyro and Sound sensors create a colorful fun interactive gadget.
1/* LED Gyro Sphere Teesy - TechKiwiGadgets Feb 2018 2 * 3 * V5 - Major Update of Hardware and Capability 4 * Addition of Teensy 3.6 5 * Upgrade Power Pack to 4400mha 6 * Reposition Gyro to ensure aligned to horizontal access when stationary 7 */ 8 9/* ============================================ 10I2Cdev device library code is placed under the MIT license 11Copyright (c) 2012 Jeff Rowberg 12 13Permission is hereby granted, free of charge, to any person obtaining a copy 14of this software and associated documentation files (the "Software"), to deal 15in the Software without restriction, including without limitation the rights 16to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17copies of the Software, and to permit persons to whom the Software is 18furnished to do so, subject to the following conditions: 19 20The above copyright notice and this permission notice shall be included in 21all copies or substantial portions of the Software. 22 23THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29THE SOFTWARE. 30=============================================== 31*/ 32 33 34#include <Audio.h> 35#include <SPI.h> 36#include <SD.h> 37#include <SerialFlash.h> 38 39// GUItool: begin automatically generated code 40AudioInputAnalog adc1; //xy=164,95 41AudioAnalyzePeak peak1; //xy=317,123 42AudioConnection patchCord1(adc1, peak1); 43 44 45 46 47//********************************************************** 48 // MPU-6050 Short Example Sketch 49// By Arduino User JohnChi 50// August 17, 2014 51// Public Domain 52#include<Wire.h> 53 54 55const int MPU_addr=0x68; // I2C address of the MPU-6050 56int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ; 57 58// WS2182 LED Driver Library Setup ************************************************************************* 59#include "FastLED.h" 60// How many leds in your strip? 61#define NUM_LEDS 130 // Note: First LED is address 0 62#define DATA_PIN 33 // Note: Teensy D33 used to control LED chain 63#define FASTLED_ALLOW_INTERRUPTS 0 64 65int t1 = 20; // Delay in Milliseconds for startup routine 66 67// Define the array of leds 68CRGB leds[NUM_LEDS]; 69 70// Smoothing Variables for LPF 71const float alpha = 0.98; 72int smoothedX = 17000; 73int smoothedY = 1000; 74int smoothedZ = 10; 75int gX = 57; // Pointer for Menu 5 option first LED on Xaxis in centre 76int gY = 0; // Pointer for Menu 5 option 77 78int i = 0; // Spiral variable 79 80int xb; 81int yb; 82int zb; 83 84int mic = 0; // Mic value read from A12 85int soundthreshold = 20; // Minimum level threshold for fisr LED 86int monoPeak = 0; // Measure of Peak input Audio 87int td = 120; // Sound delay variable 88int tsr = 224; // Sound delay variable 89int sr1 = 300; // Delay in SoundRing 90int srctr = 0; // Soundring counter 91int srs = 200; // Sound Ring Delay 92int nctr = 9; // Count down digits to zero 93 94int Znum; // color digits 95 96int clr4; 97int clr5; 98int clr6; 99 100#define DC_OFFSET 0 // DC offset in mic signal 101 102 103int Xdiff = 0; // Used to track the difference between baselib=ne Gyro and current readings 104int Ydiff = 0; 105int Zdiff = 0; 106 107int osX = 18000; // This is Gyro Offset 108int osY = 18000; // This is Gyro Offset 109int osZ = 18000; // This is Gyro Offset range of -17700 to 15200 therefore normalised to 32900 range by adding 17700 110 111 112float josX = 0.014; // Used to convert Gyro outputs to number below 255 113float josY = 0.014; // Used to convert Gyro outputs to number below 255 114float josZ = 0.014; // Used to convert Gyro outputs to number below 255 115 116int Xcol = 0; // Final Gyro Color value 117int Ycol = 0; // Final Gyro Color value 118int Zcol = 0; // Final Gyro Color value 119 120int Xvar = 0; // Variation from baseline 121int Yvar = 0; // Variation from baseline 122int Zvar = 0; // Variation from baseline 123 124/* 1258. X Plane unit of change 1093.75 1268. Y Plane unit of change 1750 1278. Z Plane unit of change 1750 128*/ 129int Xinc = 1094; // Incremental value for each LED transition 130int Yinc = 1750; // Incremental value for each LED transition 131int Zinc = 1750; // Incremental value for each LED transition 132 133int Xnormalise; 134int Ynormalise; 135int Znormalise; 136 137// Menu Selection 138int menu = 1; // Random Dot Pattern 139 140int direct; // Temp direction variable 141 142int g = 0; // Scratch variable 143int d1 = 50; // Delay for LED effects 144int d2 = 2000; // Delay for LED effects 145int d4 = 500; // Delay for LED effects 146int d5 = 200; // Delay for LED effects 147int d6 = 2000; // Delay for LED effects 148boolean cal = false; // Callibrate delay 149 150/* Dot Snakes Array int dot[4][5] = { // Setup Location for 4 Dot Snakes 4 dots long 151 * Dot Arrays track location of a item 152 Dot number identifier for each Dot 153 0. LED Position = 0-129 154 1. Current Direction = 0-7 155 2. Prev Position = 0-129 156 3. Prev Prev Position= 1-129 1570 = Up 1581 = Up Right 1592 = Right 1603 = Down Right 1614 = Down 1625 = Down Left 1636 = Left 1647 = Up Left 165*/ 166int dot[4][5] = { // Setup Location for 4 Dot Snakes 4 dots long 167 {5 , 5, 18, 34, 50}, 168 {1 , 5, 10, 26, 42}, 169 {126 , 0, 117, 101, 85}, 170 {122 , 0, 108, 92, 76} 171 172}; 173 174 175int dt = 0; // Setup Location for dot on top 176 177 178// Setup array for Sound bar graph 179 180/* Dot Arrays track location of a item 181 Dot number identifier for each Dot 182 0. LED Position = 0-129 183 1. Current Direction = 0-7 184 2. Prev Position = 0-129 185 3. Prev Prev Position= 1-129 1860 = Up 1871 = Up Right 1882 = Right 1893 = Down Right 1904 = Down 1915 = Down Left 1926 = Left 1937 = Up Left 194*/ 195 196int sb[10] = {0, 1, 9, 25, 41, 57, 73, 89}; // Used for Sound Effect 197int scntr = 0; // Counts the incremetal change around the sound effect (16 locations) 198 199/* ************************************************************************ 200 * The pixel Array carries the Coordinates of each LED in sequential order 201LED Position 2020 = Up 2031 = Up Right 2042 = Right 2053 = Down Right 2064 = Down 2075 = Down Left 2086 = Left 2097 = Up Left 2108 = LED Row Number 2119 = LED Row Position Number 21210 - X Axis Gyro Ref 21311 - Y Axis Gyro Ref 21412 - Z Axis Gyro Ref 215**************************************************************************** 216*/ 217 218const int pixel[130][13] = { 219{ 5 , 6 , 7 , 8 , 1 , 2 , 3 , 4 , 1 , 1 , 17668 , 18042 , 26 }, 220{ 0 , 7 , 8 , 9 , 10 , 11 , 2 , 3 , 2 , 1 , 13593 , 19330 , 945 }, 221{ 0 , 8 , 1 , 11 , 12 , 13 , 3 , 4 , 2 , 2 , 12765 , 14870 , 1500 }, 222{ 0 , 1 , 2 , 13 , 14 , 15 , 4 , 5 , 2 , 3 , 16290 , 12859 , 1015 }, 223{ 0 , 2 , 3 , 15 , 16 , 17 , 5 , 6 , 2 , 4 , 19352 , 12049 , 1121 }, 224{ 0 , 3 , 4 , 17 , 18 , 19 , 6 , 7 , 2 , 5 , 21402 , 15641 , 303 }, 225{ 0 , 4 , 5 , 19 , 20 , 21 , 7 , 8 , 2 , 6 , 22739 , 17763 , 390 }, 226{ 0 , 5 , 6 , 21 , 22 , 23 , 8 , 1 , 2 , 7 , 20164 , 20767 , 218 }, 227{ 0 , 6 , 7 , 23 , 24 , 9 , 1 , 2 , 2 , 8 , 16480 , 21065 , 399 }, 228{ 1 , 8 , 24 , 40 , 25 , 26 , 10 , 1 , 3 , 1 , 11649 , 22517 , 2345 }, 229{ 1 , 8 , 9 , 25 , 26 , 27 , 11 , 2 , 3 , 2 , 9928 , 18712 , 2667 }, 230{ 2 , 1 , 10 , 26 , 27 , 28 , 12 , 2 , 3 , 3 , 8984 , 15608 , 3558 }, 231{ 2 , 1 , 11 , 27 , 28 , 29 , 13 , 3 , 3 , 4 , 10660 , 11850 , 3618 }, 232{ 3 , 2 , 12 , 28 , 29 , 30 , 14 , 3 , 3 , 5 , 13153 , 9570 , 3496 }, 233{ 3 , 2 , 13 , 29 , 30 , 31 , 15 , 4 , 3 , 6 , 15628 , 7918 , 3836 }, 234{ 4 , 3 , 14 , 30 , 31 , 32 , 16 , 4 , 3 , 7 , 19982 , 7107 , 4119 }, 235{ 4 , 3 , 15 , 31 , 32 , 33 , 17 , 5 , 3 , 8 , 23846 , 8620 , 3852 }, 236{ 5 , 4 , 16 , 32 , 33 , 34 , 18 , 5 , 3 , 9 , 25987 , 10631 , 3521 }, 237{ 5 , 4 , 17 , 33 , 34 , 35 , 19 , 6 , 3 , 10 , 28716 , 13866 , 3929 }, 238{ 6 , 5 , 18 , 34 , 35 , 36 , 20 , 6 , 3 , 11 , 29138 , 18636 , 3572 }, 239{ 6 , 5 , 19 , 35 , 36 , 37 , 21 , 7 , 3 , 12 , 27845 , 22257 , 3311 }, 240{ 7 , 6 , 20 , 36 , 37 , 38 , 22 , 7 , 3 , 13 , 25448 , 24727 , 2888 }, 241{ 7 , 6 , 21 , 37 , 38 , 39 , 23 , 8 , 3 , 14 , 22405 , 27379 , 3368 }, 242{ 8 , 7 , 22 , 38 , 39 , 40 , 24 , 8 , 3 , 15 , 17686 , 27918 , 3383 }, 243{ 8 , 7 , 23 , 39 , 40 , 25 , 25 , 1 , 3 , 16 , 14693 , 26495 , 2947 }, 244{ 9 , 24 , 40 , 56 , 41 , 42 , 26 , 10 , 4 , 1 , 7984 , 26491 , 7655 }, 245{ 10 , 9 , 25 , 41 , 42 , 43 , 27 , 11 , 4 , 2 , 5486 , 21616 , 8131 }, 246{ 11 , 10 , 26 , 42 , 43 , 44 , 28 , 12 , 4 , 3 , 4951 , 16152 , 8431 }, 247{ 12 , 11 , 27 , 43 , 44 , 45 , 29 , 13 , 4 , 4 , 6181 , 10996 , 9020 }, 248{ 13 , 12 , 28 , 44 , 45 , 46 , 30 , 14 , 4 , 5 , 10314 , 6130 , 9348 }, 249{ 14 , 13 , 29 , 45 , 46 , 47 , 31 , 15 , 4 , 6 , 15265 , 3892 , 9042 }, 250{ 15 , 14 , 30 , 46 , 47 , 48 , 32 , 16 , 4 , 7 , 20306 , 3185 , 9537 }, 251{ 16 , 15 , 31 , 47 , 48 , 49 , 33 , 17 , 4 , 8 , 24925 , 5285 , 8163 }, 252{ 17 , 16 , 32 , 48 , 49 , 50 , 34 , 18 , 4 , 9 , 29639 , 9193 , 7858 }, 253{ 18 , 17 , 33 , 49 , 50 , 51 , 35 , 19 , 4 , 10 , 30917 , 14042 , 6045 }, 254{ 19 , 18 , 34 , 50 , 51 , 52 , 36 , 20 , 4 , 11 , 32324 , 18572 , 7309 }, 255{ 20 , 19 , 35 , 51 , 52 , 53 , 37 , 21 , 4 , 12 , 30890 , 23910 , 6993 }, 256{ 21 , 20 , 36 , 52 , 53 , 54 , 38 , 22 , 4 , 13 , 27434 , 28469 , 7035 }, 257{ 22 , 21 , 37 , 53 , 54 , 55 , 39 , 23 , 4 , 14 , 22328 , 30706 , 6511 }, 258{ 23 , 22 , 38 , 54 , 55 , 56 , 40 , 24 , 4 , 15 , 16781 , 30311 , 5820 }, 259{ 24 , 23 , 39 , 55 , 56 , 41 , 25 , 9 , 4 , 16 , 12755 , 28610 , 5479 }, 260{ 25 , 40 , 56 , 72 , 57 , 58 , 42 , 26 , 5 , 1 , 7799 , 28586 , 10753 }, 261{ 26 , 25 , 41 , 57 , 58 , 59 , 43 , 27 , 5 , 2 , 4003 , 21932 , 11245 }, 262{ 27 , 26 , 42 , 58 , 59 , 60 , 44 , 28 , 5 , 3 , 3408 , 17574 , 11295 }, 263{ 28 , 27 , 43 , 59 , 60 , 61 , 45 , 29 , 5 , 4 , 5198 , 11321 , 10979 }, 264{ 29 , 28 , 44 , 60 , 61 , 62 , 46 , 30 , 5 , 5 , 8799 , 5897 , 12116 }, 265{ 30 , 29 , 45 , 61 , 62 , 63 , 47 , 31 , 5 , 6 , 12895 , 3152 , 13187 }, 266{ 31 , 30 , 46 , 62 , 63 , 64 , 48 , 32 , 5 , 7 , 20472 , 2534 , 11456 }, 267{ 32 , 31 , 47 , 63 , 64 , 65 , 49 , 33 , 5 , 8 , 26325 , 4099 , 11774 }, 268{ 33 , 32 , 48 , 64 , 65 , 66 , 50 , 34 , 5 , 9 , 30549 , 8117 , 10717 }, 269{ 34 , 33 , 49 , 65 , 66 , 67 , 51 , 35 , 5 , 10 , 33015 , 12909 , 9971 }, 270{ 35 , 34 , 50 , 66 , 67 , 68 , 52 , 36 , 5 , 11 , 34328 , 19320 , 11192 }, 271{ 36 , 35 , 51 , 67 , 68 , 69 , 53 , 37 , 5 , 12 , 32750 , 24373 , 10762 }, 272{ 37 , 36 , 52 , 68 , 69 , 70 , 54 , 38 , 5 , 13 , 29723 , 28479 , 10794 }, 273{ 38 , 37 , 53 , 69 , 70 , 71 , 55 , 39 , 5 , 14 , 24231 , 32195 , 10756 }, 274{ 39 , 38 , 54 , 70 , 71 , 72 , 56 , 40 , 5 , 15 , 17745 , 33361 , 11558 }, 275{ 40 , 39 , 55 , 71 , 72 , 57 , 41 , 25 , 5 , 16 , 12228 , 31904 , 12098 }, 276{ 41 , 56 , 72 , 88 , 73 , 74 , 58 , 42 , 6 , 1 , 6691 , 28206 , 14789 }, 277{ 42 , 41 , 57 , 73 , 74 , 75 , 59 , 43 , 6 , 2 , 3615 , 23581 , 15638 }, 278{ 43 , 42 , 58 , 74 , 75 , 76 , 60 , 44 , 6 , 3 , 3043 , 17960 , 16378 }, 279{ 44 , 43 , 59 , 75 , 76 , 77 , 61 , 45 , 6 , 4 , 4318 , 12204 , 15523 }, 280{ 45 , 44 , 60 , 76 , 77 , 78 , 62 , 46 , 6 , 5 , 6727 , 7996 , 15721 }, 281{ 46 , 45 , 61 , 77 , 78 , 79 , 63 , 47 , 6 , 6 , 11867 , 3456 , 15325 }, 282{ 47 , 46 , 62 , 78 , 79 , 80 , 64 , 48 , 6 , 7 , 17541 , 2218 , 15737 }, 283{ 48 , 47 , 63 , 79 , 80 , 81 , 65 , 49 , 6 , 8 , 24905 , 3359 , 16112 }, 284{ 49 , 48 , 64 , 80 , 81 , 82 , 66 , 50 , 6 , 9 , 30165 , 6733 , 14977 }, 285{ 50 , 49 , 65 , 81 , 82 , 83 , 67 , 51 , 6 , 10 , 34142 , 13037 , 15350 }, 286{ 51 , 50 , 66 , 82 , 83 , 84 , 68 , 52 , 6 , 11 , 34749 , 18118 , 14834 }, 287{ 52 , 51 , 67 , 83 , 84 , 85 , 69 , 53 , 6 , 12 , 33417 , 24448 , 14899 }, 288{ 53 , 52 , 68 , 84 , 85 , 86 , 70 , 54 , 6 , 13 , 29458 , 30060 , 14355 }, 289{ 54 , 53 , 69 , 85 , 86 , 87 , 71 , 55 , 6 , 14 , 25152 , 32749 , 14340 }, 290{ 55 , 54 , 70 , 86 , 87 , 88 , 72 , 56 , 6 , 15 , 17874 , 33799 , 14465 }, 291{ 56 , 55 , 71 , 87 , 88 , 73 , 57 , 41 , 6 , 16 , 12293 , 32446 , 14952 }, 292{ 57 , 72 , 88 , 104 , 89 , 90 , 74 , 58 , 7 , 1 , 5086 , 25927 , 19638 }, 293{ 58 , 57 , 73 , 89 , 90 , 91 , 75 , 59 , 7 , 2 , 3880 , 22322 , 19960 }, 294{ 59 , 58 , 74 , 90 , 91 , 92 , 76 , 60 , 7 , 3 , 3236 , 15215 , 19354 }, 295{ 60 , 59 , 75 , 91 , 92 , 93 , 77 , 61 , 7 , 4 , 6407 , 8345 , 19193 }, 296{ 61 , 60 , 76 , 92 , 93 , 94 , 78 , 62 , 7 , 5 , 12490 , 4134 , 21831 }, 297{ 62 , 61 , 77 , 93 , 94 , 95 , 79 , 63 , 7 , 6 , 21073 , 2166 , 19120 }, 298{ 63 , 62 , 78 , 94 , 95 , 96 , 80 , 64 , 7 , 7 , 26857 , 4681 , 20849 }, 299{ 64 , 63 , 79 , 95 , 96 , 97 , 81 , 65 , 7 , 8 , 30594 , 7112 , 19188 }, 300{ 65 , 64 , 80 , 96 , 97 , 98 , 82 , 66 , 7 , 9 , 34260 , 13248 , 19078 }, 301{ 66 , 65 , 81 , 97 , 98 , 99 , 83 , 67 , 7 , 10 , 34359 , 22135 , 19412 }, 302{ 67 , 66 , 82 , 98 , 99 , 100 , 84 , 68 , 7 , 11 , 31790 , 27246 , 20214 }, 303{ 68 , 67 , 83 , 99 , 100 , 101 , 85 , 69 , 7 , 12 , 30688 , 27752 , 21846 }, 304{ 69 , 68 , 84 , 100 , 101 , 102 , 86 , 70 , 7 , 13 , 23430 , 33203 , 20115 }, 305{ 70 , 69 , 85 , 101 , 102 , 103 , 87 , 71 , 7 , 14 , 16897 , 34111 , 18241 }, 306{ 71 , 70 , 86 , 102 , 103 , 104 , 88 , 72 , 7 , 15 , 10035 , 31373 , 18584 }, 307{ 72 , 71 , 87 , 103 , 104 , 89 , 73 , 57 , 7 , 16 , 7134 , 28538 , 20044 }, 308{ 73 , 88 , 104 , 120 , 105 , 106 , 90 , 74 , 8 , 1 , 7873 , 26821 , 24225 }, 309{ 74 , 73 , 89 , 105 , 106 , 107 , 91 , 75 , 8 , 2 , 5306 , 22175 , 23077 }, 310{ 75 , 74 , 90 , 106 , 107 , 108 , 92 , 76 , 8 , 3 , 6201 , 16463 , 25588 }, 311{ 76 , 75 , 91 , 107 , 108 , 109 , 93 , 77 , 8 , 4 , 8490 , 13819 , 27891 }, 312{ 77 , 76 , 92 , 108 , 109 , 110 , 94 , 78 , 8 , 5 , 14794 , 5323 , 25643 }, 313{ 78 , 77 , 93 , 109 , 110 , 111 , 95 , 79 , 8 , 6 , 18490 , 5394 , 26483 }, 314{ 79 , 78 , 94 , 110 , 111 , 112 , 96 , 80 , 8 , 7 , 23016 , 6832 , 27352 }, 315{ 80 , 79 , 95 , 111 , 112 , 113 , 97 , 81 , 8 , 8 , 29410 , 9423 , 25387 }, 316{ 81 , 80 , 96 , 112 , 113 , 114 , 98 , 82 , 8 , 9 , 31652 , 13833 , 25081 }, 317{ 82 , 81 , 97 , 113 , 114 , 115 , 99 , 83 , 8 , 10 , 32588 , 19987 , 24888 }, 318{ 83 , 82 , 98 , 114 , 115 , 116 , 100 , 84 , 8 , 11 , 30446 , 26981 , 23327 }, 319{ 84 , 83 , 99 , 115 , 116 , 117 , 101 , 85 , 8 , 12 , 23286 , 31892 , 23080 }, 320{ 85 , 84 , 100 , 116 , 117 , 118 , 102 , 86 , 8 , 13 , 15759 , 31983 , 23686 }, 321{ 86 , 85 , 101 , 117 , 118 , 119 , 103 , 87 , 8 , 14 , 11992 , 30739 , 23612 }, 322{ 87 , 86 , 102 , 118 , 119 , 120 , 104 , 88 , 8 , 15 , 7613 , 28001 , 22028 }, 323{ 88 , 87 , 103 , 119 , 120 , 105 , 89 , 73 , 8 , 16 , 5508 , 18301 , 25441 }, 324{ 89 , 104 , 120 , 128 , 128 , 121 , 106 , 90 , 9 , 1 , 10407 , 17869 , 30098 }, 325{ 90 , 89 , 105 , 128 , 121 , 122 , 107 , 91 , 9 , 2 , 11177 , 16045 , 30448 }, 326{ 91 , 90 , 106 , 121 , 121 , 122 , 108 , 92 , 9 , 3 , 12933 , 12240 , 30229 }, 327{ 92 , 91 , 107 , 121 , 122 , 123 , 109 , 93 , 9 , 4 , 15426 , 10243 , 29959 }, 328{ 93 , 92 , 108 , 122 , 122 , 123 , 110 , 94 , 9 , 5 , 18541 , 9647 , 29972 }, 329{ 94 , 93 , 109 , 122 , 123 , 124 , 111 , 95 , 9 , 6 , 21995 , 11101 , 30517 }, 330{ 95 , 94 , 110 , 123 , 123 , 124 , 112 , 96 , 9 , 7 , 24772 , 13965 , 30775 }, 331{ 96 , 95 , 111 , 123 , 124 , 125 , 113 , 97 , 9 , 8 , 26122 , 17802 , 30895 }, 332{ 97 , 96 , 112 , 124 , 124 , 125 , 114 , 98 , 9 , 9 , 27284 , 20536 , 30144 }, 333{ 98 , 97 , 113 , 124 , 125 , 126 , 115 , 99 , 9 , 10 , 25751 , 23164 , 30278 }, 334{ 99 , 98 , 114 , 125 , 125 , 126 , 116 , 100 , 9 , 11 , 24160 , 23624 , 30835 }, 335{ 100 , 99 , 115 , 125 , 126 , 127 , 117 , 101 , 9 , 12 , 22398 , 25482 , 30374 }, 336{ 101 , 100 , 116 , 126 , 126 , 127 , 118 , 102 , 9 , 13 , 18869 , 26657 , 29832 }, 337{ 102 , 101 , 117 , 126 , 127 , 128 , 119 , 103 , 9 , 14 , 16163 , 26034 , 29940 }, 338{ 103 , 102 , 118 , 127 , 127 , 128 , 120 , 104 , 9 , 15 , 12348 , 23941 , 29748 }, 339{ 104 , 103 , 119 , 127 , 128 , 121 , 105 , 89 , 9 , 16 , 10088 , 24052 , 28396 }, 340{ 106 , 105 , 128 , 127 , 129 , 123 , 122 , 107 , 10 , 1 , 14631 , 20420 , 31622 }, 341{ 108 , 107 , 121 , 128 , 129 , 124 , 123 , 109 , 10 , 2 , 17492 , 18135 , 32370 }, 342{ 110 , 109 , 122 , 121 , 129 , 125 , 124 , 111 , 10 , 3 , 23254 , 15567 , 31552 }, 343{ 112 , 111 , 123 , 122 , 129 , 126 , 125 , 113 , 10 , 4 , 25852 , 18745 , 30702 }, 344{ 114 , 113 , 124 , 123 , 129 , 127 , 126 , 115 , 10 , 5 , 24787 , 21138 , 30845 }, 345{ 116 , 115 , 125 , 124 , 129 , 128 , 127 , 117 , 10 , 6 , 23662 , 24538 , 30109 }, 346{ 118 , 117 , 126 , 125 , 129 , 121 , 128 , 119 , 10 , 7 , 21269 , 25859 , 30134 }, 347{ 120 , 119 , 127 , 126 , 129 , 122 , 121 , 105 , 10 , 8 , 17778 , 25113 , 30673 }, 348{ 121 , 128 , 127 , 126 , 125 , 124 , 123 , 122 , 11 , 1 , 20604 , 19047 , 32659 } 349 350 }; 351 352elapsedMillis fps; 353 354void setup(){ 355 AudioMemory(4); 356 Wire.begin(); 357 Wire.beginTransmission(MPU_addr); 358 Wire.write(0x6B); // PWR_MGMT_1 register 359 Wire.write(0); // set to zero (wakes up the MPU-6050) 360 Wire.endTransmission(true); 361 Serial.begin(115200); 362 363 // WS2182 LED Driver Setup 364 LEDS.addLeds<WS2812,DATA_PIN,GRB>(leds,NUM_LEDS).setCorrection( TypicalLEDStrip ); // Default if RGB for this however may vary dependent on LED manufacturer 365 LEDS.setBrightness(5); //Set brightness of LEDs here 366 // limit my draw to 1A at 5v of power draw 367 FastLED.setMaxPowerInVoltsAndMilliamps(5,100); 368 369 FastLED.setDither(0); // Turns of Auto Dithering function to remove flicker 370 371 // Setup Input Mode and Select Push Buttons 372 pinMode(34,INPUT_PULLUP); // Mode Button 373 pinMode(35,INPUT_PULLUP); // Mode Button 374 375 // Clear LEDs 376 for (int g = 0; g < 10; g++) { 377 leds[g] = CRGB::Black; 378 FastLED.show(); 379 } 380 381 382clearsphere(); // Clear any LEDs left over from reset 383 384} 385 386void loop(){ 387 388buttoncheck(); // Check for user input 389 390 Wire.beginTransmission(MPU_addr); 391 Wire.write(0x3B); // starting with register 0x3B (GYRO_XOUT_H) 392 Wire.endTransmission(false); 393 Wire.requestFrom(MPU_addr,6,true); // request a total of 6 registers 394 395 /* 396 AcX=Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L) 397 AcY=Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L) 398 AcZ=Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L) 399 Tmp=Wire.read()<<8|Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L) 400 GyX=Wire.read()<<8|Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L) 401 GyY=Wire.read()<<8|Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L) 402 GyZ=Wire.read()<<8|Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L) 403*/ 404 405 GyX=Wire.read()<<8|Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L) 406 GyY=Wire.read()<<8|Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L) 407 GyZ=Wire.read()<<8|Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L) 408 409 410// Apply Low Pass Filter to signal to smooth output from MPU 6050 411 smoothedX = (alpha * smoothedX) + ( (1 - alpha) * GyX); 412 smoothedY = (alpha * smoothedY) + ( (1 - alpha) * GyY); 413 smoothedZ = (alpha * smoothedZ) + ( (1 - alpha) * GyZ); 414 415// Apply filter to MIC output 416 mic = abs(analogRead(A12)-DC_OFFSET); 417 418 419// Calculate final Gyro Colors for XYZ to RGB 420 421if (abs(smoothedX)*josX < 256) { 422 Xcol = abs(smoothedX)*josX; 423} else { 424 Xcol = 20; 425} 426 427if (abs(smoothedY)*josY < 256) { 428 Ycol = abs(smoothedY)*josY; 429} else { 430 Ycol = 20; 431} 432 433if (abs(smoothedZ)*josZ < 256) { 434 Zcol = abs(smoothedZ)*josZ; 435} else { 436 Zcol = 20; 437} 438 439 440// Znum = abs(GyX)*josX; // color for digits 441Znum = 160; // Number for Blue 442 443/* At last a stable Audio input circuit !! A2 connected to 0.1uf and SP1 on freetronics Mic 444 445 if (fps > 24) { 446 if (peak1.available()) { 447 fps = 0; 448 int monoPeak = peak1.read() * 10.0; 449 Serial.print("|"); 450 for (int cnt=0; cnt<monoPeak; cnt++) { 451 Serial.print(">"); 452 } 453 Serial.println(); 454 } 455 } 456*/ 457 458/* 459 Serial.print("AcX = "); Serial.print(AcX); 460 Serial.print(" | AcY = "); Serial.print(AcY); 461 Serial.print(" | AcZ = "); Serial.print(AcZ); 462 Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53); //equation for temperature in degrees C from datasheet 463 Serial.print(" | GyX = "); Serial.print(GyX); 464 Serial.print(" | GyY = "); Serial.print(GyY); 465 Serial.print(" | GyZ = "); Serial.println(GyZ); 466 467 468 469 Serial.print(" . Xcol "); 470 Serial.print(abs(smoothedX)*josX); 471 Serial.print(" . Ycol "); 472 Serial.print(abs(smoothedY)*josY); 473 Serial.print(" . Zcol. "); 474 Serial.println(abs(smoothedZ)*josZ); 475 476 477 478 Serial.print(" . Xb "); 479 Serial.print(xb); 480 Serial.print(" . sX "); 481 Serial.print(abs(smoothedX)); 482 Serial.print(" . gX. "); 483 Serial.print(dt); 484 485 Serial.print(" . Yb. "); 486 Serial.print(yb); 487 Serial.print(" . sY "); 488 Serial.print(abs(smoothedY)); 489 Serial.print(" . gY "); 490 Serial.print(dt); 491 492 Serial.print(" . Zb . "); 493 Serial.print(zb); 494 Serial.print(" . sZ "); 495 Serial.print(abs(smoothedZ)); 496 Serial.print(" . gZ "); 497 Serial.println(dt); 498 499 Serial.print(" . Mic . "); 500Serial.print(mic); 501 Serial.print(" . SMic . "); 502 Serial.print(smoothmic); 503 Serial.print(" . . "); 504 Serial.print(soundot[0]); 505 Serial.print(" . . "); 506 Serial.print(soundot[1]); 507 Serial.print(" . . "); 508 Serial.print(soundot[2]); 509 Serial.print(" . . "); 510 Serial.println(soundot[3]); 511 512*/ 513 514 515 516// delay(20); 517 518 Serial.println(monoPeak); 519 520 521 if (menu == 1) { 522 GyroSpirallights(); // All LEDs change color with Gyro attitude 523 } 524 if (menu == 2 ) { 525 Game1(); // Game 1 three bands of LEDs change color with Gyro attitude 526 } 527 if (menu == 3 ) { 528 SoundRingStep(); // Sound activated Rings of Color 529 } 530 if (menu == 4 ) { 531 SoundEffect7(); // Sound Meter - LED VU Meter using 130 LEDs 532 } 533 if (menu == 5 ) { 534 DotSnakesSlow(); // Sound Slows LED Snakes down sphere 535 } 536 if (menu == 6 ) { 537 Colorwash(); // Cool display of all colors in spectrum for th sphere using LED rows 538 } 539 540 if (menu == 7 ) { 541 GyroSnake(); // Sound Slows LED Snakes down sphere 542 } 543 544 if (menu == 8 ) { 545 DotSnakes(); // LED Snakes down sphere 546 } 547 if (menu == 9 ) { 548 DotOnTop(); // Single Dot Circle on the top of the sphere that stays on top using Gyro 549 } 550 551 552 553 554 555 556 557 558 559} 560 561 562void testLEDs130() { // For testing Display End to End 563 for (int g = 0; g < 130; g++) { 564 leds[g] = CRGB::Blue; 565 FastLED.show(); 566 delay(t1); 567 if (g>2) { leds[g-2] = CRGB::Black;} 568 delay(t1); 569 FastLED.show(); 570 } 571 leds[128] = CRGB::Black; 572 leds[129] = CRGB::Black; 573 FastLED.show(); 574 575 for (int g = 0; g < 130; g++) { 576 leds[g] = CRGB::Red; 577 FastLED.show(); 578 delay(t1); 579 if (g>2) { leds[g-2] = CRGB::Black;} 580 delay(t1); 581 FastLED.show(); 582 } 583 leds[128] = CRGB::Black; 584 leds[129] = CRGB::Black; 585 FastLED.show(); 586 587 for (int g = 0; g < 130; g++) { 588 leds[g] = CRGB::Green; 589 FastLED.show(); 590 delay(t1); 591 if (g>2) { leds[g-2] = CRGB::Black;} 592 delay(t1); 593 FastLED.show(); 594 } 595 leds[128] = CRGB::Black; 596 leds[129] = CRGB::Black; 597 FastLED.show(); 598 599 600 for (int g = 0; g < 130; g++) { 601 leds[g] = CRGB::HotPink; 602 FastLED.show(); 603 delay(t1); 604 if (g>2) { leds[g-2] = CRGB::Black;} 605 delay(t1); 606 FastLED.show(); 607 } 608 leds[128] = CRGB::Black; 609 leds[129] = CRGB::Black; 610 FastLED.show(); 611 612} 613 614//******************************************** 615// GyroSpirallights 616// ******************************************* 617void GyroSpirallights() { // GyroLED Snakes down sphere 618 619 620if (cal == false) { // Display the menu Item 621 one(); 622 cal = true; 623} 624 625 626 627//fill_solid( &(leds[0]), 130 /*number of leds*/, CHSV( Xcol, 255, 255) ); 628// fill_rainbow( &(leds[0]), 130 /*led count*/, 5 /*starting hue*/); 629 630fill_solid( &(leds[0]), 1, CHSV( Xcol, 255, 255) ); 631fill_solid( &(leds[1]), 8 , CHSV( Xcol, 255, 255) ); 632fill_solid( &(leds[9]), 16 , CHSV( Xcol, 255, 255) ); 633fill_solid( &(leds[25]), 16, CHSV( Xcol, 255, 255) ); 634fill_solid( &(leds[41]), 16 , CHSV( Xcol, 255, 255) ); 635fill_solid( &(leds[57]), 16 , CHSV( Xcol, 255, 255) ); 636fill_solid( &(leds[73]), 16, CHSV( Xcol, 255, 255) ); 637fill_solid( &(leds[89]), 16 , CHSV( Xcol, 255, 255) ); 638fill_solid( &(leds[105]), 16 , CHSV( Xcol, 255, 255) ); 639fill_solid( &(leds[121]), 8, CHSV( Xcol, 255, 255) ); 640fill_solid( &(leds[129]), 1 , CHSV( Xcol, 255, 255) ); 641 642 643 644FastLED.show(); 645 646// Serial.println(Xcol); 647} 648 649 650 651//******************************************** 652// Game1 653// ******************************************* 654void Game1() { // GyroLED Snakes down sphere 655 656if (cal == false) { // Display the menu Item 657 two(); 658 cal = true; 659} 660 661// Three Bands 662fill_solid( &(leds[0]), 41, CHSV( Xcol, 255, 255) ); 663fill_solid( &(leds[41]), 48 , CHSV( Ycol, 255, 255) ); 664fill_solid( &(leds[89]), 41 , CHSV( Zcol, 255, 255) ); 665 666 667FastLED.show(); 668 669// Serial.println(Xcol); 670} 671 672//******************************************** 673// Game2 674// ******************************************* 675void Game2() { // GyroLED Snakes down sphere 676 677/* Three Bands 678fill_solid( &(leds[0]), 41, CHSV( Xcol, 255, 255) ); 679fill_solid( &(leds[41]), 48 , CHSV( Ycol, 255, 255) ); 680fill_solid( &(leds[89]), 41 , CHSV( Zcol, 255, 255) ); 681*/ 682 683// 11 Bands of color 684 685fill_solid( &(leds[0]), 1, CHSV( Xcol, 255, 255) ); 686fill_solid( &(leds[1]), 8 , CHSV( Ycol, 255, 255) ); 687fill_solid( &(leds[9]), 16 , CHSV( Zcol, 255, 255) ); 688fill_solid( &(leds[25]), 16, CHSV( Xcol, 255, 255) ); 689fill_solid( &(leds[41]), 16 , CHSV( Ycol, 255, 255) ); 690fill_solid( &(leds[57]), 16 , CHSV( Zcol, 255, 255) ); 691fill_solid( &(leds[73]), 16, CHSV( Xcol, 255, 255) ); 692fill_solid( &(leds[89]), 16 , CHSV( Ycol, 255, 255) ); 693fill_solid( &(leds[105]), 16 , CHSV( Zcol, 255, 255) ); 694fill_solid( &(leds[121]), 8, CHSV( Xcol, 255, 255) ); 695fill_solid( &(leds[129]), 1 , CHSV( Ycol, 255, 255) ); 696 697 698FastLED.show(); 699 700// Serial.println(Xcol); 701} 702 703//******************************************** 704// Spirallights 705// ******************************************* 706void Spirallights() { // GyroLED Snakes down sphere 707 708 709 710 if ( i < 10 ) { 711 712// leds[map(mic,10,250,0,9)].setRGB( (random(255)), (random(255)), (random(255))); 713 714 715 leds[map(mic,10,1023,0,9)] = CRGB::Blue; 716 717 FastLED.show(); 718 719 720 delay(20); 721 leds[i] = CRGB::Black; 722 FastLED.show(); 723 724 725 i++; 726 } else { 727 i = 0; 728 } 729 730} 731 732//******************************************** 733// SoundVU 734// ******************************************* 735void SoundVU() { // At last a stable Audio input circuit !! A2 connected to 0.1uf and SP1 on freetronics Mic 736 737// Blank all LEDs 738 739fill_solid( &(leds[0]), 130 /*number of leds*/, CHSV( 0, 0, 0) ); 740 741/* 742 * // initialize the pixel matrix by setting all LED Anodes and Cathodes to LOW: 743 for (int x = 0; x < 13; x++) { 744 for (int y = 0; y < 13; y++) { 745 pixels[x][y] = LOW; 746 } 747 } 748 749*/ 750 751 752// This works. Suggest writing in a circler around sphere then deleting each column 753 754 if (fps > 24) { 755 if (peak1.available()) { 756 fps = 0; 757 monoPeak = abs((peak1.read() * 180.0)-3); 758 if (monoPeak >129) { monoPeak = 129;} 759 Serial.println(monoPeak); 760 for (int cnt=0; cnt<monoPeak; cnt++) { 761 762 if (cnt < 50) { leds[cnt] = CRGB::Blue; } 763 else 764 if (cnt < 80) { leds[cnt] = CRGB::Green; } 765 else { 766 leds[cnt] = CRGB::Red; } 767 768// leds[cnt].setRGB( (random(255)), (random(255)), (random(255))); 769 FastLED.show(); 770 771 } 772 } 773 } 774 775} 776 777void buttoncheck() { // Debounce Button Check of Digital Pins 34 and 35 used to navigate menu of effects 778 779 // Increment Menu 780 if((digitalRead(34) == LOW ) && (digitalRead(35) == HIGH)){ // Check that one button pushed only 781 delay(150); // Debounce by waiting then checking again 782 if((digitalRead(34) == LOW) && (digitalRead(35) == HIGH)){ 783 // Now confirmed legitimate request increment menu variable 784 if (menu < 10 ) { 785 menu++; 786 clearsphere(); // Clear the entire LED Array to Black 787 cal = false; 788 g = 0; 789 i = 0; 790 } 791 } 792 delay(150); 793 } 794 795 // Decrement Menu 796 if((digitalRead(35) == LOW) && (digitalRead(34) == HIGH)){ // Check that one button pushed only 797 delay(150); // Debounce by waiting then checking again 798 if((digitalRead(35) == LOW) && (digitalRead(34) == HIGH)){ 799 // Now confirmed legitimate request increment menu variable 800 if (menu > 1 ) { 801 menu--; 802 clearsphere(); // Clear the entire LED Array to Black 803 cal = false; 804 g = 0; 805 i = 0; 806 } 807 } 808 delay(150); 809 } 810// Serial.println(menu); // Temporarily print menu output for testing 811 812 813} 814 815 816 817void clearsphere() { // Clear the entire LED array to black 818 819// for (int h = 0; h < 130; h++) { 820// leds[h] = CRGB::Black; 821 822fill_solid( &(leds[0]), 130 /*number of leds*/, CHSV( 0, 0, 0) ); 823 FastLED.show(); 824// } 825 826 827} 828 829 830//******************************************** 831// GyroSnakes 832// ******************************************* 833void GyroSnake() { // GyroLED Snakes down sphere 834 835if (cal == false) { // Display the menu Item 836 seven(); 837 cal = true; 838} 839 840 if ( i < 140 ) { 841 842 if ( i < 130 ) { 843 844 leds[i].setRGB( (Xcol), (Ycol), (Zcol)); 845 } 846 delay(d1); 847 if (i>9) { 848 leds[i-10] = CRGB::Black; 849 } 850 FastLED.show(); 851 852 i++; 853 } else { 854 i = 0; 855 } 856 857} 858 859 860void nine() { 861 862 leds[33] = CHSV( Znum, 255, 255); 863 leds[34] = CHSV( Znum, 255, 255); 864 leds[35] = CHSV( Znum, 255, 255); 865 leds[49] = CHSV( Znum, 255, 255); 866 leds[51] = CHSV( Znum, 255, 255); 867 leds[65] = CHSV( Znum, 255, 255); 868 leds[66] = CHSV( Znum, 255, 255); 869 leds[67] = CHSV( Znum, 255, 255); 870// leds[83] = CHSV( Znum, 255, 255); 871 leds[81] = CHSV( Znum, 255, 255); 872 leds[99] = CHSV( Znum, 255, 255); 873 leds[98] = CHSV( Znum, 255, 255); 874 leds[97] = CHSV( Znum, 255, 255); 875 876 FastLED.show(); 877 878 delay(d6); 879 880 881 882 leds[33] = CRGB::Black; 883 leds[34] = CRGB::Black; 884 leds[35] = CRGB::Black; 885 leds[49] = CRGB::Black; 886 leds[51] = CRGB::Black; 887 leds[65] = CRGB::Black; 888 leds[66] = CRGB::Black; 889 leds[67] = CRGB::Black; 890 leds[83] = CRGB::Black; 891 leds[81] = CRGB::Black; 892 leds[99] = CRGB::Black; 893 leds[98] = CRGB::Black; 894 leds[97] = CRGB::Black; 895 896 FastLED.show(); 897} 898 899void eight() { 900 901 leds[33] = CHSV( Znum, 255, 255); 902 leds[34] = CHSV( Znum, 255, 255); 903 leds[35] = CHSV( Znum, 255, 255); 904 leds[49] = CHSV( Znum, 255, 255); 905 leds[51] = CHSV( Znum, 255, 255); 906 leds[65] = CHSV( Znum, 255, 255); 907 leds[66] = CHSV( Znum, 255, 255); 908 leds[67] = CHSV( Znum, 255, 255); 909 leds[83] = CHSV( Znum, 255, 255); 910 leds[81] = CHSV( Znum, 255, 255); 911 leds[99] = CHSV( Znum, 255, 255); 912 leds[98] = CHSV( Znum, 255, 255); 913 leds[97] = CHSV( Znum, 255, 255); 914 915 FastLED.show(); 916 917 delay(d6); 918 919 920 921 leds[33] = CRGB::Black; 922 leds[34] = CRGB::Black; 923 leds[35] = CRGB::Black; 924 leds[49] = CRGB::Black; 925 leds[51] = CRGB::Black; 926 leds[65] = CRGB::Black; 927 leds[66] = CRGB::Black; 928 leds[67] = CRGB::Black; 929 leds[83] = CRGB::Black; 930 leds[81] = CRGB::Black; 931 leds[99] = CRGB::Black; 932 leds[98] = CRGB::Black; 933 leds[97] = CRGB::Black; 934 935 FastLED.show(); 936} 937 938void seven() { 939 940 leds[33] = CHSV( Znum, 255, 255); 941 leds[34] = CHSV( Znum, 255, 255); 942 leds[35] = CHSV( Znum, 255, 255); 943 leds[49] = CHSV( Znum, 255, 255); 944// leds[51] = CHSV( Znum, 255, 255); 945 leds[65] = CHSV( Znum, 255, 255); 946// leds[66] = CHSV( Znum, 255, 255); 947// leds[67] = CHSV( Znum, 255, 255); 948// leds[83] = CHSV( Znum, 255, 255); 949 leds[81] = CHSV( Znum, 255, 255); 950// leds[99] = CHSV( Znum, 255, 255); 951// leds[98] = CHSV( Znum, 255, 255); 952 leds[97] = CHSV( Znum, 255, 255); 953 954 FastLED.show(); 955 956 delay(d6); 957 958 959 960 leds[33] = CRGB::Black; 961 leds[34] = CRGB::Black; 962 leds[35] = CRGB::Black; 963 leds[49] = CRGB::Black; 964 leds[51] = CRGB::Black; 965 leds[65] = CRGB::Black; 966 leds[66] = CRGB::Black; 967 leds[67] = CRGB::Black; 968 leds[83] = CRGB::Black; 969 leds[81] = CRGB::Black; 970 leds[99] = CRGB::Black; 971 leds[98] = CRGB::Black; 972 leds[97] = CRGB::Black; 973 974 FastLED.show(); 975} 976 977void six() { 978 979 leds[33] = CHSV( Znum, 255, 255); 980 leds[34] = CHSV( Znum, 255, 255); 981 leds[35] = CHSV( Znum, 255, 255); 982// leds[49] = CHSV( Znum, 255, 255); 983 leds[51] = CHSV( Znum, 255, 255); 984 leds[65] = CHSV( Znum, 255, 255); 985 leds[66] = CHSV( Znum, 255, 255); 986 leds[67] = CHSV( Znum, 255, 255); 987 leds[83] = CHSV( Znum, 255, 255); 988 leds[81] = CHSV( Znum, 255, 255); 989 leds[99] = CHSV( Znum, 255, 255); 990 leds[98] = CHSV( Znum, 255, 255); 991 leds[97] = CHSV( Znum, 255, 255); 992 993 FastLED.show(); 994 995 delay(d6); 996 997 998 999 leds[33] = CRGB::Black; 1000 leds[34] = CRGB::Black; 1001 leds[35] = CRGB::Black; 1002 leds[49] = CRGB::Black; 1003 leds[51] = CRGB::Black; 1004 leds[65] = CRGB::Black; 1005 leds[66] = CRGB::Black; 1006 leds[67] = CRGB::Black; 1007 leds[83] = CRGB::Black; 1008 leds[81] = CRGB::Black; 1009 leds[99] = CRGB::Black; 1010 leds[98] = CRGB::Black; 1011 leds[97] = CRGB::Black; 1012 1013 FastLED.show(); 1014} 1015 1016void five() { 1017 1018 leds[33] = CHSV( Znum, 255, 255); 1019 leds[34] = CHSV( Znum, 255, 255); 1020 leds[35] = CHSV( Znum, 255, 255); 1021// leds[49] = CHSV( Znum, 255, 255); 1022 leds[51] = CHSV( Znum, 255, 255); 1023 leds[65] = CHSV( Znum, 255, 255); 1024 leds[66] = CHSV( Znum, 255, 255); 1025 leds[67] = CHSV( Znum, 255, 255); 1026// leds[83] = CHSV( Znum, 255, 255); 1027 leds[81] = CHSV( Znum, 255, 255); 1028 leds[99] = CHSV( Znum, 255, 255); 1029 leds[98] = CHSV( Znum, 255, 255); 1030 leds[97] = CHSV( Znum, 255, 255); 1031 1032 FastLED.show(); 1033 1034 delay(d6); 1035 1036 1037 1038 leds[33] = CRGB::Black; 1039 leds[34] = CRGB::Black; 1040 leds[35] = CRGB::Black; 1041 leds[49] = CRGB::Black; 1042 leds[51] = CRGB::Black; 1043 leds[65] = CRGB::Black; 1044 leds[66] = CRGB::Black; 1045 leds[67] = CRGB::Black; 1046 leds[83] = CRGB::Black; 1047 leds[81] = CRGB::Black; 1048 leds[99] = CRGB::Black; 1049 leds[98] = CRGB::Black; 1050 leds[97] = CRGB::Black; 1051 1052 FastLED.show(); 1053} 1054 1055void four() { 1056 1057 leds[33] = CHSV( Znum, 255, 255); 1058// leds[34] = CHSV( Znum, 255, 255); 1059 leds[35] = CHSV( Znum, 255, 255); 1060 leds[49] = CHSV( Znum, 255, 255); 1061 leds[51] = CHSV( Znum, 255, 255); 1062 leds[65] = CHSV( Znum, 255, 255); 1063 leds[66] = CHSV( Znum, 255, 255); 1064 leds[67] = CHSV( Znum, 255, 255); 1065// leds[83] = CHSV( Znum, 255, 255); 1066 leds[81] = CHSV( Znum, 255, 255); 1067// leds[99] = CHSV( Znum, 255, 255); 1068// leds[98] = CHSV( Znum, 255, 255); 1069 leds[97] = CHSV( Znum, 255, 255); 1070 1071 FastLED.show(); 1072 1073 delay(d6); 1074 1075 1076 1077 leds[33] = CRGB::Black; 1078 leds[34] = CRGB::Black; 1079 leds[35] = CRGB::Black; 1080 leds[49] = CRGB::Black; 1081 leds[51] = CRGB::Black; 1082 leds[65] = CRGB::Black; 1083 leds[66] = CRGB::Black; 1084 leds[67] = CRGB::Black; 1085 leds[83] = CRGB::Black; 1086 leds[81] = CRGB::Black; 1087 leds[99] = CRGB::Black; 1088 leds[98] = CRGB::Black; 1089 leds[97] = CRGB::Black; 1090 1091 FastLED.show(); 1092} 1093 1094void three() { 1095 1096 leds[33] = CHSV( Znum, 255, 255); 1097 leds[34] = CHSV( Znum, 255, 255); 1098 leds[35] = CHSV( Znum, 255, 255); 1099 leds[49] = CHSV( Znum, 255, 255); 1100// leds[51] = CHSV( Znum, 255, 255); 1101 leds[65] = CHSV( Znum, 255, 255); 1102 leds[66] = CHSV( Znum, 255, 255); 1103 leds[67] = CHSV( Znum, 255, 255); 1104// leds[83] = CHSV( Znum, 255, 255); 1105 leds[81] = CHSV( Znum, 255, 255); 1106 leds[99] = CHSV( Znum, 255, 255); 1107 leds[98] = CHSV( Znum, 255, 255); 1108 leds[97] = CHSV( Znum, 255, 255); 1109 1110 FastLED.show(); 1111 1112 delay(d6); 1113 1114 1115 1116 leds[33] = CRGB::Black; 1117 leds[34] = CRGB::Black; 1118 leds[35] = CRGB::Black; 1119 leds[49] = CRGB::Black; 1120 leds[51] = CRGB::Black; 1121 leds[65] = CRGB::Black; 1122 leds[66] = CRGB::Black; 1123 leds[67] = CRGB::Black; 1124 leds[83] = CRGB::Black; 1125 leds[81] = CRGB::Black; 1126 leds[99] = CRGB::Black; 1127 leds[98] = CRGB::Black; 1128 leds[97] = CRGB::Black; 1129 1130 FastLED.show(); 1131} 1132 1133void two() { 1134 1135 leds[33] = CHSV( Znum, 255, 255); 1136 leds[34] = CHSV( Znum, 255, 255); 1137 leds[35] = CHSV( Znum, 255, 255); 1138 leds[49] = CHSV( Znum, 255, 255); 1139// leds[51] = CHSV( Znum, 255, 255); 1140 leds[65] = CHSV( Znum, 255, 255); 1141 leds[66] = CHSV( Znum, 255, 255); 1142 leds[67] = CHSV( Znum, 255, 255); 1143 leds[83] = CHSV( Znum, 255, 255); 1144// leds[81] = CHSV( Znum, 255, 255); 1145 leds[99] = CHSV( Znum, 255, 255); 1146 leds[98] = CHSV( Znum, 255, 255); 1147 leds[97] = CHSV( Znum, 255, 255); 1148 1149 FastLED.show(); 1150 1151 delay(d6); 1152 1153 1154 leds[33] = CRGB::Black; 1155 leds[34] = CRGB::Black; 1156 leds[35] = CRGB::Black; 1157 leds[49] = CRGB::Black; 1158 leds[51] = CRGB::Black; 1159 leds[65] = CRGB::Black; 1160 leds[66] = CRGB::Black; 1161 leds[67] = CRGB::Black; 1162 leds[83] = CRGB::Black; 1163 leds[81] = CRGB::Black; 1164 leds[99] = CRGB::Black; 1165 leds[98] = CRGB::Black; 1166 leds[97] = CRGB::Black; 1167 1168 FastLED.show(); 1169 1170} 1171 1172void one() { 1173 1174 leds[33] = CHSV( Znum, 255, 255); 1175// leds[34] = CHSV( Znum, 255, 255); 1176// leds[35] = CHSV( Znum, 255, 255); 1177 leds[49] = CHSV( Znum, 255, 255); 1178// leds[51] = CHSV( Znum, 255, 255); 1179 leds[65] = CHSV( Znum, 255, 255); 1180// leds[66] = CHSV( Znum, 255, 255); 1181// leds[67] = CHSV( Znum, 255, 255); 1182// leds[83] = CHSV( Znum, 255, 255); 1183 leds[81] = CHSV( Znum, 255, 255); 1184// leds[99] = CHSV( Znum, 255, 255); 1185// leds[98] = CHSV( Znum, 255, 255); 1186 leds[97] = CHSV( Znum, 255, 255); 1187 1188 FastLED.show(); 1189 1190 delay(d6); 1191 1192 1193 1194 leds[33] = CRGB::Black; 1195 leds[34] = CRGB::Black; 1196 leds[35] = CRGB::Black; 1197 leds[49] = CRGB::Black; 1198 leds[51] = CRGB::Black; 1199 leds[65] = CRGB::Black; 1200 leds[66] = CRGB::Black; 1201 leds[67] = CRGB::Black; 1202 leds[83] = CRGB::Black; 1203 leds[81] = CRGB::Black; 1204 leds[99] = CRGB::Black; 1205 leds[98] = CRGB::Black; 1206 leds[97] = CRGB::Black; 1207 1208 FastLED.show(); 1209} 1210 1211void zero() { 1212 1213 leds[33] = CHSV( Znum, 255, 255); 1214 leds[34] = CHSV( Znum, 255, 255); 1215 leds[35] = CHSV( Znum, 255, 255); 1216 leds[49] = CHSV( Znum, 255, 255); 1217 leds[51] = CHSV( Znum, 255, 255); 1218 leds[65] = CHSV( Znum, 255, 255); 1219// leds[66] = CHSV( Znum, 255, 255); 1220 leds[67] = CHSV( Znum, 255, 255); 1221 leds[83] = CHSV( Znum, 255, 255); 1222 leds[81] = CHSV( Znum, 255, 255); 1223 leds[99] = CHSV( Znum, 255, 255); 1224 leds[98] = CHSV( Znum, 255, 255); 1225 leds[97] = CHSV( Znum, 255, 255); 1226 1227 FastLED.show(); 1228 1229 delay(d6); 1230 1231 1232 1233 leds[33] = CRGB::Black; 1234 leds[34] = CRGB::Black; 1235 leds[35] = CRGB::Black; 1236 leds[49] = CRGB::Black; 1237 leds[51] = CRGB::Black; 1238 leds[65] = CRGB::Black; 1239 leds[66] = CRGB::Black; 1240 leds[67] = CRGB::Black; 1241 leds[83] = CRGB::Black; 1242 leds[81] = CRGB::Black; 1243 leds[99] = CRGB::Black; 1244 leds[98] = CRGB::Black; 1245 leds[97] = CRGB::Black; 1246 1247 FastLED.show(); 1248 1249} 1250 1251 1252 1253 1254//******************************************** 1255// Dotsnakes 1256// ******************************************* 1257 1258void DotSnakes() { 1259 1260if (cal == false) { // Display the menu Item 1261 eight(); 1262 cal = true; 1263} 1264 1265 //Clear all current LEDs 1266 1267 1268 leds[dot[0][0]] = CRGB::Black; // Turn off current LED position 1269 leds[dot[0][2]] = CRGB::Black; // Turn off current LED position 1270 leds[dot[0][3]] = CRGB::Black; // Turn off current LED position 1271 leds[dot[0][4]] = CRGB::Black; // Turn off current LED position 1272 1273 leds[dot[1][0]] = CRGB::Black; // Turn off current LED position 1274 leds[dot[1][2]] = CRGB::Black; // Turn off current LED position 1275 leds[dot[1][3]] = CRGB::Black; // Turn off current LED position 1276 leds[dot[1][4]] = CRGB::Black; // Turn off current LED position 1277 1278 leds[dot[2][0]] = CRGB::Black; // Turn off current LED position 1279 leds[dot[2][2]] = CRGB::Black; // Turn off current LED position 1280 leds[dot[2][3]] = CRGB::Black; // Turn off current LED position 1281 leds[dot[2][4]] = CRGB::Black; // Turn off current LED position 1282 1283 leds[dot[3][0]] = CRGB::Black; // Turn off current LED position 1284 leds[dot[3][2]] = CRGB::Black; // Turn off current LED position 1285 leds[dot[3][3]] = CRGB::Black; // Turn off current LED position 1286 leds[dot[3][4]] = CRGB::Black; // Turn off current LED position 1287 FastLED.show(); 1288 1289 // Dot 0 ********************************************************** 1290 1291 1292 // Randomly change direction of Dot 1293 1294 direct = random8(8); // Randomly determine new direction 1295 1296 // Check not going backwards 1297 while ((abs(dot[0][1] - direct)) == 4){ 1298 direct = random8(8); // Randomly determine new direction 1299 } 1300 1301 dot[0][1] = direct; // Store value in array 1302 1303 1304 1305 // Update position of data based on new direction before displaying 1306 dot[0][4] = dot[0][3]; // Store prevprev into prevprevprev location 1307 dot[0][3] = dot[0][2]; // Store prev into prevprev location 1308 dot[0][2] = dot[0][0]; // Store current into prev location 1309 1310 dot[0][0]= pixel[dot[0][0]][dot[0][1]]; // Use function to read data back from array in Progam Memory 1311 1312 1313 1314 1315 // Dot 1********************************************************** 1316 1317 1318 // Randomly change direction of Dot 1319 direct = random8(8); // Randomly determine new direction 1320 // Check not going backwards 1321 while ((abs(dot[1][1] - direct)) == 4){ 1322 direct = random8(8); // Randomly determine new direction 1323 } 1324 1325 dot[1][1] = direct; // Modify lead dot position and store value in array 1326 1327 1328 1329 1330 // Update position of data based on new direction before displaying 1331 dot[1][4] = dot[1][3]; // Store prevprev into prevprevprev location 1332 dot[1][3] = dot[1][2]; // Store prev into prevprev location 1333 dot[1][2] = dot[1][0]; // Store current into prev location 1334 1335 dot[1][0]= pixel[dot[1][0]][dot[1][1]]; // Use function to read data back from array in Progam Memory 1336 1337 1338 1339 1340 // Dot 2 ***************************************** 1341 1342 1343 // Randomly change direction of Dot 1344 direct = random8(8); // Randomly determine new direction 1345 // Check not going backwards 1346 while ((abs(dot[2][1] - direct)) == 4){ 1347 direct = random8(8); // Randomly determine new direction 1348 } 1349 1350 dot[2][1] = direct; // Store value in array 1351 1352 1353 1354 1355 // Update position of data based on new direction before displaying 1356 dot[2][4] = dot[2][3]; // Store prevprev into prevprevprev location 1357 dot[2][3] = dot[2][2]; // Store prev into prevprev location 1358 dot[2][2] = dot[2][0]; // Store current into prev location 1359 1360 dot[2][0]= pixel[dot[2][0]][dot[2][1]]; // Use pgm_read_byte function to read data back from array in Progam Memory 1361 1362 1363 1364 1365 1366 // Dot 3 ***************************************** 1367 1368 1369 // Randomly change direction of Dot 1370 direct = random8(8); // Randomly determine new direction 1371 // Check not going backwards 1372 while ((abs(dot[3][1] - direct)) == 4){ 1373 direct = random8(8); // Randomly determine new direction 1374 } 1375 dot[3][1] = direct; // Store value in array 1376 1377 1378 1379 1380 1381 // Update position of data based on new direction before displaying 1382 dot[3][4] = dot[3][3]; // Store prevprev into prevprevprev location 1383 dot[3][3] = dot[3][2]; // Store prev into prevprev location 1384 dot[3][2] = dot[3][0]; // Store current into prev location 1385 1386 dot[3][0]= pixel[dot[3][0]][dot[3][1]]; // Use pgm_read_byte function to read data back from array in Progam Memory 1387 1388 1389 // delay(100); 1390 1391 leds[dot[0][0]] = CRGB::Blue; 1392 leds[dot[0][2]] = CRGB::Blue; 1393 leds[dot[0][3]] = CRGB::Blue; 1394 leds[dot[0][4]] = CRGB::Blue; 1395 1396 leds[dot[1][0]] = CRGB::Red; 1397 leds[dot[1][2]] = CRGB::Red; 1398 leds[dot[1][3]] = CRGB::Red; 1399 leds[dot[1][4]] = CRGB::Red; 1400 1401 leds[dot[2][0]] = CRGB::Green; 1402 leds[dot[2][2]] = CRGB::Green; 1403 leds[dot[2][3]] = CRGB::Green; 1404 leds[dot[2][4]] = CRGB::Green; 1405 1406 leds[dot[3][0]] = CRGB::Purple; 1407 leds[dot[3][2]] = CRGB::Purple; 1408 leds[dot[3][3]] = CRGB::Purple; 1409 leds[dot[3][4]] = CRGB::Purple; 1410 1411 FastLED.show(); 1412 1413 delay(10); 1414} 1415 1416 1417 1418//******************************************** 1419// SoundEffect1 1420// ******************************************* 1421void SoundEffect1() { // At last a stable Audio input circuit !! Teensy A2 connected to 4.7uf and SP1 on freetronics Mic. Also Analog Ground used with Mic 1422 1423 1424// Use the Ampliyude of the Mic input to set the Delay to slow down dotsnakes effect 1425 1426 if (fps > 24) { 1427 if (peak1.available()) { 1428 fps = 0; 1429 monoPeak = abs((peak1.read() * 100.0)); 1430 } 1431 } 1432 1433 1434 1435 //Clear all current LEDs 1436 1437 1438 leds[dot[0][0]] = CRGB::Black; // Turn off current LED position 1439 leds[dot[0][2]] = CRGB::Black; // Turn off current LED position 1440 leds[dot[0][3]] = CRGB::Black; // Turn off current LED position 1441 leds[dot[0][4]] = CRGB::Black; // Turn off current LED position 1442 1443 leds[dot[1][0]] = CRGB::Black; // Turn off current LED position 1444 leds[dot[1][2]] = CRGB::Black; // Turn off current LED position 1445 leds[dot[1][3]] = CRGB::Black; // Turn off current LED position 1446 leds[dot[1][4]] = CRGB::Black; // Turn off current LED position 1447 1448 leds[dot[2][0]] = CRGB::Black; // Turn off current LED position 1449 leds[dot[2][2]] = CRGB::Black; // Turn off current LED position 1450 leds[dot[2][3]] = CRGB::Black; // Turn off current LED position 1451 leds[dot[2][4]] = CRGB::Black; // Turn off current LED position 1452 1453 leds[dot[3][0]] = CRGB::Black; // Turn off current LED position 1454 leds[dot[3][2]] = CRGB::Black; // Turn off current LED position 1455 leds[dot[3][3]] = CRGB::Black; // Turn off current LED position 1456 leds[dot[3][4]] = CRGB::Black; // Turn off current LED position 1457 FastLED.show(); 1458 1459 // Dot 0 ********************************************************** 1460 1461 1462 // Randomly change direction of Dot 1463 1464 direct = random8(8); // Randomly determine new direction 1465 1466 // Check not going backwards 1467 while ((abs(dot[0][1] - direct)) == 4){ 1468 direct = random8(8); // Randomly determine new direction 1469 } 1470 1471 dot[0][1] = direct; // Store value in array 1472 1473 1474 1475 // Update position of data based on new direction before displaying 1476 dot[0][4] = dot[0][3]; // Store prevprev into prevprevprev location 1477 dot[0][3] = dot[0][2]; // Store prev into prevprev location 1478 dot[0][2] = dot[0][0]; // Store current into prev location 1479 1480 dot[0][0]= pixel[dot[0][0]][dot[0][1]]; // Use function to read data back from array in Progam Memory 1481 1482 1483 1484 1485 // Dot 1********************************************************** 1486 1487 1488 // Randomly change direction of Dot 1489 direct = random8(8); // Randomly determine new direction 1490 // Check not going backwards 1491 while ((abs(dot[1][1] - direct)) == 4){ 1492 direct = random8(8); // Randomly determine new direction 1493 } 1494 1495 dot[1][1] = direct; // Modify lead dot position and store value in array 1496 1497 1498 1499 1500 // Update position of data based on new direction before displaying 1501 dot[1][4] = dot[1][3]; // Store prevprev into prevprevprev location 1502 dot[1][3] = dot[1][2]; // Store prev into prevprev location 1503 dot[1][2] = dot[1][0]; // Store current into prev location 1504 1505 dot[1][0]= pixel[dot[1][0]][dot[1][1]]; // Use function to read data back from array in Progam Memory 1506 1507 1508 1509 1510 // Dot 2 ***************************************** 1511 1512 1513 // Randomly change direction of Dot 1514 direct = random8(8); // Randomly determine new direction 1515 // Check not going backwards 1516 while ((abs(dot[2][1] - direct)) == 4){ 1517 direct = random8(8); // Randomly determine new direction 1518 } 1519 1520 dot[2][1] = direct; // Store value in array 1521 1522 1523 1524 1525 // Update position of data based on new direction before displaying 1526 dot[2][4] = dot[2][3]; // Store prevprev into prevprevprev location 1527 dot[2][3] = dot[2][2]; // Store prev into prevprev location 1528 dot[2][2] = dot[2][0]; // Store current into prev location 1529 1530 dot[2][0]= pixel[dot[2][0]][dot[2][1]]; // Use pgm_read_byte function to read data back from array in Progam Memory 1531 1532 1533 1534 1535 1536 // Dot 3 ***************************************** 1537 1538 1539 // Randomly change direction of Dot 1540 direct = random8(8); // Randomly determine new direction 1541 // Check not going backwards 1542 while ((abs(dot[3][1] - direct)) == 4){ 1543 direct = random8(8); // Randomly determine new direction 1544 } 1545 dot[3][1] = direct; // Store value in array 1546 1547 1548 1549 1550 1551 // Update position of data based on new direction before displaying 1552 dot[3][4] = dot[3][3]; // Store prevprev into prevprevprev location 1553 dot[3][3] = dot[3][2]; // Store prev into prevprev location 1554 dot[3][2] = dot[3][0]; // Store current into prev location 1555 1556 dot[3][0]= pixel[dot[3][0]][dot[3][1]]; // Use pgm_read_byte function to read data back from array in Progam Memory 1557 1558 1559 // delay(100); 1560 1561 leds[dot[0][0]] = CRGB::Blue; 1562 leds[dot[0][2]] = CRGB::Blue; 1563 leds[dot[0][3]] = CRGB::Blue; 1564 leds[dot[0][4]] = CRGB::Blue; 1565 1566 leds[dot[1][0]] = CRGB::Red; 1567 leds[dot[1][2]] = CRGB::Red; 1568 leds[dot[1][3]] = CRGB::Red; 1569 leds[dot[1][4]] = CRGB::Red; 1570 1571 leds[dot[2][0]] = CRGB::Green; 1572 leds[dot[2][2]] = CRGB::Green; 1573 leds[dot[2][3]] = CRGB::Green; 1574 leds[dot[2][4]] = CRGB::Green; 1575 1576 leds[dot[3][0]] = CRGB::Purple; 1577 leds[dot[3][2]] = CRGB::Purple; 1578 leds[dot[3][3]] = CRGB::Purple; 1579 leds[dot[3][4]] = CRGB::Purple; 1580 1581 FastLED.show(); 1582 1583 delay(monoPeak); 1584 1585 1586 1587} 1588 1589 1590 1591 1592//******************************************** 1593// SoundEffect 3 1594// ******************************************* 1595void SoundEffect3() { // At last a stable Audio input circuit !! Teensy A2 connected to 4.7uf and SP1 on freetronics Mic. Also Analog Ground used with Mic 1596 1597 1598// Use the Ampliyude of the Mic input to set the VU Display which is a Bar graph cicling the Shpere 1599 1600 if (fps > 24) { 1601 if (peak1.available()) { 1602 fps = 0; 1603 monoPeak = abs((peak1.read() * 10000.0)); 1604 if (monoPeak >10000 ) { 1605 monoPeak = 10000; 1606 } 1607 } 1608 } 1609 1610 1611// ********* 1612 1613/* 16140 = Up 16151 = Up Right 16162 = Right 16173 = Down Right 16184 = Down 16195 = Down Left 16206 = Left 16217 = Up Left 1622 led, peakv 1623int soundot[5] = { 73 , 73, 88, 87, 86}; 1624*/ 1625 1626 // Determine the Location of the new dot position based on the Analogue input value and the 5 rings of LEDs where 1st is baseline 1627 // smoothmic is the smooothed Mic output from A2 which has a range of 0 - 1025 in value 1628 // Suggested ranges are 0 < 10, 1 < 30, etc 1629 1630 if (monoPeak >= 10000) { // Highest level of sound (read adjacent dot 4x) 1631 1632// 11 Bands of color 1633 1634fill_solid( &(leds[0]), 1, CRGB( 255, 0, 0) ); 1635fill_solid( &(leds[1]), 8 , CRGB( 255, 0, 0) ); 1636fill_solid( &(leds[9]), 16 , CRGB::Red); 1637fill_solid( &(leds[25]), 16, CRGB::Green); 1638fill_solid( &(leds[41]), 16 , CRGB( 0, 255, 0) ); 1639fill_solid( &(leds[57]), 16 , CRGB( 0, 255, 0) ); 1640fill_solid( &(leds[73]), 16, CRGB( 0, 0, 255) ); 1641fill_solid( &(leds[89]), 16 , CRGB( 0, 0, 255) ); 1642//fill_solid( &(leds[105]), 16 , CRGB( 0, 0, 255) ); 1643 1644 1645 } else 1646 1647 if (monoPeak >= 8000 ) { // 2nd Highest level of sound 1648 1649fill_solid( &(leds[1]), 8 , CRGB( 255, 0, 0) ); 1650fill_solid( &(leds[9]), 16 , CRGB::Red); 1651fill_solid( &(leds[25]), 16, CRGB::Green); 1652fill_solid( &(leds[41]), 16 , CRGB( 0, 255, 0) ); 1653fill_solid( &(leds[57]), 16 , CRGB( 0, 255, 0) ); 1654fill_solid( &(leds[73]), 16, CRGB( 0, 0, 255) ); 1655fill_solid( &(leds[89]), 16 , CRGB( 0, 0, 255) ); 1656//fill_solid( &(leds[105]), 16 , CRGB( 0, 0, 255) ); 1657 1658 1659 } else 1660 1661 1662 if (monoPeak >= 6000 ) { // 2nd Highest level of sound 1663 1664 1665fill_solid( &(leds[9]), 16 , CRGB::Red); 1666fill_solid( &(leds[25]), 16, CRGB::Green); 1667fill_solid( &(leds[41]), 16 , CRGB( 0, 255, 0) ); 1668fill_solid( &(leds[57]), 16 , CRGB( 0, 255, 0) ); 1669fill_solid( &(leds[73]), 16, CRGB( 0, 0, 255) ); 1670fill_solid( &(leds[89]), 16 , CRGB( 0, 0, 255) ); 1671//fill_solid( &(leds[105]), 16 , CRGB( 0, 0, 255) ); 1672 1673 } else 1674 1675 if (monoPeak >= 5000 ) { // 2nd Highest level of sound 1676 1677 1678 1679fill_solid( &(leds[25]), 16, CRGB::Green); 1680fill_solid( &(leds[41]), 16 , CRGB( 0, 255, 0) ); 1681fill_solid( &(leds[57]), 16 , CRGB( 0, 255, 0) ); 1682fill_solid( &(leds[73]), 16, CRGB( 0, 0, 255) ); 1683fill_solid( &(leds[89]), 16 , CRGB( 0, 0, 255) ); 1684//fill_solid( &(leds[105]), 16 , CRGB( 0, 0, 255) ); 1685 1686 1687 } else 1688 1689 1690 if (monoPeak >= 4000 ) { // 2nd Highest level of sound 1691 1692fill_solid( &(leds[41]), 16 , CRGB( 0, 255, 0) ); 1693fill_solid( &(leds[57]), 16 , CRGB( 0, 255, 0) ); 1694fill_solid( &(leds[73]), 16, CRGB( 0, 0, 255) ); 1695fill_solid( &(leds[89]), 16 , CRGB( 0, 0, 255) ); 1696//fill_solid( &(leds[105]), 16 , CRGB( 0, 0, 255) ); 1697 1698 } else 1699 1700 if (monoPeak >= 3000 ) { // 3rd Highest level of sound 1701 1702fill_solid( &(leds[57]), 16 , CRGB( 0, 255, 0) ); 1703fill_solid( &(leds[73]), 16, CRGB( 0, 0, 255) ); 1704fill_solid( &(leds[89]), 16 , CRGB( 0, 0, 255) ); 1705//fill_solid( &(leds[105]), 16 , CRGB( 0, 0, 255) ); 1706 1707 1708 } else 1709 1710 if (monoPeak >= 2000 ) { // 3rd Highest level of sound 1711 1712fill_solid( &(leds[73]), 16, CRGB( 0, 0, 255) ); 1713fill_solid( &(leds[89]), 16 , CRGB( 0, 0, 255) ); 1714 1715 } else 1716 1717 if (monoPeak >= 1000 ) { // 3rd Highest level of sound 1718 1719fill_solid( &(leds[89]), 16 , CRGB( 0, 0, 255) ); 1720 1721 1722 } 1723 1724 FastLED.show(); 1725 1726 delay(1); 1727 1728 1729 // Clear Sphere 1730 1731fadeToBlackBy( leds, 25, 15); 1732fadeToBlackBy( leds, 41, 15); 1733fadeToBlackBy( leds, 57, 15); 1734fadeToBlackBy( leds, 73, 15); 1735fadeToBlackBy( leds, 89, 15); 1736// FastLED.show(); 1737 1738 1739} 1740 1741 1742//******************************************** 1743// Color Wash 1744// ******************************************* 1745void Colorwash() { // GyroLED Snakes down sphere 1746 1747 1748if (cal == false) { // Display the menu Item 1749 six(); 1750 cal = true; 1751} 1752 1753/* Three Bands 1754fill_solid( &(leds[0]), 41, CHSV( Xcol, 255, 255) ); 1755fill_solid( &(leds[41]), 48 , CHSV( Ycol, 255, 255) ); 1756fill_solid( &(leds[89]), 41 , CHSV( Zcol, 255, 255) ); 1757*/ 1758 1759int aw[11]; // 1760 1761 for (int uw = 0; uw < 256; uw++) { 1762 1763 aw[0] = uw + 22; 1764 aw[1] = uw + 44; 1765 aw[2] = uw + 66; 1766 aw[3] = uw + 88; 1767 aw[4] = uw + 110; 1768 aw[5] = uw + 132; 1769 aw[6] = uw + 154; 1770 aw[7] = uw + 176; 1771 aw[8] = uw + 196; 1772 aw[9] = uw + 218; 1773 aw[10] = uw + 240; 1774 1775 if (aw[1] > 256) { aw[1] = aw[1] - 255; } 1776 if (aw[2] > 256) { aw[2] = aw[2] - 255; } 1777 if (aw[3] > 256) { aw[3] = aw[3] - 255; } 1778 if (aw[4] > 256) { aw[4] = aw[4] - 255; } 1779 if (aw[5] > 256) { aw[5] = aw[5] - 255; } 1780 if (aw[6] > 256) { aw[6] = aw[6] - 255; } 1781 if (aw[7] > 256) { aw[7] = aw[7] - 255; } 1782 if (aw[8] > 256) { aw[8] = aw[8] - 255; } 1783 if (aw[9] > 256) { aw[9] = aw[9] - 255; } 1784 if (aw[10] > 256) { aw[10] = aw[10] - 255; } 1785 1786 1787 // 11 Bands of color 1788 1789 fill_solid( &(leds[0]), 1, CHSV( aw[0], 255, 255) ); 1790 fill_solid( &(leds[1]), 8 , CHSV( aw[1], 255, 255) ); 1791 fill_solid( &(leds[9]), 16 , CHSV( aw[2], 255, 255) ); 1792 fill_solid( &(leds[25]), 16, CHSV( aw[3], 255, 255) ); 1793 fill_solid( &(leds[41]), 16 , CHSV( aw[4], 255, 255) ); 1794 fill_solid( &(leds[57]), 16 , CHSV( aw[5], 255, 255) ); 1795 fill_solid( &(leds[73]), 16, CHSV( aw[6], 255, 255) ); 1796 fill_solid( &(leds[89]), 16 , CHSV( aw[7], 255, 255) ); 1797 fill_solid( &(leds[105]), 16 , CHSV( aw[8], 255, 255) ); 1798 fill_solid( &(leds[121]), 8, CHSV( aw[9], 255, 255) ); 1799 fill_solid( &(leds[129]), 1 , CHSV( aw[10], 255, 255) ); 1800 1801 1802 FastLED.show(); 1803 1804 delay(1); 1805 1806 1807 // Serial.println(Xcol); 1808 } 1809 1810} 1811 1812//******************************************** 1813// DotOnTop 1814// ******************************************* 1815void DotOnTop() { // LED stays in top of sphere 1816 1817 // Callibrate with 5 second count down 1818 1819if (cal == false) { // Delay count down timer to let MPU 6050 stabilize 1820 nine(); 1821 1822 1823 cal = true; 1824// get a baseline of X,Y,Z coordinates from smoothing algorithm 1825 1826 xb = smoothedX; // At rest baseline value 1827 yb = smoothedY; // At rest baseline value 1828 zb = smoothedZ; // At rest baseline value 1829 1830 // Normalise Baseline 1831 1832 xb = xb + 18100; 1833 yb = yb + 18100; 1834 zb = zb + 18100; 1835 1836} 1837 1838 1839 1840// Normalise Smoothed Values 1841Xnormalise = smoothedX + 18100; 1842Ynormalise = smoothedY + 18100; 1843Znormalise = smoothedZ + 18100; 1844 1845// Display dot on top of ball 1846 1847// leds[dt] = CRGB::Blue; 1848// FastLED.show(); 1849 1850// Identify from Array new position of the Dot 1851 1852int tolerance = 2000;// X,Y,Z must meet this criteria to turn on LED 1853int gc=0; // Points to LED to be tested 1854boolean gf = false; // Flag to indicate coordinate found no need to search further 1855 1856// Temp calc variables 1857int tX = 0; 1858int tY = 0; 1859int tZ = 0; 1860 1861 1862 1863while ( (gc<130) && (gf == false)) { // For LEDS on top of Sphere 1864 // Read in Data from Array and Test Against Gyro Coordinates 1865 1866 tX = pixel[gc][10]; 1867 tY = pixel[gc][11]; 1868 tZ = pixel[gc][12]; 1869 1870 1871 if ( (Xnormalise < (tX+tolerance)) && (Xnormalise > (tX-tolerance))) { 1872 1873 if ( (Ynormalise < (tY+tolerance)) && (Ynormalise > (tY-tolerance))) { 1874 1875 if ( (Znormalise < (tZ+tolerance)) && (Znormalise > (tZ-tolerance))) { 1876 1877 // Set pointer to new LED and display it 1878 dt = gc; 1879 gf = true; // Set flag to exit While Loop 1880 leds[dt] = CRGB::Red; 1881 leds[pixel[dt][0]] = CRGB::Blue; 1882 leds[pixel[dt][1]] = CRGB::Blue; 1883 leds[pixel[dt][2]] = CRGB::Blue; 1884 leds[pixel[dt][3]] = CRGB::Blue; 1885 leds[pixel[dt][4]] = CRGB::Blue; 1886 leds[pixel[dt][5]] = CRGB::Blue; 1887 leds[pixel[dt][6]] = CRGB::Blue; 1888 leds[pixel[dt][7]] = CRGB::Blue; 1889 1890 FastLED.show(); 1891 1892 leds[dt] = CRGB::Black; 1893 leds[pixel[dt][0]] = CRGB::Black; 1894 leds[pixel[dt][1]] = CRGB::Black; 1895 leds[pixel[dt][2]] = CRGB::Black; 1896 leds[pixel[dt][3]] = CRGB::Black; 1897 leds[pixel[dt][4]] = CRGB::Black; 1898 leds[pixel[dt][5]] = CRGB::Black; 1899 leds[pixel[dt][6]] = CRGB::Black; 1900 leds[pixel[dt][7]] = CRGB::Black; 1901 FastLED.show(); 1902 } 1903 1904 } 1905 } 1906 1907 // leds[i].setRGB( (Xcol), (Ycol), (Zcol)); 1908 1909 //Increment counter 1910 gc++; 1911 } 1912 1913} 1914 1915//******************************************** 1916// SoundEffect 4 1917// ******************************************* 1918void SoundEffect4() { // At last a stable Audio input circuit !! Teensy A2 connected to 4.7uf and SP1 on freetronics Mic. Also Analog Ground used with Mic 1919 1920 1921// Use the Ampliyude of the Mic input to set the VU Display which is a Bar graph circling the Shpere 1922 1923 if (fps > 24) { 1924 if (peak1.available()) { 1925 fps = 0; 1926 monoPeak = abs((peak1.read() * 10000.0)); 1927 if (monoPeak >10000 ) { 1928 monoPeak = 10000; 1929 } 1930 } 1931 1932 } 1933 1934 1935// ********* 1936 1937/* 19380 = Up 19391 = Up Right 19402 = Right 19413 = Down Right 19424 = Down 19435 = Down Left 19446 = Left 19457 = Up Left 1946 led, peakv 1947int soundot[5] = { 73 , 73, 88, 87, 86}; 1948 1949int sb[10] = {0, 1, 9, 25, 41, 57, 73, 89}; // Used for Sound Effect 1950int scntr = 0; // Counts the incremetal change around the sound effect (16 locations) 1951 1952 1953*/ 1954 1955 1956 1957// 6 Bands of color 1958 1959 if (monoPeak >= 10000) { // Highest level of sound (read adjacent dot 4x) 1960 1961 leds[sb[2] + scntr] = CRGB::Red; 1962 leds[sb[3] + scntr] = CRGB::Red; 1963 leds[sb[4] + scntr] = CRGB::Green; 1964 leds[sb[5] + scntr] = CRGB::Green; 1965 leds[sb[6] + scntr] = CRGB::Blue; 1966 leds[sb[7] + scntr] = CRGB::Blue; 1967 1968 } else 1969 1970 if (monoPeak >= 8000 ) { // 2nd Highest level of sound 1971 1972 // leds[sb[2] + scntr] = CRGB::Red; 1973 leds[sb[3] + scntr] = CRGB::Red; 1974 leds[sb[4] + scntr] = CRGB::Green; 1975 leds[sb[5] + scntr] = CRGB::Green; 1976 leds[sb[6] + scntr] = CRGB::Blue; 1977 leds[sb[7] + scntr] = CRGB::Blue; 1978 1979 } else 1980 1981 1982 if (monoPeak >= 6500 ) { // 2nd Highest level of sound 1983 1984 // leds[sb[2] + scntr] = CRGB::Red; 1985 // leds[sb[3] + scntr] = CRGB::Red; 1986 leds[sb[4] + scntr] = CRGB::Green; 1987 leds[sb[5] + scntr] = CRGB::Green; 1988 leds[sb[6] + scntr] = CRGB::Blue; 1989 leds[sb[7] + scntr] = CRGB::Blue; 1990 1991 } else 1992 1993 if (monoPeak >= 5000 ) { // 2nd Highest level of sound 1994 1995 // leds[sb[2] + scntr] = CRGB::Red; 1996 // leds[sb[3] + scntr] = CRGB::Red; 1997 // leds[sb[4] + scntr] = CRGB::Green; 1998 leds[sb[5] + scntr] = CRGB::Green; 1999 leds[sb[6] + scntr] = CRGB::Blue; 2000 leds[sb[7] + scntr] = CRGB::Blue; 2001 2002 } else 2003 2004 2005 if (monoPeak >= 2000 ) { // 2nd Highest level of sound 2006 2007 // leds[sb[2] + scntr] = CRGB::Red; 2008 // leds[sb[3] + scntr] = CRGB::Red; 2009 // leds[sb[4] + scntr] = CRGB::Green; 2010 // leds[sb[5] + scntr] = CRGB::Green; 2011 leds[sb[6] + scntr] = CRGB::Blue; 2012 leds[sb[7] + scntr] = CRGB::Blue; 2013 2014 } else 2015 2016 if (monoPeak >= 1000 ) { // 3rd Highest level of sound 2017 2018 // leds[sb[2] + scntr] = CRGB::Red; 2019 // leds[sb[3] + scntr] = CRGB::Red; 2020 // leds[sb[4] + scntr] = CRGB::Green; 2021 // leds[sb[5] + scntr] = CRGB::Green; 2022 // leds[sb[6] + scntr] = CRGB::Blue; 2023 leds[sb[7] + scntr] = CRGB::Blue; 2024 2025 } 2026 2027 2028 2029 FastLED.show(); 2030 2031// delay(100); 2032 2033 // Increment LED Counter 2034 scntr++; 2035 2036 if (scntr == 6 ) { 2037 // Fade all LEDs to Black 2038 fadeToBlackBy( leds, 25, 15); 2039 fadeToBlackBy( leds, 41, 15); 2040 fadeToBlackBy( leds, 57, 15); 2041 fadeToBlackBy( leds, 73, 15); 2042 fadeToBlackBy( leds, 89, 15); 2043 2044 } else 2045 2046 if (scntr == 12 ) { 2047 // Fade all LEDs to Black 2048 fadeToBlackBy( leds, 25, 15); 2049 fadeToBlackBy( leds, 41, 15); 2050 fadeToBlackBy( leds, 57, 15); 2051 fadeToBlackBy( leds, 73, 15); 2052 fadeToBlackBy( leds, 89, 15); 2053 2054 } else 2055 2056 if (scntr > 15 ) { 2057 scntr = 0; // Reset Counter 2058 // Fade all LEDs to Black 2059 fadeToBlackBy( leds, 25, 15); 2060 fadeToBlackBy( leds, 41, 15); 2061 fadeToBlackBy( leds, 57, 15); 2062 fadeToBlackBy( leds, 73, 15); 2063 fadeToBlackBy( leds, 89, 15); 2064 2065 } 2066 2067 2068 2069 2070} 2071 2072 2073void BouncingBalls(byte red, byte green, byte blue, int BallCount) { 2074 float Gravity = -9.81; 2075 int StartHeight = 1; 2076 2077 float Height[BallCount]; 2078 float ImpactVelocityStart = sqrt( -2 * Gravity * StartHeight ); 2079 float ImpactVelocity[BallCount]; 2080 float TimeSinceLastBounce[BallCount]; 2081 int Position[BallCount]; 2082 long ClockTimeSinceLastBounce[BallCount]; 2083 float Dampening[BallCount]; 2084 2085 for (int i = 0 ; i < BallCount ; i++) { 2086 ClockTimeSinceLastBounce[i] = millis(); 2087 Height[i] = StartHeight; 2088 Position[i] = 0; 2089 ImpactVelocity[i] = ImpactVelocityStart; 2090 TimeSinceLastBounce[i] = 0; 2091 Dampening[i] = 0.90 - float(i)/pow(BallCount,2); 2092 } 2093 2094 while (menu == 8) { 2095 for (int i = 0 ; i < BallCount ; i++) { 2096 TimeSinceLastBounce[i] = millis() - ClockTimeSinceLastBounce[i]; 2097 Height[i] = 0.5 * Gravity * pow( TimeSinceLastBounce[i]/1000 , 2.0 ) + ImpactVelocity[i] * TimeSinceLastBounce[i]/1000; 2098 2099 if ( Height[i] < 0 ) { 2100 Height[i] = 0; 2101 ImpactVelocity[i] = Dampening[i] * ImpactVelocity[i]; 2102 ClockTimeSinceLastBounce[i] = millis(); 2103 2104 if ( ImpactVelocity[i] < 0.01 ) { 2105 ImpactVelocity[i] = ImpactVelocityStart; 2106 } 2107 } 2108 Position[i] = round( Height[i] * (NUM_LEDS - 1) / StartHeight); 2109 } 2110 2111 for (int i = 0 ; i < BallCount ; i++) { 2112 leds[Position[i]].setRGB( random(255),random(255),random(255)); 2113 FastLED.show(); 2114 } 2115 2116 2117fadeToBlackBy( leds, 130, 5); 2118 2119 } 2120 2121 2122} 2123 2124//******************************************** 2125// SoundEffect 6 2126// ******************************************* 2127void SoundEffect6() { // At last a stable Audio input circuit !! Teensy A2 connected to 4.7uf and SP1 on freetronics Mic. Also Analog Ground used with Mic 2128 2129clr4 = random(255); 2130clr5 = random(255); 2131clr6 = random(255); 2132 2133// Use the Ampliyude of the Mic input to set the VU Display which is a Bar graph circling the Shpere 2134 2135 2136 if (fps > 24) { 2137 if (peak1.available()) { 2138 fps = 0; 2139 monoPeak = abs((peak1.read() * 139.0)) - 9; // Remove noise level of 9 2140 if (monoPeak >129 ) { 2141 monoPeak = 129; 2142 } 2143 } 2144 2145 } 2146 2147 fill_solid( &(leds[0]), monoPeak, CRGB( clr4, clr5, clr6 ) ); 2148 2149 FastLED.show(); 2150 2151 delay(5); 2152 2153 fadeToBlackBy( leds, 130, 5); 2154 2155 FastLED.show(); 2156 2157 Serial.println(monoPeak); 2158 2159} 2160 2161//******************************************** 2162// SoundEffect 7 2163// ******************************************* 2164void SoundEffect7() { // At last a stable Audio input circuit !! Teensy A2 connected to 4.7uf and SP1 on freetronics Mic. Also Analog Ground used with Mic 2165 2166if (cal == false) { // Display the menu Item 2167 four(); 2168 cal = true; 2169} 2170 2171clr6 = random(3); 2172 2173// Use the Amplitude of the Mic input to set the VU Display which is a Bar graph circling the Shpere 2174 2175 2176 if (fps > 24) { 2177 if (peak1.available()) { 2178 fps = 0; 2179 monoPeak = abs((peak1.read() * 139.0)) - 9; // Remove noise level of 9 2180 if (monoPeak >129 ) { 2181 monoPeak = 129; 2182 } 2183 } 2184 2185 } 2186 2187 2188 2189if (clr6 == 0 ) { 2190 fill_solid( &(leds[0]), monoPeak , CRGB::Blue); 2191} else 2192 2193if (clr6 == 1 ) { 2194 fill_solid( &(leds[0]), monoPeak , CRGB::Green); 2195} else 2196 2197if (clr6 == 2 ) { 2198 fill_solid( &(leds[0]), monoPeak , CRGB::Red); 2199} 2200 2201 2202 // fill_solid( &(leds[0]), monoPeak, CRGB( clr4, clr5, clr6 ) ); 2203 2204 FastLED.show(); 2205 2206 delay(3); 2207 2208 fadeToBlackBy( leds, 130, 10); 2209 2210 FastLED.show(); 2211 2212 2213} 2214 2215//******************************************** 2216// DotSnakesSlow 2217// ******************************************* 2218 2219void DotSnakesSlow() { 2220 2221if (cal == false) { // Display the menu Item 2222 five(); 2223 cal = true; 2224} 2225 2226// Use the Amplitude of the Mic input to set the delay for the DotSnakes 2227 2228 2229 if (fps > 24) { 2230 if (peak1.available()) { 2231 fps = 0; 2232 monoPeak = abs((peak1.read() * td)); // Remove noise level 2233 if (monoPeak >td ) { 2234 monoPeak = td; 2235 } 2236 } 2237 2238 } 2239 2240 //Clear all current LEDs 2241 2242 2243 leds[dot[0][0]] = CRGB::Black; // Turn off current LED position 2244 leds[dot[0][2]] = CRGB::Black; // Turn off current LED position 2245 leds[dot[0][3]] = CRGB::Black; // Turn off current LED position 2246 leds[dot[0][4]] = CRGB::Black; // Turn off current LED position 2247 2248 leds[dot[1][0]] = CRGB::Black; // Turn off current LED position 2249 leds[dot[1][2]] = CRGB::Black; // Turn off current LED position 2250 leds[dot[1][3]] = CRGB::Black; // Turn off current LED position 2251 leds[dot[1][4]] = CRGB::Black; // Turn off current LED position 2252 2253 leds[dot[2][0]] = CRGB::Black; // Turn off current LED position 2254 leds[dot[2][2]] = CRGB::Black; // Turn off current LED position 2255 leds[dot[2][3]] = CRGB::Black; // Turn off current LED position 2256 leds[dot[2][4]] = CRGB::Black; // Turn off current LED position 2257 2258 leds[dot[3][0]] = CRGB::Black; // Turn off current LED position 2259 leds[dot[3][2]] = CRGB::Black; // Turn off current LED position 2260 leds[dot[3][3]] = CRGB::Black; // Turn off current LED position 2261 leds[dot[3][4]] = CRGB::Black; // Turn off current LED position 2262 FastLED.show(); 2263 2264//if (monoPeak > 1) { // No sound blank ball 2265 2266 2267 // Dot 0 ********************************************************** 2268 2269 2270 // Randomly change direction of Dot 2271 2272 direct = random8(8); // Randomly determine new direction 2273 2274 // Check not going backwards 2275 while ((abs(dot[0][1] - direct)) == 4){ 2276 direct = random8(8); // Randomly determine new direction 2277 } 2278 2279 dot[0][1] = direct; // Store value in array 2280 2281 2282 2283 // Update position of data based on new direction before displaying 2284 dot[0][4] = dot[0][3]; // Store prevprev into prevprevprev location 2285 dot[0][3] = dot[0][2]; // Store prev into prevprev location 2286 dot[0][2] = dot[0][0]; // Store current into prev location 2287 2288 dot[0][0]= pixel[dot[0][0]][dot[0][1]]; // Use function to read data back from array in Progam Memory 2289 2290 2291 2292 2293 // Dot 1********************************************************** 2294 2295 2296 // Randomly change direction of Dot 2297 direct = random8(8); // Randomly determine new direction 2298 // Check not going backwards 2299 while ((abs(dot[1][1] - direct)) == 4){ 2300 direct = random8(8); // Randomly determine new direction 2301 } 2302 2303 dot[1][1] = direct; // Modify lead dot position and store value in array 2304 2305 2306 2307 2308 // Update position of data based on new direction before displaying 2309 dot[1][4] = dot[1][3]; // Store prevprev into prevprevprev location 2310 dot[1][3] = dot[1][2]; // Store prev into prevprev location 2311 dot[1][2] = dot[1][0]; // Store current into prev location 2312 2313 dot[1][0]= pixel[dot[1][0]][dot[1][1]]; // Use function to read data back from array in Progam Memory 2314 2315 2316 2317 2318 // Dot 2 ***************************************** 2319 2320 2321 // Randomly change direction of Dot 2322 direct = random8(8); // Randomly determine new direction 2323 // Check not going backwards 2324 while ((abs(dot[2][1] - direct)) == 4){ 2325 direct = random8(8); // Randomly determine new direction 2326 } 2327 2328 dot[2][1] = direct; // Store value in array 2329 2330 2331 2332 2333 // Update position of data based on new direction before displaying 2334 dot[2][4] = dot[2][3]; // Store prevprev into prevprevprev location 2335 dot[2][3] = dot[2][2]; // Store prev into prevprev location 2336 dot[2][2] = dot[2][0]; // Store current into prev location 2337 2338 dot[2][0]= pixel[dot[2][0]][dot[2][1]]; // Use pgm_read_byte function to read data back from array in Progam Memory 2339 2340 2341 2342 2343 2344 // Dot 3 ***************************************** 2345 2346 2347 // Randomly change direction of Dot 2348 direct = random8(8); // Randomly determine new direction 2349 // Check not going backwards 2350 while ((abs(dot[3][1] - direct)) == 4){ 2351 direct = random8(8); // Randomly determine new direction 2352 } 2353 dot[3][1] = direct; // Store value in array 2354 2355 2356 2357 2358 2359 // Update position of data based on new direction before displaying 2360 dot[3][4] = dot[3][3]; // Store prevprev into prevprevprev location 2361 dot[3][3] = dot[3][2]; // Store prev into prevprev location 2362 dot[3][2] = dot[3][0]; // Store current into prev location 2363 2364 dot[3][0]= pixel[dot[3][0]][dot[3][1]]; // Use pgm_read_byte function to read data back from array in Progam Memory 2365 2366 2367 // delay(100); 2368 2369 leds[dot[0][0]] = CRGB::Blue; 2370 leds[dot[0][2]] = CRGB::Blue; 2371 leds[dot[0][3]] = CRGB::Blue; 2372 leds[dot[0][4]] = CRGB::Blue; 2373 2374 leds[dot[1][0]] = CRGB::Red; 2375 leds[dot[1][2]] = CRGB::Red; 2376 leds[dot[1][3]] = CRGB::Red; 2377 leds[dot[1][4]] = CRGB::Red; 2378 2379 leds[dot[2][0]] = CRGB::Green; 2380 leds[dot[2][2]] = CRGB::Green; 2381 leds[dot[2][3]] = CRGB::Green; 2382 leds[dot[2][4]] = CRGB::Green; 2383 2384 leds[dot[3][0]] = CRGB::Purple; 2385 leds[dot[3][2]] = CRGB::Purple; 2386 leds[dot[3][3]] = CRGB::Purple; 2387 leds[dot[3][4]] = CRGB::Purple; 2388 2389 FastLED.show(); 2390 2391 2392// Serial.println(monoPeak); 2393 2394 delay(monoPeak*2); 2395//} 2396 2397} 2398 2399//******************************************** 2400// SoundRing 2401// ******************************************* 2402void SoundRing() { // GyroLED Snakes down sphere 2403 2404 if (fps > 24) { 2405 if (peak1.available()) { 2406 fps = 0; 2407 monoPeak = abs((peak1.read() * tsr)); // Remove noise level 2408 if (monoPeak >tsr ) { 2409 monoPeak = tsr; 2410 } 2411 } 2412 } 2413 2414 2415 2416 2417 // Step Through Layers from top to bottom ring on ball and speed up with louder music 2418 2419 srctr++; // Increment counter 2420 if ( srctr > 10 ) { 2421 srctr = 0; // Reset Counter to top ring on ball 2422 } 2423 2424 2425if (monoPeak > 10 ) { 2426 2427 // 11 Bands of color 2428 // fill_solid( &(leds[0]), 130, CHSV( monoPeak, 0, 0) );// First blank all LEDs 2429 2430 2431 if (srctr == 0) { 2432 fill_solid( &(leds[0]), 1, CHSV( 224-monoPeak, 255, 255) ); 2433 } else 2434 2435 if (srctr == 1) { 2436 fill_solid( &(leds[1]), 8 , CHSV( 224-monoPeak, 255, 255) ); 2437 }else 2438 2439 if (srctr == 2) { 2440 fill_solid( &(leds[9]), 16 , CHSV( 224-monoPeak, 255, 255) ); 2441 2442 }else 2443 2444 if (srctr == 3) { 2445 fill_solid( &(leds[25]), 16, CHSV( 224-monoPeak, 255, 255) ); 2446 }else 2447 2448 if (srctr == 4) { 2449 fill_solid( &(leds[41]), 16 , CHSV( 224-monoPeak, 255, 255) ); 2450 }else 2451 2452 if (srctr == 5) { 2453 fill_solid( &(leds[57]), 16 , CHSV( 224-monoPeak, 255, 255) ); 2454 }else 2455 2456 if (srctr == 6) { 2457 fill_solid( &(leds[73]), 16, CHSV( 224-monoPeak, 255, 255) ); 2458 }else 2459 2460 if (srctr == 7) { 2461 fill_solid( &(leds[89]), 16 , CHSV( 224-monoPeak, 255, 255) ); 2462 }else 2463 2464 if (srctr == 8) { 2465 fill_solid( &(leds[105]), 16 , CHSV( 224-monoPeak, 255, 255) ); 2466 }else 2467 2468 if (srctr == 9) { 2469 fill_solid( &(leds[121]), 8, CHSV( 224-monoPeak, 255, 255) ); 2470 }else 2471 2472 if (srctr == 10) { 2473 fill_solid( &(leds[129]), 1 , CHSV( 224-monoPeak, 255, 255) ); 2474 } 2475 FastLED.show(); 2476} else { 2477 2478 fadeToBlackBy( leds, 130, 8); 2479 FastLED.show(); 2480} 2481// Serial.println(monoPeak); 2482 2483 2484} 2485 2486//******************************************** 2487// SoundRingStep 2488// ******************************************* 2489void SoundRingStep() { // GyroLED Snakes down sphere 2490 2491if (cal == false) { // Display the menu Item 2492 three(); 2493 cal = true; 2494} 2495 2496 if (fps > 24) { 2497 if (peak1.available()) { 2498 fps = 0; 2499 monoPeak = abs((peak1.read() * 160)); // Remove noise level 2500 if (monoPeak >160 ) { 2501 monoPeak = 160; 2502 } 2503 } 2504 } 2505 2506 2507 srs = 10; 2508 2509 // Step Through Layers from top to bottom ring on ball and speed up with louder music 2510 2511 srctr++; // Increment counter 2512 if ( srctr > 10 ) { 2513 srctr = 0; // Reset Counter to top ring on ball 2514 } 2515 2516 2517if (monoPeak >10 ) { 2518 2519 // 11 Bands of color 2520 // fill_solid( &(leds[0]), 130, CHSV( monoPeak, 0, 0) );// First blank all LEDs 2521 2522 2523 if (srctr == 0) { 2524 fill_solid( &(leds[0]), 1, CHSV( 160-monoPeak, 255, 255) ); 2525 FastLED.show(); 2526 delay(srs); 2527 // fill_solid( &(leds[0]), 1, CHSV( 0, 0, 0) ); 2528 2529 } else 2530 2531 if (srctr == 1) { 2532 fill_solid( &(leds[1]), 8 , CHSV( 160-monoPeak, 255, 255) ); 2533 FastLED.show(); 2534 delay(srs); 2535 // fill_solid( &(leds[1]), 8, CHSV( 0, 0, 0) ); 2536 2537 }else 2538 2539 if (srctr == 2) { 2540 fill_solid( &(leds[9]), 16 , CHSV( 160-monoPeak, 255, 255) ); 2541 FastLED.show(); 2542 delay(srs); 2543 // fill_solid( &(leds[9]), 16, CHSV( 0, 0, 0) ); 2544 2545 }else 2546 2547 if (srctr == 3) { 2548 fill_solid( &(leds[25]), 16, CHSV( 160-monoPeak, 255, 255) ); 2549 FastLED.show(); 2550 delay(srs); 2551// fill_solid( &(leds[25]), 16, CHSV( 0, 0, 0) ); 2552 2553 }else 2554 2555 if (srctr == 4) { 2556 fill_solid( &(leds[41]), 16 , CHSV( 160-monoPeak, 255, 255) ); 2557 FastLED.show(); 2558 delay(srs); 2559// fill_solid( &(leds[41]), 16, CHSV( 0, 0, 0) ); 2560 2561 }else 2562 2563 if (srctr == 5) { 2564 fill_solid( &(leds[57]), 16 , CHSV( 160-monoPeak, 255, 255) ); 2565 FastLED.show(); 2566 delay(srs); 2567 // fill_solid( &(leds[57]), 16, CHSV( 0, 0, 0) ); 2568 2569 }else 2570 2571 if (srctr == 6) { 2572 fill_solid( &(leds[73]), 16, CHSV( 160-monoPeak, 255, 255) ); 2573 FastLED.show(); 2574 delay(srs); 2575 // fill_solid( &(leds[73]), 16, CHSV( 0, 0, 0) ); 2576 2577 }else 2578 2579 if (srctr == 7) { 2580 fill_solid( &(leds[89]), 16 , CHSV( 160-monoPeak, 255, 255) ); 2581 FastLED.show(); 2582 delay(srs); 2583 // fill_solid( &(leds[89]), 16, CHSV( 0, 0, 0) ); 2584 2585 }else 2586 2587 if (srctr == 8) { 2588 fill_solid( &(leds[105]), 16 , CHSV( 160-monoPeak, 255, 255) ); 2589 FastLED.show(); 2590 delay(srs); 2591 // fill_solid( &(leds[105]), 16, CHSV( 0, 0, 0) ); 2592 2593 }else 2594 2595 if (srctr == 9) { 2596 fill_solid( &(leds[121]), 8, CHSV( 160-monoPeak, 255, 255) ); 2597 FastLED.show(); 2598 delay(srs); 2599 // fill_solid( &(leds[121]), 8, CHSV( 0, 0, 0) ); 2600 2601 }else 2602 2603 if (srctr == 10) { 2604 fill_solid( &(leds[129]), 1 , CHSV( 160-monoPeak, 255, 255) ); 2605 FastLED.show(); 2606 delay(srs); 2607 2608 2609 2610 } 2611 }else { 2612 fadeToBlackBy( leds, 130, 2); 2613 FastLED.show(); 2614 } 2615// Serial.println(monoPeak); 2616 2617 2618} 2619 2620//******************************************** 2621// SoundRingStepBar 2622// ******************************************* 2623void SoundRingStepBar() { // GyroLED Snakes down sphere 2624 2625 if (fps > 24) { 2626 if (peak1.available()) { 2627 fps = 0; 2628 monoPeak = abs((peak1.read() * 160)); // TThis limits spectrum from Red to Blue which us reversed below for Bar effect 2629 if (monoPeak >160 ) { 2630 monoPeak = 160; 2631 } 2632 } 2633 } 2634 2635 2636 srs = 0; // Sets minimum delay between each ring being left on 2637 2638 // Step Through Layers from top to bottom ring on ball and speed up with louder music 2639 2640 2641 2642if (monoPeak >10 ) { 2643 2644 // 11 Bands of color 2645 // fill_solid( &(leds[0]), 130, CHSV( monoPeak, 0, 0) );// First blank all LEDs 2646 2647 2648 if (monoPeak > 10) { 2649 fill_solid( &(leds[0]), 1, CHSV( 160-monoPeak, 255, 255) ); 2650 FastLED.show(); 2651 delay(srs); 2652 // fill_solid( &(leds[0]), 1, CHSV( 0, 0, 0) ); 2653 2654 } else 2655 2656 if (monoPeak > 35) { 2657 fill_solid( &(leds[1]), 8 , CHSV( 160-monoPeak, 255, 255) ); 2658 FastLED.show(); 2659 delay(srs); 2660 // fill_solid( &(leds[1]), 8, CHSV( 0, 0, 0) ); 2661 2662 } else 2663 2664 if (monoPeak > 55) { 2665 fill_solid( &(leds[9]), 16 , CHSV( 160-monoPeak, 255, 255) ); 2666 FastLED.show(); 2667 delay(srs); 2668 // fill_solid( &(leds[9]), 16, CHSV( 0, 0, 0) ); 2669 2670 } else 2671 2672 if (monoPeak > 75) { 2673 fill_solid( &(leds[25]), 16, CHSV( 160-monoPeak, 255, 255) ); 2674 FastLED.show(); 2675 delay(srs); 2676// fill_solid( &(leds[25]), 16, CHSV( 0, 0, 0) ); 2677 2678 } else 2679 2680 if (monoPeak > 95) { 2681 fill_solid( &(leds[41]), 16 , CHSV( 160-monoPeak, 255, 255) ); 2682 FastLED.show(); 2683 delay(srs); 2684// fill_solid( &(leds[41]), 16, CHSV( 0, 0, 0) ); 2685 2686 } else 2687 2688 if (monoPeak > 115) { 2689 fill_solid( &(leds[57]), 16 , CHSV( 160-monoPeak, 255, 255) ); 2690 FastLED.show(); 2691 delay(srs); 2692 // fill_solid( &(leds[57]), 16, CHSV( 0, 0, 0) ); 2693 2694 } else 2695 2696 if (monoPeak > 125) { 2697 fill_solid( &(leds[73]), 16, CHSV( 160-monoPeak, 255, 255) ); 2698 FastLED.show(); 2699 delay(srs); 2700 // fill_solid( &(leds[73]), 16, CHSV( 0, 0, 0) ); 2701 2702 } else 2703 2704 if (monoPeak > 135) { 2705 fill_solid( &(leds[89]), 16 , CHSV( 160-monoPeak, 255, 255) ); 2706 FastLED.show(); 2707 delay(srs); 2708 // fill_solid( &(leds[89]), 16, CHSV( 0, 0, 0) ); 2709 2710 } else 2711 2712 if (monoPeak > 145) { 2713 fill_solid( &(leds[105]), 16 , CHSV( 160-monoPeak, 255, 255) ); 2714 FastLED.show(); 2715 delay(srs); 2716 // fill_solid( &(leds[105]), 16, CHSV( 0, 0, 0) ); 2717 2718 } else 2719 2720 if (monoPeak > 150) { 2721 fill_solid( &(leds[121]), 8, CHSV( 160-monoPeak, 255, 255) ); 2722 FastLED.show(); 2723 delay(srs); 2724 // fill_solid( &(leds[121]), 8, CHSV( 0, 0, 0) ); 2725 2726 } else 2727 2728 if (monoPeak > 155) { 2729 fill_solid( &(leds[129]), 1 , CHSV( 160-monoPeak, 255, 255) ); 2730 FastLED.show(); 2731 delay(srs); 2732 2733 2734 2735 } 2736 }else { 2737 fadeToBlackBy( leds, 130, 2); 2738 FastLED.show(); 2739 } 2740// Serial.println(monoPeak); 2741 2742 2743} 2744 2745//******************************************** 2746// DotOnTopSound 2747// ******************************************* 2748void DotOnTopSound() { // Sound Bubble stays in top of sphere 2749 2750 2751 2752 if (fps > 24) { 2753 if (peak1.available()) { 2754 fps = 0; 2755 monoPeak = abs((peak1.read() * 160)); // TThis limits spectrum from Red to Blue which us reversed below for Bar effect 2756 if (monoPeak >160 ) { 2757 monoPeak = 160; 2758 } 2759 } 2760 } 2761 2762// Normalise Smoothed Values 2763Xnormalise = smoothedX + 18100; 2764Ynormalise = smoothedY + 18100; 2765Znormalise = smoothedZ + 18100; 2766 2767// Display dot on top of ball 2768 2769// leds[dt] = CRGB::Blue; 2770// FastLED.show(); 2771 2772// Identify from Array new position of the Dot 2773 2774int tolerance = 2000;// X,Y,Z must meet this criteria to turn on LED 2775int gc=0; // Points to LED to be tested 2776boolean gf = false; // Flag to indicate coordinate found no need to search further 2777 2778// Temp calc variables 2779int tX = 0; 2780int tY = 0; 2781int tZ = 0; 2782 2783 2784 2785while ( (gc<130) && (gf == false)) { // For LEDS on top of Sphere 2786 // Read in Data from Array and Test Against Gyro Coordinates 2787 2788 tX = pixel[gc][10]; 2789 tY = pixel[gc][11]; 2790 tZ = pixel[gc][12]; 2791 2792 2793 if ( (Xnormalise < (tX+tolerance)) && (Xnormalise > (tX-tolerance))) { 2794 2795 if ( (Ynormalise < (tY+tolerance)) && (Ynormalise > (tY-tolerance))) { 2796 2797 if ( (Znormalise < (tZ+tolerance)) && (Znormalise > (tZ-tolerance))) { 2798 2799 // Set pointer to new LED and display it 2800 dt = gc; 2801 gf = true; // Set flag to exit While Loop 2802 leds[dt] = CRGB::Green; 2803 2804 /* 2805 * LED Position 2806 0 = Up 2807 1 = Up Right 2808 2 = Right 2809 3 = Down Right 2810 4 = Down 2811 5 = Down Left 2812 6 = Left 2813 7 = Up Left 2814 * 2815 */ 2816 2817 2818 if (monoPeak > 50) { 2819 leds[pixel[dt][0]] = CRGB::Red; 2820 leds[pixel[dt][1]] = CRGB::Red; 2821 leds[pixel[dt][2]] = CRGB::Red; 2822 leds[pixel[dt][3]] = CRGB::Red; 2823 leds[pixel[dt][4]] = CRGB::Red; 2824 leds[pixel[dt][5]] = CRGB::Red; 2825 leds[pixel[dt][6]] = CRGB::Red; 2826 leds[pixel[dt][7]] = CRGB::Red; 2827 2828 } 2829 2830 if (monoPeak > 140) { 2831 2832 leds[pixel[pixel[dt][0]][0]] = CRGB::Blue; 2833 2834 leds[pixel[pixel[dt][1]][0]] = CRGB::Blue; 2835 leds[pixel[pixel[dt][1]][2]] = CRGB::Blue; 2836 2837 leds[pixel[pixel[dt][2]][2]] = CRGB::Blue; 2838 2839 2840 leds[pixel[pixel[dt][3]][2]] = CRGB::Blue; 2841 leds[pixel[pixel[dt][3]][4]] = CRGB::Blue; 2842 2843 2844 leds[pixel[pixel[dt][4]][4]] = CRGB::Blue; 2845 2846 leds[pixel[pixel[dt][5]][4]] = CRGB::Blue; 2847 leds[pixel[pixel[dt][5]][6]] = CRGB::Blue; 2848 2849 leds[pixel[pixel[dt][6]][6]] = CRGB::Blue; 2850 2851 leds[pixel[pixel[dt][7]][0]] = CRGB::Blue; 2852 leds[pixel[pixel[dt][7]][6]] = CRGB::Blue; 2853 2854 } 2855 2856 2857 FastLED.show(); 2858 delay(10); 2859 2860 2861 leds[dt] = CRGB::Black; 2862 leds[pixel[dt][0]] = CRGB::Black; 2863 2864 leds[pixel[dt][1]] = CRGB::Black; 2865 leds[pixel[dt][2]] = CRGB::Black; 2866 leds[pixel[dt][3]] = CRGB::Black; 2867 leds[pixel[dt][4]] = CRGB::Black; 2868 leds[pixel[dt][5]] = CRGB::Black; 2869 leds[pixel[dt][6]] = CRGB::Black; 2870 leds[pixel[dt][7]] = CRGB::Black; 2871 2872 2873 leds[pixel[pixel[dt][0]][0]] = CRGB::Black; 2874 2875 leds[pixel[pixel[dt][1]][0]] = CRGB::Black; 2876 leds[pixel[pixel[dt][1]][2]] = CRGB::Black; 2877 2878 leds[pixel[pixel[dt][2]][2]] = CRGB::Black; 2879 2880 2881 leds[pixel[pixel[dt][3]][2]] = CRGB::Black; 2882 leds[pixel[pixel[dt][3]][4]] = CRGB::Black; 2883 2884 2885 leds[pixel[pixel[dt][4]][4]] = CRGB::Black; 2886 2887 leds[pixel[pixel[dt][5]][4]] = CRGB::Black; 2888 leds[pixel[pixel[dt][5]][6]] = CRGB::Black; 2889 2890 leds[pixel[pixel[dt][6]][6]] = CRGB::Black; 2891 2892 leds[pixel[pixel[dt][7]][0]] = CRGB::Black; 2893 leds[pixel[pixel[dt][7]][6]] = CRGB::Black; 2894 2895 2896 2897 2898 FastLED.show(); 2899 } 2900 2901 } 2902 } 2903 2904 // leds[i].setRGB( (Xcol), (Ycol), (Zcol)); 2905 2906 //Increment counter 2907 gc++; 2908 } 2909 2910} 2911 2912//******************************************** 2913// Counter 2914// ******************************************* 2915void Counter() { // LED stays in top of sphere 2916 2917 2918 2919 if (nctr == 9) { 2920 nine(); 2921 } else 2922 2923 if (nctr == 8) { 2924 eight(); 2925 } else 2926 if (nctr == 7) { 2927 seven(); 2928 } else 2929 if (nctr == 6) { 2930 six(); 2931 } else 2932 2933 if (nctr == 5) { 2934 five(); 2935 } else 2936 if (nctr == 4) { 2937 four(); 2938 } else 2939 if (nctr == 3) { 2940 three(); 2941 } else 2942 2943 if (nctr == 2) { 2944 two(); 2945 } else 2946 if (nctr == 1) { 2947 one(); 2948 } else 2949 if (nctr == 0) { 2950 zero(); 2951 } 2952 2953 nctr--; 2954 if (nctr < 0) { 2955 nctr = 9; 2956 } 2957 2958 2959 2960} 2961 2962//******************************************** 2963// DotsnakesSpeed 2964// ******************************************* 2965 2966void DotSnakesSpeed() { 2967 2968// Use the Amplitude of the Mic input to set the delay for the DotSnakes 2969 2970 2971 if (fps > 24) { 2972 if (peak1.available()) { 2973 fps = 0; 2974 monoPeak = abs((peak1.read() * td)); // Remove noise level 2975 if (monoPeak >td ) { 2976 monoPeak = td; 2977 } 2978 } 2979 2980 } 2981 2982 //Clear all current LEDs 2983 2984 2985 leds[dot[0][0]] = CRGB::Black; // Turn off current LED position 2986 leds[dot[0][2]] = CRGB::Black; // Turn off current LED position 2987 leds[dot[0][3]] = CRGB::Black; // Turn off current LED position 2988 leds[dot[0][4]] = CRGB::Black; // Turn off current LED position 2989 2990 leds[dot[1][0]] = CRGB::Black; // Turn off current LED position 2991 leds[dot[1][2]] = CRGB::Black; // Turn off current LED position 2992 leds[dot[1][3]] = CRGB::Black; // Turn off current LED position 2993 leds[dot[1][4]] = CRGB::Black; // Turn off current LED position 2994 2995 leds[dot[2][0]] = CRGB::Black; // Turn off current LED position 2996 leds[dot[2][2]] = CRGB::Black; // Turn off current LED position 2997 leds[dot[2][3]] = CRGB::Black; // Turn off current LED position 2998 leds[dot[2][4]] = CRGB::Black; // Turn off current LED position 2999 3000 leds[dot[3][0]] = CRGB::Black; // Turn off current LED position 3001 leds[dot[3][2]] = CRGB::Black; // Turn off current LED position 3002 leds[dot[3][3]] = CRGB::Black; // Turn off current LED position 3003 leds[dot[3][4]] = CRGB::Black; // Turn off current LED position 3004 FastLED.show(); 3005 3006//if (monoPeak > 1) { // No sound blank ball 3007 3008 3009 // Dot 0 ********************************************************** 3010 3011 3012 // Randomly change direction of Dot 3013 3014 direct = random8(8); // Randomly determine new direction 3015 3016 // Check not going backwards 3017 while ((abs(dot[0][1] - direct)) == 4){ 3018 direct = random8(8); // Randomly determine new direction 3019 } 3020 3021 dot[0][1] = direct; // Store value in array 3022 3023 3024 3025 // Update position of data based on new direction before displaying 3026 dot[0][4] = dot[0][3]; // Store prevprev into prevprevprev location 3027 dot[0][3] = dot[0][2]; // Store prev into prevprev location 3028 dot[0][2] = dot[0][0]; // Store current into prev location 3029 3030 dot[0][0]= pixel[dot[0][0]][dot[0][1]]; // Use function to read data back from array in Progam Memory 3031 3032 3033 3034 3035 // Dot 1********************************************************** 3036 3037 3038 // Randomly change direction of Dot 3039 direct = random8(8); // Randomly determine new direction 3040 // Check not going backwards 3041 while ((abs(dot[1][1] - direct)) == 4){ 3042 direct = random8(8); // Randomly determine new direction 3043 } 3044 3045 dot[1][1] = direct; // Modify lead dot position and store value in array 3046 3047 3048 3049 3050 // Update position of data based on new direction before displaying 3051 dot[1][4] = dot[1][3]; // Store prevprev into prevprevprev location 3052 dot[1][3] = dot[1][2]; // Store prev into prevprev location 3053 dot[1][2] = dot[1][0]; // Store current into prev location 3054 3055 dot[1][0]= pixel[dot[1][0]][dot[1][1]]; // Use function to read data back from array in Progam Memory 3056 3057 3058 3059 3060 // Dot 2 ***************************************** 3061 3062 3063 // Randomly change direction of Dot 3064 direct = random8(8); // Randomly determine new direction 3065 // Check not going backwards 3066 while ((abs(dot[2][1] - direct)) == 4){ 3067 direct = random8(8); // Randomly determine new direction 3068 } 3069 3070 dot[2][1] = direct; // Store value in array 3071 3072 3073 3074 3075 // Update position of data based on new direction before displaying 3076 dot[2][4] = dot[2][3]; // Store prevprev into prevprevprev location 3077 dot[2][3] = dot[2][2]; // Store prev into prevprev location 3078 dot[2][2] = dot[2][0]; // Store current into prev location 3079 3080 dot[2][0]= pixel[dot[2][0]][dot[2][1]]; // Use pgm_read_byte function to read data back from array in Progam Memory 3081 3082 3083 3084 3085 3086 // Dot 3 ***************************************** 3087 3088 3089 // Randomly change direction of Dot 3090 direct = random8(8); // Randomly determine new direction 3091 // Check not going backwards 3092 while ((abs(dot[3][1] - direct)) == 4){ 3093 direct = random8(8); // Randomly determine new direction 3094 } 3095 dot[3][1] = direct; // Store value in array 3096 3097 3098 3099 3100 3101 // Update position of data based on new direction before displaying 3102 dot[3][4] = dot[3][3]; // Store prevprev into prevprevprev location 3103 dot[3][3] = dot[3][2]; // Store prev into prevprev location 3104 dot[3][2] = dot[3][0]; // Store current into prev location 3105 3106 dot[3][0]= pixel[dot[3][0]][dot[3][1]]; // Use pgm_read_byte function to read data back from array in Progam Memory 3107 3108 3109 // delay(100); 3110 3111 leds[dot[0][0]] = CRGB::Blue; 3112 leds[dot[0][2]] = CRGB::Blue; 3113 leds[dot[0][3]] = CRGB::Blue; 3114 leds[dot[0][4]] = CRGB::Blue; 3115 3116 leds[dot[1][0]] = CRGB::Red; 3117 leds[dot[1][2]] = CRGB::Red; 3118 leds[dot[1][3]] = CRGB::Red; 3119 leds[dot[1][4]] = CRGB::Red; 3120 3121 leds[dot[2][0]] = CRGB::Green; 3122 leds[dot[2][2]] = CRGB::Green; 3123 leds[dot[2][3]] = CRGB::Green; 3124 leds[dot[2][4]] = CRGB::Green; 3125 3126 leds[dot[3][0]] = CRGB::Purple; 3127 leds[dot[3][2]] = CRGB::Purple; 3128 leds[dot[3][3]] = CRGB::Purple; 3129 leds[dot[3][4]] = CRGB::Purple; 3130 3131 FastLED.show(); 3132 3133 3134// Serial.println(monoPeak); 3135 3136 delay(240 - monoPeak*2); 3137//} 3138 3139} 3140 3141 3142
Downloadable files
LED Gyro Sphere Circuit
A unique, cool interactive LED Sphere using a Gyro and Sound sensors create a colorful fun interactive gadget.
LED Gyro Sphere Circuit

Documentation
Thingiverse
https://www.thingiverse.com/thing:2776550
https://www.thingiverse.com/thing:2776550
Comments
Only logged in users can leave comments