├── .DS_Store ├── Code ├── .DS_Store ├── LED_suit_remote │ ├── .DS_Store │ └── LED_suit_remote.ino ├── LED_suit_vest_no_bluetooth │ └── LED_suit_vest_no_bluetooth.ino └── LED_suit_vest_bluetooth │ └── LED_suit_vest_bluetooth.ino ├── img ├── .DS_Store └── readme │ ├── .DS_Store │ └── lightvest-back-left.png ├── 3D Prints ├── .DS_Store ├── PCB DESIGN │ ├── .DS_Store │ └── REMOTE FINAL │ │ ├── .DS_Store │ │ └── STL │ │ ├── .DS_Store │ │ ├── PCB_TOP.stl │ │ ├── PCB_BOTTOM.stl │ │ ├── PCB_BUTTON.stl │ │ └── PCB_REMOTE_RAW.stl ├── BIKE MOUNT CLIPS │ ├── .DS_Store │ └── STL │ │ ├── .DS_Store │ │ ├── clippers.stl │ │ ├── top-mount.stl │ │ ├── Bike Clips.stl │ │ └── bottom-mount.stl └── BREADBOARD DESIGN │ ├── .DS_Store │ ├── Remote │ ├── .DS_Store │ └── STL │ │ ├── .DS_Store │ │ ├── button-up-down.stl │ │ ├── button-left-right.stl │ │ ├── breadboard-remote-top.stl │ │ └── breadboard-remote-bottom.stl │ └── Vest Container │ ├── .DS_Store │ └── STL │ ├── .DS_Store │ └── LightVest-Vest-Container.stl ├── Diagrams ├── .DS_Store ├── LED_bike_vest.fzz ├── LED_bike_remote.fzz ├── LED_bike_vest_bb.png ├── LED_bike_remote_bb.png ├── LED_bike_remote_no_mpu.fzz └── LED_bike_remote_no_mpu_bb.png ├── Schematics ├── .DS_Store ├── LIGHTVEST_LED_VEST │ └── .DS_Store └── LIGHTVEST_LED_REMOTE │ └── .DS_Store └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/.DS_Store -------------------------------------------------------------------------------- /Code/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/Code/.DS_Store -------------------------------------------------------------------------------- /img/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/img/.DS_Store -------------------------------------------------------------------------------- /3D Prints/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/.DS_Store -------------------------------------------------------------------------------- /Diagrams/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/Diagrams/.DS_Store -------------------------------------------------------------------------------- /Schematics/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/Schematics/.DS_Store -------------------------------------------------------------------------------- /img/readme/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/img/readme/.DS_Store -------------------------------------------------------------------------------- /Diagrams/LED_bike_vest.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/Diagrams/LED_bike_vest.fzz -------------------------------------------------------------------------------- /Diagrams/LED_bike_remote.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/Diagrams/LED_bike_remote.fzz -------------------------------------------------------------------------------- /Diagrams/LED_bike_vest_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/Diagrams/LED_bike_vest_bb.png -------------------------------------------------------------------------------- /3D Prints/PCB DESIGN/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/PCB DESIGN/.DS_Store -------------------------------------------------------------------------------- /Code/LED_suit_remote/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/Code/LED_suit_remote/.DS_Store -------------------------------------------------------------------------------- /Diagrams/LED_bike_remote_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/Diagrams/LED_bike_remote_bb.png -------------------------------------------------------------------------------- /img/readme/lightvest-back-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/img/readme/lightvest-back-left.png -------------------------------------------------------------------------------- /3D Prints/BIKE MOUNT CLIPS/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BIKE MOUNT CLIPS/.DS_Store -------------------------------------------------------------------------------- /3D Prints/BREADBOARD DESIGN/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BREADBOARD DESIGN/.DS_Store -------------------------------------------------------------------------------- /Diagrams/LED_bike_remote_no_mpu.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/Diagrams/LED_bike_remote_no_mpu.fzz -------------------------------------------------------------------------------- /Diagrams/LED_bike_remote_no_mpu_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/Diagrams/LED_bike_remote_no_mpu_bb.png -------------------------------------------------------------------------------- /Schematics/LIGHTVEST_LED_VEST/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/Schematics/LIGHTVEST_LED_VEST/.DS_Store -------------------------------------------------------------------------------- /3D Prints/BIKE MOUNT CLIPS/STL/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BIKE MOUNT CLIPS/STL/.DS_Store -------------------------------------------------------------------------------- /Schematics/LIGHTVEST_LED_REMOTE/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/Schematics/LIGHTVEST_LED_REMOTE/.DS_Store -------------------------------------------------------------------------------- /3D Prints/BIKE MOUNT CLIPS/STL/clippers.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BIKE MOUNT CLIPS/STL/clippers.stl -------------------------------------------------------------------------------- /3D Prints/BIKE MOUNT CLIPS/STL/top-mount.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BIKE MOUNT CLIPS/STL/top-mount.stl -------------------------------------------------------------------------------- /3D Prints/BREADBOARD DESIGN/Remote/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BREADBOARD DESIGN/Remote/.DS_Store -------------------------------------------------------------------------------- /3D Prints/PCB DESIGN/REMOTE FINAL/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/PCB DESIGN/REMOTE FINAL/.DS_Store -------------------------------------------------------------------------------- /3D Prints/BIKE MOUNT CLIPS/STL/Bike Clips.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BIKE MOUNT CLIPS/STL/Bike Clips.stl -------------------------------------------------------------------------------- /3D Prints/BIKE MOUNT CLIPS/STL/bottom-mount.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BIKE MOUNT CLIPS/STL/bottom-mount.stl -------------------------------------------------------------------------------- /3D Prints/PCB DESIGN/REMOTE FINAL/STL/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/PCB DESIGN/REMOTE FINAL/STL/.DS_Store -------------------------------------------------------------------------------- /3D Prints/BREADBOARD DESIGN/Remote/STL/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BREADBOARD DESIGN/Remote/STL/.DS_Store -------------------------------------------------------------------------------- /3D Prints/PCB DESIGN/REMOTE FINAL/STL/PCB_TOP.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/PCB DESIGN/REMOTE FINAL/STL/PCB_TOP.stl -------------------------------------------------------------------------------- /3D Prints/BREADBOARD DESIGN/Vest Container/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BREADBOARD DESIGN/Vest Container/.DS_Store -------------------------------------------------------------------------------- /3D Prints/PCB DESIGN/REMOTE FINAL/STL/PCB_BOTTOM.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/PCB DESIGN/REMOTE FINAL/STL/PCB_BOTTOM.stl -------------------------------------------------------------------------------- /3D Prints/PCB DESIGN/REMOTE FINAL/STL/PCB_BUTTON.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/PCB DESIGN/REMOTE FINAL/STL/PCB_BUTTON.stl -------------------------------------------------------------------------------- /3D Prints/BREADBOARD DESIGN/Remote/STL/button-up-down.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BREADBOARD DESIGN/Remote/STL/button-up-down.stl -------------------------------------------------------------------------------- /3D Prints/BREADBOARD DESIGN/Vest Container/STL/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BREADBOARD DESIGN/Vest Container/STL/.DS_Store -------------------------------------------------------------------------------- /3D Prints/PCB DESIGN/REMOTE FINAL/STL/PCB_REMOTE_RAW.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/PCB DESIGN/REMOTE FINAL/STL/PCB_REMOTE_RAW.stl -------------------------------------------------------------------------------- /3D Prints/BREADBOARD DESIGN/Remote/STL/button-left-right.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BREADBOARD DESIGN/Remote/STL/button-left-right.stl -------------------------------------------------------------------------------- /3D Prints/BREADBOARD DESIGN/Remote/STL/breadboard-remote-top.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BREADBOARD DESIGN/Remote/STL/breadboard-remote-top.stl -------------------------------------------------------------------------------- /3D Prints/BREADBOARD DESIGN/Remote/STL/breadboard-remote-bottom.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BREADBOARD DESIGN/Remote/STL/breadboard-remote-bottom.stl -------------------------------------------------------------------------------- /3D Prints/BREADBOARD DESIGN/Vest Container/STL/LightVest-Vest-Container.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EbenKouao/lightvest-led-bike-suit/HEAD/3D Prints/BREADBOARD DESIGN/Vest Container/STL/LightVest-Vest-Container.stl -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LightVest 2 | 3 | LightVest is an open-source Bike Vest designed to be wearable technology. The product is a Bike Suit designed to increase a cyclist’s visibility, especially during the night. As well as improving cyclist communication and intent with other motorists and pedestrians. 4 | 5 | ## About this project: 6 | 7 | This Bike Safety Product is designed to be open source. Feel free to contribute to make LightVest more robust. LightVest is designed for you to build on top of. Certain aspects of LightVest can be improved. Feel free to contribute, and explore more use cases. 8 | 9 | Originally a video idea, aiming to build and launch a start-up in 4 weeks. You can find more information on the process on [smartbuilds.io](https://smartbuilds.io). 10 | Alternatively, you can watch the full start up journey on my YouTube channel for context [Eben Kouao - The 4 Week Start-Up - Mini Documentary](https://www.youtube.com/channel/UCGxwyXJWEarxh2XWqvygiIg). 11 | 12 | For more information visit: [lightvest.io](https://lightvest.io) 13 | 14 | ![Light Vest](img/readme/lightvest-back-left.png) 15 | 16 | ## Features 17 | 18 | - A lightweight Weatherproof LED Vest (with IP67 Rated LEDs) 19 | - Turn Signal’s – Fully programmable RGB LEDs 20 | - Wireless remote to control the lights (with 4 fully customisable buttons) 21 | - A Bike mount to attach to your Bike 22 | - ON/OFF Switch Button 23 | - Go Hand’s Free with an Inbuilt accelerometer – control Turn signals by from your bike handle 24 | - Smart Mode – Send Data and track your Journey by Phone 25 | 26 | ## LightVest - Resources 27 | 28 | This repo contains includes: 29 | 30 | - Arduino Code 31 | - LightVest Remote 32 | - LightVest Wearable 33 | - Breadboard Schematics (CAD and Fritzing) 34 | - LightVest Remote 35 | - LightVest Wearable 36 | - PCB Schematics 37 | - LightVest Remote 38 | - LightVest Wearable 39 | - 3D Prints 40 | - Remote 41 | - Breadboard Design: 42 | - Top Case 43 | - Bottom Case 44 | - Button (Arrow Keys) 45 | - PCB Design 46 | - Top Case 47 | - Bottom Case 48 | - Button (Circular) 49 | - Vest Case 50 | - L Connector Case 51 | 52 | ## Functionality of LightVest 53 | 54 | | LED Strip | Colour | Function | 55 | | -------------------- | --------- | ----------------------- | 56 | | Diamond Strip - Half | Yellow | Turn Left or Right | 57 | | Diamond | Strip Red | Red Abrupt Break Lights | 58 | | Front Shoulder strip | Yellow | Turn Left or Right | 59 | | All LED on Blinking | Yellow | Hazard / Emergency | 60 | 61 | ## Requirement 62 | 63 | Arduino Nano x 2 64 | MPU6050 (Accelerometer) 65 | LED Strip (WS2812B) 66 | Jumper Wires 67 | 2 x Bluetooth HC-05 68 | 69 | See the full Part List on LightVest's components on [smartbuilds.io](https://smartbuilds.io) 70 | 71 | ## Diagrams 72 | 73 | ### LightVest 74 | 75 | ![LightVest](Diagrams/LED_bike_vest_bb.png) 76 | 77 | ### Remote 78 | 79 | ![Remote](Diagrams/LED_bike_remote_bb.png) 80 | 81 | Support my [Future Projects on Patreon](https://www.patreon.com/ebenkouao) 82 | -------------------------------------------------------------------------------- /Code/LED_suit_remote/LED_suit_remote.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Code: Remote for LightVest 3 | Modified by Eben - smartbuilds.io 4 | Date: 22.02.21 5 | 6 | The circuit: 7 | - LED attached from pin 13 to ground 8 | - pushbutton attached to pin 2 from +5V 9 | - 10K resistor attached to pin 2 from ground 10 | 11 | Description: 12 | Push buttons can be put on Pin 10 and 11 for indicator lights. More info: smartbuilds.io 13 | */ 14 | 15 | #include 16 | 17 | // constants won't change. They're used here to set pin numbers: 18 | const int buttonPin_Left = 3; // the number of the pushbutton pin 19 | const int buttonPin_Right = 4; // the number of the pushbutton pin 20 | 21 | const int ledPin_Left = 8; // the number of the LED pin 22 | const int ledPin_Right = 7; // the number of the LED pin 23 | 24 | 25 | // variables will change: 26 | int buttonState_Left = 0; // variable for reading the pushbutton status 27 | int buttonState_Right = 0; // variable for reading the pushbutton status 28 | 29 | 30 | const int MPU_addr = 0x68; 31 | int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ; 32 | 33 | int minVal = 265; 34 | int maxVal = 402; 35 | 36 | double x; 37 | double y; 38 | double z; 39 | 40 | bool bool_caliberate = false; 41 | int response_time = 400; 42 | 43 | 44 | bool offset_pos = false; 45 | 46 | 47 | 48 | void setup() { 49 | // initialize the LED pin as an output: 50 | pinMode(ledPin_Left, OUTPUT); 51 | pinMode(ledPin_Right, OUTPUT); 52 | 53 | // initialize the pushbutton pin as an input: 54 | pinMode(buttonPin_Left, INPUT); 55 | pinMode(buttonPin_Right, INPUT); 56 | 57 | // // variables will change: 58 | // buttonState_Left = 0; // variable for reading the pushbutton status 59 | // buttonState_Right = 0; // variable for reading the pushbutton status 60 | 61 | Wire.begin(); 62 | Wire.beginTransmission(MPU_addr); 63 | Wire.write(0x6B);// PWR_MGMT_1 register 64 | Wire.write(0); // set to zero (wakes up the MPU-6050) 65 | Wire.endTransmission(true); Wire.begin(); 66 | Serial.begin(9600); 67 | delay(1000); 68 | 69 | } 70 | 71 | void loop() { 72 | 73 | //debug modes 74 | // button_debug(); 75 | MPU_debug(); 76 | 77 | //create some time of peak offset that needs to be triggered first 78 | 79 | // read the state of the pushbutton value: 80 | buttonState_Left = digitalRead(buttonPin_Left); 81 | buttonState_Right = digitalRead(buttonPin_Right); 82 | // 83 | // Serial.print("Left: "); 84 | // Serial.print(buttonState_Left); 85 | // Serial.print("\t"); 86 | // Serial.print("Right: "); 87 | // Serial.println(buttonState_Right); 88 | 89 | 90 | 91 | // check if the pushbutton is pressed. If it is, the buttonState is HIGH: 92 | if (buttonState_Left == HIGH) { 93 | // turn LED on: 94 | Serial.print("L"); 95 | digitalWrite(ledPin_Left, HIGH); 96 | delay(500); 97 | buttonState_Right = 0; 98 | } else { 99 | // turn LED off: 100 | digitalWrite(ledPin_Left, LOW); 101 | } 102 | 103 | if (buttonState_Right == HIGH) { 104 | // turn LED on: 105 | Serial.print("R"); 106 | digitalWrite(ledPin_Right, HIGH); 107 | delay(500); 108 | buttonState_Left = 0; 109 | 110 | } else { 111 | // turn LED off: 112 | digitalWrite(ledPin_Right, LOW); 113 | buttonState_Left = LOW; 114 | buttonState_Right = LOW; 115 | } 116 | 117 | 118 | 119 | //------------------------------------- 120 | GetMpuValue1(MPU_addr); 121 | 122 | // 123 | if (offset_pos == false) { 124 | // // //Move right 125 | if ( GyZ > 15000) { 126 | Serial.println("L"); 127 | digitalWrite(ledPin_Left, HIGH); 128 | digitalWrite(ledPin_Right, LOW); 129 | offset_pos = true; 130 | 131 | delay(response_time); 132 | } 133 | } 134 | 135 | if (offset_pos == true) { 136 | if ( GyZ > 15000) { 137 | Serial.println("L Offset centre"); 138 | offset_pos = false; 139 | delay(response_time); 140 | } 141 | } 142 | 143 | 144 | if (offset_pos == true) { 145 | if ( GyZ < -15000) { 146 | Serial.println("R Offset centre"); ; 147 | delay(response_time); 148 | offset_pos = false; 149 | 150 | } 151 | } 152 | 153 | 154 | 155 | if (offset_pos == false) { 156 | // //Move right 157 | if ( GyZ < -15000) { 158 | Serial.println("R"); 159 | digitalWrite(ledPin_Right, HIGH); 160 | digitalWrite(ledPin_Left, LOW); 161 | delay(response_time); 162 | offset_pos = true; 163 | 164 | } 165 | } 166 | 167 | 168 | 169 | } 170 | 171 | void button_debug() { 172 | Serial.print("Left: "); 173 | Serial.print(buttonState_Left); 174 | Serial.print("\t"); 175 | Serial.print("Right: "); 176 | Serial.println(buttonState_Right); 177 | 178 | } 179 | 180 | 181 | void GetMpuValue1(const int MPU) { 182 | 183 | Wire.beginTransmission(MPU); 184 | Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H) 185 | Wire.endTransmission(false); 186 | Wire.requestFrom(MPU, 14, true); // request a total of 14 registers 187 | 188 | AcX = Wire.read() << 8 | Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L) 189 | AcY = Wire.read() << 8 | Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L) 190 | AcZ = Wire.read() << 8 | Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L) 191 | 192 | Tmp = Wire.read() << 8 | Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L) 193 | 194 | int xAng = map(AcX, minVal, maxVal, -90, 90); 195 | int yAng = map(AcY, minVal, maxVal, -90, 90); 196 | int zAng = map(AcZ, minVal, maxVal, -90, 90); 197 | 198 | GyX = Wire.read() << 8 | Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L) 199 | GyY = Wire.read() << 8 | Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L) 200 | GyZ = Wire.read() << 8 | Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L) 201 | 202 | x = RAD_TO_DEG * (atan2(-yAng, -zAng) + PI) + 4; //offset by 4 degrees to get back to zero 203 | y = RAD_TO_DEG * (atan2(-xAng, -zAng) + PI); 204 | z = RAD_TO_DEG * (atan2(-yAng, -xAng) + PI); 205 | 206 | } 207 | 208 | void MPU_debug() { 209 | 210 | // Serial.print("AngleX= "); 211 | // Serial.print(x); 212 | // Serial.print("\t"); 213 | // 214 | // Serial.print("AngleY= "); 215 | // Serial.print(y); 216 | // Serial.print("\t"); 217 | // 218 | // Serial.print("AngleZ= "); 219 | // Serial.println(z); 220 | // Serial.print("\t"); 221 | // Serial.println("-----------------------------------------"); 222 | 223 | // Serial.print("AcX = "); 224 | // Serial.print(AcX1); 225 | // Serial.print(" | AcY = "); 226 | // Serial.print(AcY1); 227 | // Serial.print(" | AcZ = "); 228 | // Serial.print(AcZ1); 229 | 230 | // 231 | // Serial.print(" | GyX = "); 232 | // Serial.print(GyX); 233 | // Serial.print(" | GyY = "); 234 | // Serial.print(GyY); 235 | // Serial.print(" | GyZ = "); 236 | // Serial.println(GyZ); 237 | 238 | } 239 | -------------------------------------------------------------------------------- /Code/LED_suit_vest_no_bluetooth/LED_suit_vest_no_bluetooth.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Code: LightVest Remote enabled Vest 3 | Modified by Eben - smartbuilds.io 4 | Date: 22.02.21 5 | 6 | Description: 7 | LightVest to control the indicator lights (test code non-bluetooth). More info: smartbuilds.io 8 | 9 | Features: 10 | - Left 11 | - Right 12 | - Hazard 13 | - Rainbow 14 | 15 | */ 16 | 17 | 18 | 19 | // NEOPIXEL BEST PRACTICES for most reliable operation: 20 | // - Add 1000 uF CAPACITOR between NeoPixel strip_back's + and - connections. 21 | // - MINIMIZE WIRING LENGTH between microcontroller board and first pixel. 22 | // - NeoPixel strip_back's DATA-IN should pass through a 300-500 OHM RESISTOR. 23 | // - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS 24 | // connect GROUND (-) first, then +, then data. 25 | // - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip_back, 26 | // a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED. 27 | // (Skipping these may work OK on your workbench but can fail in the field) 28 | 29 | #include 30 | #ifdef __AVR__ 31 | #include // Required for 16 MHz Adafruit Trinket 32 | #endif 33 | 34 | #define LED_BACK 5 35 | #define LED_LEFT 4 36 | #define LED_RIGHT 6 37 | 38 | // How many NeoPixels are attached to the Arduino? 39 | #define LED_COUNT 52 // Define the number of LEDs in the strip 40 | 41 | char state = 0; // Changes value from ASCII to char 42 | int light_delay = 50; //How long to keep the LED on for (ms) 43 | 44 | 45 | // Declare our NeoPixel strip_back object: 46 | Adafruit_NeoPixel strip_back(LED_COUNT, LED_BACK, NEO_GRB + NEO_KHZ800); 47 | Adafruit_NeoPixel strip_left(LED_COUNT, LED_LEFT, NEO_GRB + NEO_KHZ800); 48 | Adafruit_NeoPixel strip_right(LED_COUNT, LED_RIGHT, NEO_GRB + NEO_KHZ800); 49 | 50 | 51 | // Argument 1 = Number of pixels in NeoPixel strip_back 52 | // Argument 2 = Arduino pin number (most are valid) 53 | // Argument 3 = Pixel type flags, add together as needed: 54 | // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 55 | // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) 56 | // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) 57 | // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) 58 | // NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) 59 | 60 | 61 | // setup() function -- runs once at startup -------------------------------- 62 | 63 | void setup() { 64 | // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. 65 | // Any other board, you can remove this part (but no harm leaving it): 66 | #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) 67 | clock_prescale_set(clock_div_1); 68 | #endif 69 | // END of Trinket-specific code. 70 | 71 | strip_back.begin(); // INITIALIZE NeoPixel strip_back object (REQUIRED) 72 | strip_back.show(); // Turn OFF all pixels ASAP 73 | strip_back.setBrightness(150); // Set BRIGHTNESS to about 1/5 (max = 255) 74 | 75 | strip_left.begin(); // INITIALIZE NeoPixel strip_back object (REQUIRED) 76 | strip_left.show(); // Turn OFF all pixels ASAP 77 | strip_left.setBrightness(150); // Set BRIGHTNESS to about 1/5 (max = 255) 78 | 79 | strip_right.begin(); // INITIALIZE NeoPixel strip_back object (REQUIRED) 80 | strip_right.show(); // Turn OFF all pixels ASAP 81 | strip_right.setBrightness(150); // Set BRIGHTNESS to about 1/5 (max = 255) 82 | 83 | Serial.begin(9600); 84 | delay(1000); 85 | } 86 | 87 | 88 | // loop() function -- runs repeatedly as long as board is on --------------- 89 | 90 | void loop() { 91 | 92 | //colorBlinkersLeft(strip_left.Color(255, 100, 0), 50); //Yellow 93 | // colorBlinkersRight(strip_left.Color(255, 100, 0), 50); //Yellow 94 | // delay(400); 95 | // colorBlinkersRight(strip_left.Color(0, 0, 0), 25); //Yellow 96 | // delay(300); 97 | 98 | 99 | rightBlink(); 100 | delay(3000); 101 | 102 | leftBlink(); 103 | delay(3000); 104 | 105 | sixNine(); 106 | delay(3000); 107 | 108 | hazardBlink(); 109 | delay(3000); 110 | 111 | // colorWipeRight(strip_right.Color(255, 100, 0), 50); //Yellow 112 | 113 | // colorWipeLeft(strip_left.Color(255, 100, 0), 50); //Yellow 114 | 115 | } 116 | 117 | 118 | // Some functions of our own for creating animated effects ----------------- 119 | 120 | // Fill strip_back pixels one after another with a color. strip_back is NOT cleared 121 | // first; anything there will be covered pixel by pixel. Pass in color 122 | // (as a single 'packed' 32-bit value, which you can get by calling 123 | // strip_back.Color(red, green, blue) as shown in the loop() function above), 124 | // and a delay time (in milliseconds) between pixels. 125 | void colorWipeLeft(uint32_t color, int wait) { 126 | for (int i = 0; i < strip_left.numPixels(); i++) { // For each pixel in strip_back... 127 | strip_left.setPixelColor(i, color); // Set pixel's color (in RAM) 128 | strip_left.show(); // Update strip_back to match 129 | delay(wait); // Pause for a moment 130 | strip_left.clear(); 131 | } 132 | } 133 | 134 | //void colorBlinkersLeft(uint32_t c, int wait) { 135 | // strip_left.setPixelColor(0, c); 136 | // strip_left.setPixelColor(1, c); 137 | // strip_left.setPixelColor(2, c); 138 | // strip_left.setPixelColor(3, c); 139 | // strip_left.setPixelColor(4, c); 140 | // strip_left.setPixelColor(5, c); 141 | // strip_left.setPixelColor(6, c); 142 | // strip_left.setPixelColor(7, c); 143 | // 144 | // strip_left.show(); 145 | // delay(wait); 146 | // strip_left.clear(); 147 | //} 148 | 149 | void rightBlink() { 150 | 151 | for (int i = 0; i < 4; i++) { // For each pixel in strip_back... 152 | 153 | colorBlinkersRight(strip_left.Color(255, 100, 0), 50); //Yellow 154 | turnRight(strip_back.Color(255, 100, 0), 50); 155 | delay(400); 156 | colorBlinkersRight(strip_left.Color(0, 0, 0), 25); //Yellow 157 | turnRight(strip_back.Color(0, 0, 0), 50); 158 | delay(300); 159 | 160 | } 161 | } 162 | 163 | void colorBlinkersRight(uint32_t c, int wait) { 164 | 165 | strip_right.setPixelColor(0, c); 166 | strip_right.setPixelColor(1, c); 167 | strip_right.setPixelColor(2, c); 168 | strip_right.setPixelColor(3, c); 169 | strip_right.setPixelColor(4, c); 170 | strip_right.setPixelColor(5, c); 171 | strip_right.setPixelColor(6, c); 172 | strip_right.setPixelColor(7, c); 173 | strip_right.setPixelColor(8, c); 174 | strip_right.setPixelColor(9, c); 175 | strip_right.setPixelColor(10, c); 176 | strip_right.setPixelColor(11, c); 177 | strip_right.setPixelColor(12, c); 178 | strip_right.setPixelColor(13, c); 179 | strip_right.setPixelColor(14, c); 180 | strip_right.setPixelColor(15, c); 181 | strip_right.setPixelColor(16, c); 182 | strip_right.setPixelColor(17, c); 183 | strip_right.setPixelColor(18, c); 184 | strip_right.setPixelColor(19, c); 185 | strip_right.setPixelColor(20, c); 186 | strip_right.setPixelColor(21, c); 187 | strip_right.setPixelColor(22, c); 188 | strip_right.setPixelColor(23, c); 189 | strip_right.setPixelColor(24, c); 190 | strip_right.setPixelColor(25, c); 191 | strip_right.setPixelColor(26, c); 192 | strip_right.setPixelColor(27, c); 193 | strip_right.setPixelColor(28, c); 194 | 195 | strip_right.show(); 196 | delay(wait); 197 | strip_right.clear(); 198 | delay(wait); 199 | 200 | } 201 | 202 | 203 | void sixNine() { 204 | rainbow_back(10); 205 | } 206 | 207 | 208 | void hazardBlink() { 209 | 210 | for (int i = 0; i < 4; i++) { // For each pixel in strip_back... 211 | 212 | colorBlinkersLeft(strip_left.Color(255, 100, 0), 50); //Yellow 213 | colorBlinkersRight(strip_right.Color(255, 100, 0), 50); //Yellow 214 | colorBlinkersHazard(strip_back.Color(255, 100, 0), 50); //for back 215 | 216 | delay(400); 217 | colorBlinkersLeft(strip_left.Color(0, 0, 0), 25); //Yellow 218 | colorBlinkersRight(strip_right.Color(0, 0, 0), 50); //Yellow 219 | colorBlinkersHazard(strip_back.Color(0, 0, 0), 50); //for back 220 | 221 | 222 | delay(300); 223 | 224 | } 225 | } 226 | 227 | 228 | void leftBlink() { 229 | 230 | for (int i = 0; i < 4; i++) { // For each pixel in strip_back... 231 | 232 | colorBlinkersLeft(strip_left.Color(255, 100, 0), 50); //Yellow 233 | turnLeft(strip_back.Color(255, 100, 0), 50); //for back 234 | delay(400); 235 | colorBlinkersLeft(strip_left.Color(0, 0, 0), 25); //Yellow 236 | turnLeft(strip_back.Color(0, 0, 0), 50); //for back 237 | 238 | delay(300); 239 | 240 | } 241 | } 242 | 243 | void colorBlinkersLeft(uint32_t c, int wait) { 244 | 245 | 246 | 247 | strip_left.setPixelColor(0, c); 248 | strip_left.setPixelColor(1, c); 249 | strip_left.setPixelColor(2, c); 250 | strip_left.setPixelColor(3, c); 251 | strip_left.setPixelColor(4, c); 252 | strip_left.setPixelColor(5, c); 253 | strip_left.setPixelColor(6, c); 254 | strip_left.setPixelColor(7, c); 255 | strip_left.setPixelColor(8, c); 256 | strip_left.setPixelColor(9, c); 257 | strip_left.setPixelColor(10, c); 258 | strip_left.setPixelColor(11, c); 259 | strip_left.setPixelColor(12, c); 260 | strip_left.setPixelColor(13, c); 261 | strip_left.setPixelColor(14, c); 262 | strip_left.setPixelColor(15, c); 263 | strip_left.setPixelColor(16, c); 264 | strip_left.setPixelColor(17, c); 265 | strip_left.setPixelColor(18, c); 266 | strip_left.setPixelColor(19, c); 267 | strip_left.setPixelColor(20, c); 268 | strip_left.setPixelColor(21, c); 269 | strip_left.setPixelColor(22, c); 270 | strip_left.setPixelColor(23, c); 271 | strip_left.setPixelColor(24, c); 272 | strip_left.setPixelColor(25, c); 273 | strip_left.setPixelColor(26, c); 274 | strip_left.setPixelColor(27, c); 275 | strip_left.setPixelColor(28, c); 276 | 277 | strip_left.show(); 278 | delay(wait); 279 | strip_left.clear(); 280 | delay(wait); 281 | 282 | } 283 | 284 | 285 | void colorBlinkersHazard(uint32_t c, int wait) { 286 | 287 | strip_back.setPixelColor(0, c); 288 | strip_back.setPixelColor(1, c); 289 | strip_back.setPixelColor(2, c); 290 | strip_back.setPixelColor(3, c); 291 | strip_back.setPixelColor(4, c); 292 | strip_back.setPixelColor(5, c); 293 | strip_back.setPixelColor(6, c); 294 | strip_back.setPixelColor(7, c); 295 | 296 | strip_back.setPixelColor(24, c); 297 | strip_back.setPixelColor(25, c); 298 | strip_back.setPixelColor(26, c); 299 | strip_back.setPixelColor(27, c); 300 | strip_back.setPixelColor(28, c); 301 | strip_back.setPixelColor(29, c); 302 | strip_back.setPixelColor(30, c); 303 | strip_back.setPixelColor(31, c); 304 | 305 | 306 | strip_back.setPixelColor(32, c); 307 | strip_back.setPixelColor(33, c); 308 | strip_back.setPixelColor(34, c); 309 | strip_back.setPixelColor(35, c); 310 | strip_back.setPixelColor(36, c); 311 | strip_back.setPixelColor(37, c); 312 | strip_back.setPixelColor(38, c); 313 | strip_back.setPixelColor(39, c); 314 | strip_back.setPixelColor(40, c); 315 | strip_back.setPixelColor(41, c); 316 | strip_back.setPixelColor(42, c); 317 | strip_back.setPixelColor(43, c); 318 | strip_back.setPixelColor(44, c); 319 | 320 | strip_back.setPixelColor(8, c); 321 | strip_back.setPixelColor(9, c); 322 | strip_back.setPixelColor(10, c); 323 | strip_back.setPixelColor(11, c); 324 | strip_back.setPixelColor(12, c); 325 | strip_back.setPixelColor(13, c); 326 | strip_back.setPixelColor(14, c); 327 | strip_back.setPixelColor(15, c); 328 | 329 | strip_back.setPixelColor(16, c); 330 | strip_back.setPixelColor(17, c); 331 | strip_back.setPixelColor(18, c); 332 | strip_back.setPixelColor(19, c); 333 | strip_back.setPixelColor(20, c); 334 | strip_back.setPixelColor(21, c); 335 | strip_back.setPixelColor(22, c); 336 | strip_back.setPixelColor(23, c); 337 | 338 | 339 | strip_back.setPixelColor(32, c); 340 | strip_back.setPixelColor(33, c); 341 | strip_back.setPixelColor(34, c); 342 | strip_back.setPixelColor(35, c); 343 | strip_back.setPixelColor(36, c); 344 | strip_back.setPixelColor(37, c); 345 | strip_back.setPixelColor(38, c); 346 | strip_back.setPixelColor(39, c); 347 | strip_back.setPixelColor(40, c); 348 | strip_back.setPixelColor(41, c); 349 | strip_back.setPixelColor(42, c); 350 | strip_back.setPixelColor(43, c); 351 | strip_back.setPixelColor(44, c); 352 | 353 | 354 | 355 | strip_back.show(); 356 | delay(wait); 357 | strip_back.clear(); 358 | delay(wait); 359 | 360 | } 361 | 362 | 363 | void colorWipeRight(uint32_t color, int wait) { 364 | for (int i = 0; i < strip_right.numPixels(); i++) { // For each pixel in strip_back... 365 | strip_right.setPixelColor(i, color); // Set pixel's color (in RAM) 366 | strip_right.show(); // Update strip_back to match 367 | delay(wait); // Pause for a moment 368 | strip_right.clear(); 369 | } 370 | } 371 | 372 | 373 | //1st - 0 - 7 374 | //2nd - 8 - 15 375 | //3rd - 16 - 23 376 | //4th - 23 - 31 377 | //long - 32 -44 378 | 379 | // Fill the dots one after the other with a color 380 | void turnRight(uint32_t c, uint8_t wait) { 381 | 382 | strip_back.setPixelColor(0, c); 383 | strip_back.setPixelColor(1, c); 384 | strip_back.setPixelColor(2, c); 385 | strip_back.setPixelColor(3, c); 386 | strip_back.setPixelColor(4, c); 387 | strip_back.setPixelColor(5, c); 388 | strip_back.setPixelColor(6, c); 389 | strip_back.setPixelColor(7, c); 390 | 391 | strip_back.setPixelColor(24, c); 392 | strip_back.setPixelColor(25, c); 393 | strip_back.setPixelColor(26, c); 394 | strip_back.setPixelColor(27, c); 395 | strip_back.setPixelColor(28, c); 396 | strip_back.setPixelColor(29, c); 397 | strip_back.setPixelColor(30, c); 398 | strip_back.setPixelColor(31, c); 399 | 400 | 401 | strip_back.setPixelColor(32, c); 402 | strip_back.setPixelColor(33, c); 403 | strip_back.setPixelColor(34, c); 404 | strip_back.setPixelColor(35, c); 405 | strip_back.setPixelColor(36, c); 406 | strip_back.setPixelColor(37, c); 407 | strip_back.setPixelColor(38, c); 408 | strip_back.setPixelColor(39, c); 409 | strip_back.setPixelColor(40, c); 410 | strip_back.setPixelColor(41, c); 411 | strip_back.setPixelColor(42, c); 412 | strip_back.setPixelColor(43, c); 413 | strip_back.setPixelColor(44, c); 414 | 415 | strip_back.show(); 416 | delay(wait); 417 | strip_back.clear(); 418 | 419 | 420 | } 421 | 422 | 423 | // Fill the dots one after the other with a color 424 | void turnLeft(uint32_t c, uint8_t wait) { 425 | 426 | strip_back.setPixelColor(8, c); 427 | strip_back.setPixelColor(9, c); 428 | strip_back.setPixelColor(10, c); 429 | strip_back.setPixelColor(11, c); 430 | strip_back.setPixelColor(12, c); 431 | strip_back.setPixelColor(13, c); 432 | strip_back.setPixelColor(14, c); 433 | strip_back.setPixelColor(15, c); 434 | 435 | strip_back.setPixelColor(16, c); 436 | strip_back.setPixelColor(17, c); 437 | strip_back.setPixelColor(18, c); 438 | strip_back.setPixelColor(19, c); 439 | strip_back.setPixelColor(20, c); 440 | strip_back.setPixelColor(21, c); 441 | strip_back.setPixelColor(22, c); 442 | strip_back.setPixelColor(23, c); 443 | 444 | 445 | strip_back.setPixelColor(32, c); 446 | strip_back.setPixelColor(33, c); 447 | strip_back.setPixelColor(34, c); 448 | strip_back.setPixelColor(35, c); 449 | strip_back.setPixelColor(36, c); 450 | strip_back.setPixelColor(37, c); 451 | strip_back.setPixelColor(38, c); 452 | strip_back.setPixelColor(39, c); 453 | strip_back.setPixelColor(40, c); 454 | strip_back.setPixelColor(41, c); 455 | strip_back.setPixelColor(42, c); 456 | strip_back.setPixelColor(43, c); 457 | strip_back.setPixelColor(44, c); 458 | 459 | 460 | strip_back.show(); 461 | delay(wait); 462 | strip_back.clear(); 463 | 464 | 465 | } 466 | 467 | // Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames. 468 | void theaterChaseRainbow(int wait) { 469 | int firstPixelHue = 0; // First pixel starts at red (hue 0) 470 | for (int a = 0; a < 30; a++) { // Repeat 30 times... 471 | for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2... 472 | strip_back.clear(); // Set all pixels in RAM to 0 (off) 473 | // 'c' counts up from 'b' to end of strip_back in increments of 3... 474 | for (int c = b; c < strip_back.numPixels(); c += 3) { 475 | // hue of pixel 'c' is offset by an amount to make one full 476 | // revolution of the color wheel (range 65536) along the length 477 | // of the strip_back (strip_back.numPixels() steps): 478 | int hue = firstPixelHue + c * 65536L / strip_back.numPixels(); 479 | uint32_t color = strip_back.gamma32(strip_back.ColorHSV(hue)); // hue -> RGB 480 | strip_back.setPixelColor(c, color); // Set pixel 'c' to value 'color' 481 | } 482 | strip_back.show(); // Update strip_back with new contents 483 | delay(wait); // Pause for a moment 484 | firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames 485 | } 486 | } 487 | } 488 | 489 | 490 | // Rainbow cycle along whole strip_back. Pass delay time (in ms) between frames. 491 | void rainbow_back(int wait) { 492 | 493 | for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) { 494 | for (int i = 0; i < strip_back.numPixels(); i++) { // For each pixel in strip_back... 495 | 496 | int pixelHue = firstPixelHue + (i * 65536L / strip_back.numPixels()); 497 | 498 | strip_back.setPixelColor(i, strip_back.gamma32(strip_back.ColorHSV(pixelHue))); 499 | strip_left.setPixelColor(i, strip_right.gamma32(strip_right.ColorHSV(pixelHue))); 500 | strip_right.setPixelColor(i, strip_right.gamma32(strip_right.ColorHSV(pixelHue))); 501 | 502 | 503 | } 504 | strip_back.show(); // Update strip_back with new contents 505 | strip_left.show(); // Update strip_back with new contents 506 | strip_right.show(); // Update strip_back with new contents 507 | 508 | 509 | delay(wait); // Pause for a moment 510 | } 511 | } 512 | 513 | 514 | // Rainbow cycle along whole strip_back. Pass delay time (in ms) between frames. 515 | void rainbow_left(int wait) { 516 | 517 | for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) { 518 | for (int i = 0; i < strip_left.numPixels(); i++) { // For each pixel in strip_back... 519 | 520 | int pixelHue = firstPixelHue + (i * 65536L / strip_back.numPixels()); 521 | 522 | strip_left.setPixelColor(i, strip_left.gamma32(strip_left.ColorHSV(pixelHue))); 523 | } 524 | strip_left.show(); // Update strip_back with new contents 525 | delay(wait); // Pause for a moment 526 | } 527 | } 528 | 529 | 530 | // Rainbow cycle along whole strip_back. Pass delay time (in ms) between frames. 531 | void rainbow_right(int wait) { 532 | 533 | for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) { 534 | for (int i = 0; i < strip_right.numPixels(); i++) { // For each pixel in strip_back... 535 | 536 | int pixelHue = firstPixelHue + (i * 65536L / strip_right.numPixels()); 537 | 538 | strip_right.setPixelColor(i, strip_right.gamma32(strip_right.ColorHSV(pixelHue))); 539 | } 540 | strip_right.show(); // Update strip_back with new contents 541 | delay(wait); // Pause for a moment 542 | } 543 | } 544 | 545 | 546 | void colorShow(uint32_t color, int wait) { 547 | for (int i = 0; i < strip_back.numPixels(); i++) { // For each pixel in strip_back... 548 | strip_back.setPixelColor(i, color); // Set pixel's color (in RAM) 549 | } 550 | strip_back.show(); // Update strip_back to match 551 | //delay(wait); // Pause for a moment 552 | strip_back.clear(); 553 | 554 | } 555 | 556 | // Theater-marquee-style chasing lights. Pass in a color (32-bit value, 557 | // a la strip_back.Color(r,g,b) as mentioned above), and a delay time (in ms) 558 | // between frames. 559 | void theaterChase(uint32_t color, int wait) { 560 | for (int a = 0; a < 10; a++) { // Repeat 10 times... 561 | for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2... 562 | strip_back.clear(); // Set all pixels in RAM to 0 (off) 563 | // 'c' counts up from 'b' to end of strip_back in steps of 3... 564 | for (int c = b; c < strip_back.numPixels(); c += 3) { 565 | strip_back.setPixelColor(c, color); // Set pixel 'c' to value 'color' 566 | } 567 | strip_back.show(); // Update strip_back with new contents 568 | delay(wait); // Pause for a moment 569 | strip_back.clear(); 570 | 571 | } 572 | } 573 | } 574 | 575 | void clearLights() { 576 | strip_left.clear(); 577 | strip_right.clear(); 578 | strip_back.clear(); 579 | } 580 | -------------------------------------------------------------------------------- /Code/LED_suit_vest_bluetooth/LED_suit_vest_bluetooth.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Code: LightVest Remote enabled Vest 3 | Modified by Eben - smartbuilds.io 4 | Date: 22.02.21 5 | 6 | Description: 7 | A bluetooth enabled LightVest to control the indicator lights with the remote. More info: smartbuilds.io 8 | */ 9 | 10 | // NEOPIXEL BEST PRACTICES for most reliable operation: 11 | // - Add 1000 uF CAPACITOR between NeoPixel strip_back's + and - connections. 12 | // - MINIMIZE WIRING LENGTH between microcontroller board and first pixel. 13 | // - NeoPixel strip_back's DATA-IN should pass through a 300-500 OHM RESISTOR. 14 | // - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS 15 | // connect GROUND (-) first, then +, then data. 16 | // - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip_back, 17 | // a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED. 18 | // (Skipping these may work OK on your workbench but can fail in the field) 19 | 20 | #include 21 | #ifdef __AVR__ 22 | #include // Required for 16 MHz Adafruit Trinket 23 | #endif 24 | 25 | #define LED_BACK 5 26 | #define LED_LEFT 4 27 | #define LED_RIGHT 6 28 | 29 | // How many NeoPixels are attached to the Arduino? 30 | #define LED_COUNT 52 // Define the number of LEDs in the strip 31 | 32 | char state = 0; // Changes value from ASCII to char 33 | int light_delay = 50; //How long to keep the LED on for (ms) 34 | 35 | 36 | // Declare our NeoPixel strip_back object: 37 | Adafruit_NeoPixel strip_back(LED_COUNT, LED_BACK, NEO_GRB + NEO_KHZ800); 38 | Adafruit_NeoPixel strip_left(LED_COUNT, LED_LEFT, NEO_GRB + NEO_KHZ800); 39 | Adafruit_NeoPixel strip_right(LED_COUNT, LED_RIGHT, NEO_GRB + NEO_KHZ800); 40 | 41 | 42 | // Argument 1 = Number of pixels in NeoPixel strip_back 43 | // Argument 2 = Arduino pin number (most are valid) 44 | // Argument 3 = Pixel type flags, add together as needed: 45 | // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) 46 | // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) 47 | // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) 48 | // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) 49 | // NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) 50 | 51 | 52 | // setup() function -- runs once at startup -------------------------------- 53 | 54 | void setup() { 55 | // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. 56 | // Any other board, you can remove this part (but no harm leaving it): 57 | #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) 58 | clock_prescale_set(clock_div_1); 59 | #endif 60 | // END of Trinket-specific code. 61 | 62 | strip_back.begin(); // INITIALIZE NeoPixel strip_back object (REQUIRED) 63 | strip_back.show(); // Turn OFF all pixels ASAP 64 | strip_back.setBrightness(150); // Set BRIGHTNESS to about 1/5 (max = 255) 65 | 66 | strip_left.begin(); // INITIALIZE NeoPixel strip_back object (REQUIRED) 67 | strip_left.show(); // Turn OFF all pixels ASAP 68 | strip_left.setBrightness(150); // Set BRIGHTNESS to about 1/5 (max = 255) 69 | 70 | strip_right.begin(); // INITIALIZE NeoPixel strip_back object (REQUIRED) 71 | strip_right.show(); // Turn OFF all pixels ASAP 72 | strip_right.setBrightness(150); // Set BRIGHTNESS to about 1/5 (max = 255) 73 | 74 | Serial.begin(9600); 75 | delay(1000); 76 | } 77 | 78 | 79 | // loop() function -- runs repeatedly as long as board is on --------------- 80 | 81 | void loop() { 82 | 83 | //colorBlinkersLeft(strip_left.Color(255, 100, 0), 50); //Yellow 84 | // colorBlinkersRight(strip_left.Color(255, 100, 0), 50); //Yellow 85 | // delay(400); 86 | // colorBlinkersRight(strip_left.Color(0, 0, 0), 25); //Yellow 87 | // delay(300); 88 | 89 | 90 | // rightBlink(); 91 | // delay(3000); 92 | // 93 | // leftBlink(); 94 | // delay(3000); 95 | // 96 | // sixNine(); 97 | // delay(3000); 98 | // 99 | // hazardBlink(); 100 | // delay(3000); 101 | 102 | // colorWipeRight(strip_right.Color(255, 100, 0), 50); //Yellow 103 | 104 | // colorWipeLeft(strip_left.Color(255, 100, 0), 50); //Yellow 105 | 106 | 107 | if (Serial.available() > 0) { // Checks whether data is comming from the serial port 108 | 109 | 110 | state = Serial.read(); // Reads the data from the serial port 111 | Serial.print(state); // Prints out the value sent 112 | 113 | //Indicate Left 114 | if (state == 'L') { 115 | leftBlink(); 116 | delay(light_delay); 117 | 118 | } 119 | 120 | //Indicate Right 121 | if (state == 'R') { 122 | rightBlink(); 123 | delay(light_delay); 124 | 125 | } 126 | 127 | } 128 | 129 | } 130 | 131 | 132 | // Some functions of our own for creating animated effects ----------------- 133 | 134 | // Fill strip_back pixels one after another with a color. strip_back is NOT cleared 135 | // first; anything there will be covered pixel by pixel. Pass in color 136 | // (as a single 'packed' 32-bit value, which you can get by calling 137 | // strip_back.Color(red, green, blue) as shown in the loop() function above), 138 | // and a delay time (in milliseconds) between pixels. 139 | void colorWipeLeft(uint32_t color, int wait) { 140 | for (int i = 0; i < strip_left.numPixels(); i++) { // For each pixel in strip_back... 141 | strip_left.setPixelColor(i, color); // Set pixel's color (in RAM) 142 | strip_left.show(); // Update strip_back to match 143 | delay(wait); // Pause for a moment 144 | strip_left.clear(); 145 | } 146 | } 147 | 148 | //void colorBlinkersLeft(uint32_t c, int wait) { 149 | // strip_left.setPixelColor(0, c); 150 | // strip_left.setPixelColor(1, c); 151 | // strip_left.setPixelColor(2, c); 152 | // strip_left.setPixelColor(3, c); 153 | // strip_left.setPixelColor(4, c); 154 | // strip_left.setPixelColor(5, c); 155 | // strip_left.setPixelColor(6, c); 156 | // strip_left.setPixelColor(7, c); 157 | // 158 | // strip_left.show(); 159 | // delay(wait); 160 | // strip_left.clear(); 161 | //} 162 | 163 | void rightBlink() { 164 | 165 | for (int i = 0; i < 4; i++) { // For each pixel in strip_back... 166 | 167 | colorBlinkersRight(strip_left.Color(255, 100, 0), 50); //Yellow 168 | turnRight(strip_back.Color(255, 100, 0), 50); 169 | delay(400); 170 | colorBlinkersRight(strip_left.Color(0, 0, 0), 25); //Yellow 171 | turnRight(strip_back.Color(0, 0, 0), 50); 172 | delay(300); 173 | 174 | } 175 | } 176 | 177 | void colorBlinkersRight(uint32_t c, int wait) { 178 | 179 | strip_right.setPixelColor(0, c); 180 | strip_right.setPixelColor(1, c); 181 | strip_right.setPixelColor(2, c); 182 | strip_right.setPixelColor(3, c); 183 | strip_right.setPixelColor(4, c); 184 | strip_right.setPixelColor(5, c); 185 | strip_right.setPixelColor(6, c); 186 | strip_right.setPixelColor(7, c); 187 | strip_right.setPixelColor(8, c); 188 | strip_right.setPixelColor(9, c); 189 | strip_right.setPixelColor(10, c); 190 | strip_right.setPixelColor(11, c); 191 | strip_right.setPixelColor(12, c); 192 | strip_right.setPixelColor(13, c); 193 | strip_right.setPixelColor(14, c); 194 | strip_right.setPixelColor(15, c); 195 | strip_right.setPixelColor(16, c); 196 | strip_right.setPixelColor(17, c); 197 | strip_right.setPixelColor(18, c); 198 | strip_right.setPixelColor(19, c); 199 | strip_right.setPixelColor(20, c); 200 | strip_right.setPixelColor(21, c); 201 | strip_right.setPixelColor(22, c); 202 | strip_right.setPixelColor(23, c); 203 | strip_right.setPixelColor(24, c); 204 | strip_right.setPixelColor(25, c); 205 | strip_right.setPixelColor(26, c); 206 | strip_right.setPixelColor(27, c); 207 | strip_right.setPixelColor(28, c); 208 | 209 | strip_right.show(); 210 | delay(wait); 211 | strip_right.clear(); 212 | delay(wait); 213 | 214 | } 215 | 216 | 217 | void sixNine() { 218 | rainbow_back(10); 219 | } 220 | 221 | 222 | void hazardBlink() { 223 | 224 | for (int i = 0; i < 4; i++) { // For each pixel in strip_back... 225 | 226 | colorBlinkersLeft(strip_left.Color(255, 100, 0), 50); //Yellow 227 | colorBlinkersRight(strip_right.Color(255, 100, 0), 50); //Yellow 228 | colorBlinkersHazard(strip_back.Color(255, 100, 0), 50); //for back 229 | 230 | delay(400); 231 | colorBlinkersLeft(strip_left.Color(0, 0, 0), 25); //Yellow 232 | colorBlinkersRight(strip_right.Color(0, 0, 0), 50); //Yellow 233 | colorBlinkersHazard(strip_back.Color(0, 0, 0), 50); //for back 234 | 235 | 236 | delay(300); 237 | 238 | } 239 | } 240 | 241 | 242 | void leftBlink() { 243 | 244 | for (int i = 0; i < 4; i++) { // For each pixel in strip_back... 245 | 246 | colorBlinkersLeft(strip_left.Color(255, 100, 0), 50); //Yellow 247 | turnLeft(strip_back.Color(255, 100, 0), 50); //for back 248 | delay(400); 249 | colorBlinkersLeft(strip_left.Color(0, 0, 0), 25); //Yellow 250 | turnLeft(strip_back.Color(0, 0, 0), 50); //for back 251 | 252 | delay(300); 253 | 254 | } 255 | } 256 | 257 | void colorBlinkersLeft(uint32_t c, int wait) { 258 | 259 | 260 | 261 | strip_left.setPixelColor(0, c); 262 | strip_left.setPixelColor(1, c); 263 | strip_left.setPixelColor(2, c); 264 | strip_left.setPixelColor(3, c); 265 | strip_left.setPixelColor(4, c); 266 | strip_left.setPixelColor(5, c); 267 | strip_left.setPixelColor(6, c); 268 | strip_left.setPixelColor(7, c); 269 | strip_left.setPixelColor(8, c); 270 | strip_left.setPixelColor(9, c); 271 | strip_left.setPixelColor(10, c); 272 | strip_left.setPixelColor(11, c); 273 | strip_left.setPixelColor(12, c); 274 | strip_left.setPixelColor(13, c); 275 | strip_left.setPixelColor(14, c); 276 | strip_left.setPixelColor(15, c); 277 | strip_left.setPixelColor(16, c); 278 | strip_left.setPixelColor(17, c); 279 | strip_left.setPixelColor(18, c); 280 | strip_left.setPixelColor(19, c); 281 | strip_left.setPixelColor(20, c); 282 | strip_left.setPixelColor(21, c); 283 | strip_left.setPixelColor(22, c); 284 | strip_left.setPixelColor(23, c); 285 | strip_left.setPixelColor(24, c); 286 | strip_left.setPixelColor(25, c); 287 | strip_left.setPixelColor(26, c); 288 | strip_left.setPixelColor(27, c); 289 | strip_left.setPixelColor(28, c); 290 | 291 | strip_left.show(); 292 | delay(wait); 293 | strip_left.clear(); 294 | delay(wait); 295 | 296 | } 297 | 298 | 299 | void colorBlinkersHazard(uint32_t c, int wait) { 300 | 301 | strip_back.setPixelColor(0, c); 302 | strip_back.setPixelColor(1, c); 303 | strip_back.setPixelColor(2, c); 304 | strip_back.setPixelColor(3, c); 305 | strip_back.setPixelColor(4, c); 306 | strip_back.setPixelColor(5, c); 307 | strip_back.setPixelColor(6, c); 308 | strip_back.setPixelColor(7, c); 309 | 310 | strip_back.setPixelColor(24, c); 311 | strip_back.setPixelColor(25, c); 312 | strip_back.setPixelColor(26, c); 313 | strip_back.setPixelColor(27, c); 314 | strip_back.setPixelColor(28, c); 315 | strip_back.setPixelColor(29, c); 316 | strip_back.setPixelColor(30, c); 317 | strip_back.setPixelColor(31, c); 318 | 319 | 320 | strip_back.setPixelColor(32, c); 321 | strip_back.setPixelColor(33, c); 322 | strip_back.setPixelColor(34, c); 323 | strip_back.setPixelColor(35, c); 324 | strip_back.setPixelColor(36, c); 325 | strip_back.setPixelColor(37, c); 326 | strip_back.setPixelColor(38, c); 327 | strip_back.setPixelColor(39, c); 328 | strip_back.setPixelColor(40, c); 329 | strip_back.setPixelColor(41, c); 330 | strip_back.setPixelColor(42, c); 331 | strip_back.setPixelColor(43, c); 332 | strip_back.setPixelColor(44, c); 333 | 334 | strip_back.setPixelColor(8, c); 335 | strip_back.setPixelColor(9, c); 336 | strip_back.setPixelColor(10, c); 337 | strip_back.setPixelColor(11, c); 338 | strip_back.setPixelColor(12, c); 339 | strip_back.setPixelColor(13, c); 340 | strip_back.setPixelColor(14, c); 341 | strip_back.setPixelColor(15, c); 342 | 343 | strip_back.setPixelColor(16, c); 344 | strip_back.setPixelColor(17, c); 345 | strip_back.setPixelColor(18, c); 346 | strip_back.setPixelColor(19, c); 347 | strip_back.setPixelColor(20, c); 348 | strip_back.setPixelColor(21, c); 349 | strip_back.setPixelColor(22, c); 350 | strip_back.setPixelColor(23, c); 351 | 352 | 353 | strip_back.setPixelColor(32, c); 354 | strip_back.setPixelColor(33, c); 355 | strip_back.setPixelColor(34, c); 356 | strip_back.setPixelColor(35, c); 357 | strip_back.setPixelColor(36, c); 358 | strip_back.setPixelColor(37, c); 359 | strip_back.setPixelColor(38, c); 360 | strip_back.setPixelColor(39, c); 361 | strip_back.setPixelColor(40, c); 362 | strip_back.setPixelColor(41, c); 363 | strip_back.setPixelColor(42, c); 364 | strip_back.setPixelColor(43, c); 365 | strip_back.setPixelColor(44, c); 366 | 367 | 368 | 369 | strip_back.show(); 370 | delay(wait); 371 | strip_back.clear(); 372 | delay(wait); 373 | 374 | } 375 | 376 | 377 | void colorWipeRight(uint32_t color, int wait) { 378 | for (int i = 0; i < strip_right.numPixels(); i++) { // For each pixel in strip_back... 379 | strip_right.setPixelColor(i, color); // Set pixel's color (in RAM) 380 | strip_right.show(); // Update strip_back to match 381 | delay(wait); // Pause for a moment 382 | strip_right.clear(); 383 | } 384 | } 385 | 386 | 387 | //1st - 0 - 7 388 | //2nd - 8 - 15 389 | //3rd - 16 - 23 390 | //4th - 23 - 31 391 | //long - 32 -44 392 | 393 | // Fill the dots one after the other with a color 394 | void turnRight(uint32_t c, uint8_t wait) { 395 | 396 | strip_back.setPixelColor(0, c); 397 | strip_back.setPixelColor(1, c); 398 | strip_back.setPixelColor(2, c); 399 | strip_back.setPixelColor(3, c); 400 | strip_back.setPixelColor(4, c); 401 | strip_back.setPixelColor(5, c); 402 | strip_back.setPixelColor(6, c); 403 | strip_back.setPixelColor(7, c); 404 | 405 | strip_back.setPixelColor(24, c); 406 | strip_back.setPixelColor(25, c); 407 | strip_back.setPixelColor(26, c); 408 | strip_back.setPixelColor(27, c); 409 | strip_back.setPixelColor(28, c); 410 | strip_back.setPixelColor(29, c); 411 | strip_back.setPixelColor(30, c); 412 | strip_back.setPixelColor(31, c); 413 | 414 | 415 | strip_back.setPixelColor(32, c); 416 | strip_back.setPixelColor(33, c); 417 | strip_back.setPixelColor(34, c); 418 | strip_back.setPixelColor(35, c); 419 | strip_back.setPixelColor(36, c); 420 | strip_back.setPixelColor(37, c); 421 | strip_back.setPixelColor(38, c); 422 | strip_back.setPixelColor(39, c); 423 | strip_back.setPixelColor(40, c); 424 | strip_back.setPixelColor(41, c); 425 | strip_back.setPixelColor(42, c); 426 | strip_back.setPixelColor(43, c); 427 | strip_back.setPixelColor(44, c); 428 | 429 | strip_back.show(); 430 | delay(wait); 431 | strip_back.clear(); 432 | 433 | 434 | } 435 | 436 | 437 | // Fill the dots one after the other with a color 438 | void turnLeft(uint32_t c, uint8_t wait) { 439 | 440 | strip_back.setPixelColor(8, c); 441 | strip_back.setPixelColor(9, c); 442 | strip_back.setPixelColor(10, c); 443 | strip_back.setPixelColor(11, c); 444 | strip_back.setPixelColor(12, c); 445 | strip_back.setPixelColor(13, c); 446 | strip_back.setPixelColor(14, c); 447 | strip_back.setPixelColor(15, c); 448 | 449 | strip_back.setPixelColor(16, c); 450 | strip_back.setPixelColor(17, c); 451 | strip_back.setPixelColor(18, c); 452 | strip_back.setPixelColor(19, c); 453 | strip_back.setPixelColor(20, c); 454 | strip_back.setPixelColor(21, c); 455 | strip_back.setPixelColor(22, c); 456 | strip_back.setPixelColor(23, c); 457 | 458 | 459 | strip_back.setPixelColor(32, c); 460 | strip_back.setPixelColor(33, c); 461 | strip_back.setPixelColor(34, c); 462 | strip_back.setPixelColor(35, c); 463 | strip_back.setPixelColor(36, c); 464 | strip_back.setPixelColor(37, c); 465 | strip_back.setPixelColor(38, c); 466 | strip_back.setPixelColor(39, c); 467 | strip_back.setPixelColor(40, c); 468 | strip_back.setPixelColor(41, c); 469 | strip_back.setPixelColor(42, c); 470 | strip_back.setPixelColor(43, c); 471 | strip_back.setPixelColor(44, c); 472 | 473 | 474 | strip_back.show(); 475 | delay(wait); 476 | strip_back.clear(); 477 | 478 | 479 | } 480 | 481 | // Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames. 482 | void theaterChaseRainbow(int wait) { 483 | int firstPixelHue = 0; // First pixel starts at red (hue 0) 484 | for (int a = 0; a < 30; a++) { // Repeat 30 times... 485 | for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2... 486 | strip_back.clear(); // Set all pixels in RAM to 0 (off) 487 | // 'c' counts up from 'b' to end of strip_back in increments of 3... 488 | for (int c = b; c < strip_back.numPixels(); c += 3) { 489 | // hue of pixel 'c' is offset by an amount to make one full 490 | // revolution of the color wheel (range 65536) along the length 491 | // of the strip_back (strip_back.numPixels() steps): 492 | int hue = firstPixelHue + c * 65536L / strip_back.numPixels(); 493 | uint32_t color = strip_back.gamma32(strip_back.ColorHSV(hue)); // hue -> RGB 494 | strip_back.setPixelColor(c, color); // Set pixel 'c' to value 'color' 495 | } 496 | strip_back.show(); // Update strip_back with new contents 497 | delay(wait); // Pause for a moment 498 | firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames 499 | } 500 | } 501 | } 502 | 503 | 504 | // Rainbow cycle along whole strip_back. Pass delay time (in ms) between frames. 505 | void rainbow_back(int wait) { 506 | 507 | for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) { 508 | for (int i = 0; i < strip_back.numPixels(); i++) { // For each pixel in strip_back... 509 | 510 | int pixelHue = firstPixelHue + (i * 65536L / strip_back.numPixels()); 511 | 512 | strip_back.setPixelColor(i, strip_back.gamma32(strip_back.ColorHSV(pixelHue))); 513 | strip_left.setPixelColor(i, strip_right.gamma32(strip_right.ColorHSV(pixelHue))); 514 | strip_right.setPixelColor(i, strip_right.gamma32(strip_right.ColorHSV(pixelHue))); 515 | 516 | 517 | } 518 | strip_back.show(); // Update strip_back with new contents 519 | strip_left.show(); // Update strip_back with new contents 520 | strip_right.show(); // Update strip_back with new contents 521 | 522 | 523 | delay(wait); // Pause for a moment 524 | } 525 | } 526 | 527 | 528 | // Rainbow cycle along whole strip_back. Pass delay time (in ms) between frames. 529 | void rainbow_left(int wait) { 530 | 531 | for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) { 532 | for (int i = 0; i < strip_left.numPixels(); i++) { // For each pixel in strip_back... 533 | 534 | int pixelHue = firstPixelHue + (i * 65536L / strip_back.numPixels()); 535 | 536 | strip_left.setPixelColor(i, strip_left.gamma32(strip_left.ColorHSV(pixelHue))); 537 | } 538 | strip_left.show(); // Update strip_back with new contents 539 | delay(wait); // Pause for a moment 540 | } 541 | } 542 | 543 | 544 | // Rainbow cycle along whole strip_back. Pass delay time (in ms) between frames. 545 | void rainbow_right(int wait) { 546 | 547 | for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) { 548 | for (int i = 0; i < strip_right.numPixels(); i++) { // For each pixel in strip_back... 549 | 550 | int pixelHue = firstPixelHue + (i * 65536L / strip_right.numPixels()); 551 | 552 | strip_right.setPixelColor(i, strip_right.gamma32(strip_right.ColorHSV(pixelHue))); 553 | } 554 | strip_right.show(); // Update strip_back with new contents 555 | delay(wait); // Pause for a moment 556 | } 557 | } 558 | 559 | 560 | void colorShow(uint32_t color, int wait) { 561 | for (int i = 0; i < strip_back.numPixels(); i++) { // For each pixel in strip_back... 562 | strip_back.setPixelColor(i, color); // Set pixel's color (in RAM) 563 | } 564 | strip_back.show(); // Update strip_back to match 565 | //delay(wait); // Pause for a moment 566 | strip_back.clear(); 567 | 568 | } 569 | 570 | // Theater-marquee-style chasing lights. Pass in a color (32-bit value, 571 | // a la strip_back.Color(r,g,b) as mentioned above), and a delay time (in ms) 572 | // between frames. 573 | void theaterChase(uint32_t color, int wait) { 574 | for (int a = 0; a < 10; a++) { // Repeat 10 times... 575 | for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2... 576 | strip_back.clear(); // Set all pixels in RAM to 0 (off) 577 | // 'c' counts up from 'b' to end of strip_back in steps of 3... 578 | for (int c = b; c < strip_back.numPixels(); c += 3) { 579 | strip_back.setPixelColor(c, color); // Set pixel 'c' to value 'color' 580 | } 581 | strip_back.show(); // Update strip_back with new contents 582 | delay(wait); // Pause for a moment 583 | strip_back.clear(); 584 | 585 | } 586 | } 587 | } 588 | 589 | void clearLights() { 590 | strip_left.clear(); 591 | strip_right.clear(); 592 | strip_back.clear(); 593 | } 594 | --------------------------------------------------------------------------------