Components and supplies
1
Arduino UNO
1
Jumper wires (generic)
1
Android device
1
SparkFun RGB LED Breakout - WS2812B
1
HC-05 Bluetooth Module
Apps and platforms
1
MIT App Inventor 2
Project description
Code
Bluetooth_NeoPixel_Control
arduino
Allows control of Arduino NeoPixel via Android phone Bluetooth connection
1/* 2* Bluetooh Basic: NeoPixel color changer 3* Coder - Mayoogh Girish; Modified by Lucas W 4* Website - http://bit.do/Avishkar 5* Download the App : https://github.com/Mayoogh/Arduino-Bluetooth-Basic 6* This program lets you to control a NeoPixel display on pin 6 of Arduino using a bluetooth module 7*/ 8 #include <Adafruit_NeoPixel.h> 9 10#define PIN 6 11#define NumOfLEDs 1 12 13Adafruit_NeoPixel strip = Adafruit_NeoPixel(NumOfLEDs, PIN, NEO_GRB + NEO_KHZ800); 14 15char data = 0; //Variable for storing received data 16 17void setup() 18{ 19 strip.begin(); 20 strip.show(); // Initialize all pixels to 'off' 21 Serial.begin(9600); //Sets the baud for serial data transmission 22 pinMode(12, OUTPUT); //Sets digital pin 13 as output pin 23} 24void loop() 25{ 26 if(Serial.available() > 0) // Send data only when you receive data: 27 { 28 data = Serial.read(); //Read the incoming data & store into data 29 Serial.print(data); //Print Value inside data in Serial monitor 30 Serial.print("\ 31"); 32 if(data == '0') { // Checks whether value of data is equal to 0 or black 33 strip.setPixelColor(0, strip.Color(0, 0, 0)); //off 34 strip.show(); // This sends the updated pixel color to the hardware. 35 } 36 if(data == '1') { // Red 37 strip.setPixelColor(0, strip.Color(255, 0, 0));//red 38 strip.show(); 39 } 40 if(data == '2') { // Pink 41 strip.setPixelColor(0, strip.Color(255, 0, 255)); //pink 42 strip.show(); 43 } 44 if(data == '3') { // Orange 45 strip.setPixelColor(0, strip.Color(255, 136, 0)); //orange 46 strip.show(); 47 } 48 if(data == '4') { // Yellow 49 strip.setPixelColor(0, strip.Color(255, 255, 0)); // yellow 50 strip.show(); 51 } 52 if(data == '5') { // Green 53 strip.setPixelColor(0, strip.Color(0, 255, 0)); //green 54 strip.show(); 55 } 56 if(data == '6') { // Blue 57 strip.setPixelColor(0, strip.Color(0, 0, 255)); // blue 58 strip.show(); 59 } 60 if(data == '7') { // Teal 61 strip.setPixelColor(0, strip.Color(0, 255, 255)); // teal 62 strip.show(); 63 } 64 if(data == '8') { // Purple 65 strip.setPixelColor(0, strip.Color(70, 5, 184)); // purple 66 strip.show(); 67 } 68 if(data == '9') { // White 69 strip.setPixelColor(0, strip.Color(255, 255, 255)); // white 70 strip.show(); 71 } 72 if(data == 'R') { // Checks whether value of data is equal to 0 73 rainbowCycle(4); 74 } 75 } 76} 77 78// Input a value 0 to 255 to get a color value. 79// The colours are a transition r - g - b - back to r. 80uint32_t Wheel(byte WheelPos) { 81 if(WheelPos < 85) { 82 return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); 83 } else if(WheelPos < 170) { 84 WheelPos -= 85; 85 return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); 86 } else { 87 WheelPos -= 170; 88 return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); 89 } 90} 91 92void rainbow(uint8_t wait) { 93 uint16_t i, j; 94 95 for(j=0; j<256; j++) { 96 for(i=0; i<strip.numPixels(); i++) { 97 strip.setPixelColor(i, Wheel((i+j) & 255)); 98 } 99 strip.show(); 100 delay(wait); 101 } 102} 103 104// Slightly different, this makes the rainbow equally distributed throughout 105void rainbowCycle(uint8_t wait) { 106 uint16_t i, j; 107 108 for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel 109 for(i=0; i< strip.numPixels(); i++) { 110 strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); 111 } 112 strip.show(); 113 delay(wait); 114 } 115} 116
Bluetooth_NeoPixel_Control
arduino
Allows control of Arduino NeoPixel via Android phone Bluetooth connection
1/* 2* Bluetooh Basic: NeoPixel color changer 3* Coder - Mayoogh Girish; Modified by Lucas W 4* Website - http://bit.do/Avishkar 5* Download the App : https://github.com/Mayoogh/Arduino-Bluetooth-Basic 6* This program lets you to control a NeoPixel display on pin 6 of Arduino using a bluetooth module 7*/ 8 #include <Adafruit_NeoPixel.h> 9 10#define PIN 6 11#define NumOfLEDs 1 12 13Adafruit_NeoPixel strip = Adafruit_NeoPixel(NumOfLEDs, PIN, NEO_GRB + NEO_KHZ800); 14 15char data = 0; //Variable for storing received data 16 17void setup() 18{ 19 strip.begin(); 20 strip.show(); // Initialize all pixels to 'off' 21 Serial.begin(9600); //Sets the baud for serial data transmission 22 pinMode(12, OUTPUT); //Sets digital pin 13 as output pin 23} 24void loop() 25{ 26 if(Serial.available() > 0) // Send data only when you receive data: 27 { 28 data = Serial.read(); //Read the incoming data & store into data 29 Serial.print(data); //Print Value inside data in Serial monitor 30 Serial.print("\ 31"); 32 if(data == '0') { // Checks whether value of data is equal to 0 or black 33 strip.setPixelColor(0, strip.Color(0, 0, 0)); //off 34 strip.show(); // This sends the updated pixel color to the hardware. 35 } 36 if(data == '1') { // Red 37 strip.setPixelColor(0, strip.Color(255, 0, 0));//red 38 strip.show(); 39 } 40 if(data == '2') { // Pink 41 strip.setPixelColor(0, strip.Color(255, 0, 255)); //pink 42 strip.show(); 43 } 44 if(data == '3') { // Orange 45 strip.setPixelColor(0, strip.Color(255, 136, 0)); //orange 46 strip.show(); 47 } 48 if(data == '4') { // Yellow 49 strip.setPixelColor(0, strip.Color(255, 255, 0)); // yellow 50 strip.show(); 51 } 52 if(data == '5') { // Green 53 strip.setPixelColor(0, strip.Color(0, 255, 0)); //green 54 strip.show(); 55 } 56 if(data == '6') { // Blue 57 strip.setPixelColor(0, strip.Color(0, 0, 255)); // blue 58 strip.show(); 59 } 60 if(data == '7') { // Teal 61 strip.setPixelColor(0, strip.Color(0, 255, 255)); // teal 62 strip.show(); 63 } 64 if(data == '8') { // Purple 65 strip.setPixelColor(0, strip.Color(70, 5, 184)); // purple 66 strip.show(); 67 } 68 if(data == '9') { // White 69 strip.setPixelColor(0, strip.Color(255, 255, 255)); // white 70 strip.show(); 71 } 72 if(data == 'R') { // Checks whether value of data is equal to 0 73 rainbowCycle(4); 74 } 75 } 76} 77 78// Input a value 0 to 255 to get a color value. 79// The colours are a transition r - g - b - back to r. 80uint32_t Wheel(byte WheelPos) { 81 if(WheelPos < 85) { 82 return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); 83 } else if(WheelPos < 170) { 84 WheelPos -= 85; 85 return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); 86 } else { 87 WheelPos -= 170; 88 return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); 89 } 90} 91 92void rainbow(uint8_t wait) { 93 uint16_t i, j; 94 95 for(j=0; j<256; j++) { 96 for(i=0; i<strip.numPixels(); i++) { 97 strip.setPixelColor(i, Wheel((i+j) & 255)); 98 } 99 strip.show(); 100 delay(wait); 101 } 102} 103 104// Slightly different, this makes the rainbow equally distributed throughout 105void rainbowCycle(uint8_t wait) { 106 uint16_t i, j; 107 108 for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel 109 for(i=0; i< strip.numPixels(); i++) { 110 strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); 111 } 112 strip.show(); 113 delay(wait); 114 } 115} 116
Bluetooth_NeoPixel_Control
arduino
Allows control of Arduino NeoPixel via Android phone Bluetooth connection
1/* 2* Bluetooh Basic: NeoPixel color changer 3* Coder - Mayoogh Girish; 4 Modified by Lucas W 5* Website - http://bit.do/Avishkar 6* Download the App 7 : https://github.com/Mayoogh/Arduino-Bluetooth-Basic 8* This program lets you 9 to control a NeoPixel display on pin 6 of Arduino using a bluetooth module 10*/ 11 12 #include <Adafruit_NeoPixel.h> 13 14#define PIN 6 15#define NumOfLEDs 1 16 17Adafruit_NeoPixel 18 strip = Adafruit_NeoPixel(NumOfLEDs, PIN, NEO_GRB + NEO_KHZ800); 19 20char data 21 = 0; //Variable for storing received data 22 23void setup() 24{ 25 26 strip.begin(); 27 strip.show(); // Initialize all pixels to 'off' 28 29 Serial.begin(9600); //Sets the baud for serial data transmission 30 31 pinMode(12, OUTPUT); //Sets digital pin 13 as output pin 32} 33void loop() 34{ 35 36 if(Serial.available() > 0) // Send data only when you receive data: 37 38 { 39 data = Serial.read(); //Read the incoming data & store into 40 data 41 Serial.print(data); //Print Value inside data in Serial monitor 42 43 Serial.print("\ 44"); 45 if(data == '0') { // Checks 46 whether value of data is equal to 0 or black 47 strip.setPixelColor(0, 48 strip.Color(0, 0, 0)); //off 49 strip.show(); // This sends the updated 50 pixel color to the hardware. 51 } 52 if(data == '1') { // Red 53 54 strip.setPixelColor(0, strip.Color(255, 0, 0));//red 55 strip.show(); 56 57 } 58 if(data == '2') { // Pink 59 strip.setPixelColor(0, 60 strip.Color(255, 0, 255)); //pink 61 strip.show(); 62 } 63 if(data 64 == '3') { // Orange 65 strip.setPixelColor(0, strip.Color(255, 66 136, 0)); //orange 67 strip.show(); 68 } 69 if(data == '4') 70 { // Yellow 71 strip.setPixelColor(0, strip.Color(255, 255, 0)); 72 // yellow 73 strip.show(); 74 } 75 if(data == '5') { 76 // Green 77 strip.setPixelColor(0, strip.Color(0, 255, 0)); //green 78 79 strip.show(); 80 } 81 if(data == '6') { // Blue 82 83 strip.setPixelColor(0, strip.Color(0, 0, 255)); // blue 84 strip.show(); 85 86 } 87 if(data == '7') { // Teal 88 strip.setPixelColor(0, 89 strip.Color(0, 255, 255)); // teal 90 strip.show(); 91 } 92 if(data 93 == '8') { // Purple 94 strip.setPixelColor(0, strip.Color(70, 5, 95 184)); // purple 96 strip.show(); 97 } 98 if(data == '9') 99 { // White 100 strip.setPixelColor(0, strip.Color(255, 255, 255)); 101 // white 102 strip.show(); 103 } 104 if(data == 'R') { // 105 Checks whether value of data is equal to 0 106 rainbowCycle(4); 107 108 } 109 } 110} 111 112// Input a value 0 to 255 to get a color value. 113// 114 The colours are a transition r - g - b - back to r. 115uint32_t Wheel(byte WheelPos) 116 { 117 if(WheelPos < 85) { 118 return strip.Color(WheelPos * 3, 255 - WheelPos 119 * 3, 0); 120 } else if(WheelPos < 170) { 121 WheelPos -= 85; 122 return strip.Color(255 123 - WheelPos * 3, 0, WheelPos * 3); 124 } else { 125 WheelPos -= 170; 126 return 127 strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); 128 } 129} 130 131void rainbow(uint8_t 132 wait) { 133 uint16_t i, j; 134 135 for(j=0; j<256; j++) { 136 for(i=0; i<strip.numPixels(); 137 i++) { 138 strip.setPixelColor(i, Wheel((i+j) & 255)); 139 } 140 strip.show(); 141 142 delay(wait); 143 } 144} 145 146// Slightly different, this makes the rainbow 147 equally distributed throughout 148void rainbowCycle(uint8_t wait) { 149 uint16_t 150 i, j; 151 152 for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel 153 for(i=0; 154 i< strip.numPixels(); i++) { 155 strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) 156 + j) & 255)); 157 } 158 strip.show(); 159 delay(wait); 160 } 161} 162
Downloadable files
Bluetooth NeoPixel Schematic
Fritzing schematic
Bluetooth NeoPixel Schematic
Bluetooth NeoPixel Schematic
Fritzing schematic
Bluetooth NeoPixel Schematic
Comments
Only logged in users can leave comments