Project tutorial
Android Phone Control of NeoPixel Display

Android Phone Control of NeoPixel Display © GPL3+

Use an Android device to control the color of a NeoPixel via a Bluetooth connection.

  • 2,242 views
  • 1 comment
  • 7 respects

Components and supplies

Apps and online services

About this project

This project was the result of two of my middle school students combining two smaller projects: connecting an Android device to an Arduino and changing the color of a NeoPixel display.

One student worked on each portion. Here is the result.

Code

Bluetooth_NeoPixel_ControlScheme
MIT App Inventor 2 aia file to control an Arduino NeoPixel via Andriod phone with Bluetooth connection
No preview (download only).
Bluetooth_NeoPixel_ControlArduino
Allows control of Arduino NeoPixel via Android phone Bluetooth connection
/*
* Bluetooh Basic: NeoPixel color changer
* Coder - Mayoogh Girish; Modified by Lucas W
* Website - http://bit.do/Avishkar
* Download the App : https://github.com/Mayoogh/Arduino-Bluetooth-Basic
* This program lets you to control a NeoPixel display on pin 6 of Arduino using a bluetooth module
*/
  #include <Adafruit_NeoPixel.h>

#define PIN 6
#define NumOfLEDs 1

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NumOfLEDs, PIN, NEO_GRB + NEO_KHZ800);

char data = 0;            //Variable for storing received data

void setup()
{
    strip.begin();
    strip.show();         // Initialize all pixels to 'off'
    Serial.begin(9600);   //Sets the baud for serial data transmission                               
    pinMode(12, OUTPUT);  //Sets digital pin 13 as output pin
}
void loop()
{
   if(Serial.available() > 0)      // Send data only when you receive data:
   {
      data = Serial.read();        //Read the incoming data & store into data
      Serial.print(data);          //Print Value inside data in Serial monitor
      Serial.print("\n");        
      if(data == '0')  {           //  Checks whether value of data is equal to 0 or black
         strip.setPixelColor(0, strip.Color(0, 0, 0)); //off
         strip.show();     // This sends the updated pixel color to the hardware.
      }
      if(data == '1')  {       // Red
         strip.setPixelColor(0, strip.Color(255, 0, 0));//red
         strip.show();     
      }
      if(data == '2')  {       // Pink
         strip.setPixelColor(0, strip.Color(255, 0, 255)); //pink
         strip.show(); 
      }
      if(data == '3')  {       //  Orange
         strip.setPixelColor(0, strip.Color(255, 136, 0)); //orange
         strip.show(); 
      }
      if(data == '4')  {       //  Yellow
         strip.setPixelColor(0, strip.Color(255, 255, 0));  // yellow
         strip.show(); 
          }
      if(data == '5')  {       //  Green
         strip.setPixelColor(0, strip.Color(0, 255, 0));  //green
         strip.show(); 
          }
      if(data == '6')  {       //  Blue
         strip.setPixelColor(0, strip.Color(0, 0, 255)); // blue
         strip.show(); 
          }
      if(data == '7')  {       //  Teal
         strip.setPixelColor(0, strip.Color(0, 255, 255));  // teal
         strip.show(); 
      }
      if(data == '8')  {       //  Purple
         strip.setPixelColor(0, strip.Color(70, 5, 184)); // purple
         strip.show(); 
      }
      if(data == '9')  {       //  White
         strip.setPixelColor(0, strip.Color(255, 255, 255));  // white
         strip.show(); 
      }
      if(data == 'R')  {       //  Checks whether value of data is equal to 0
          rainbowCycle(4); 
      }
   }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

Schematics

Bluetooth NeoPixel Schematic
Fritzing schematic
bluetooth_neopixel_hnU3uh5dZP.fzz

Comments

Created by

Bryce K and Lucas W

Are you Bryce K and Lucas W? Claim this project and add it to your profile.

This is mine

Posted by

Nfarrier
nfarrier
  • 0 projects
  • 0 followers

Additional contributors

  • The original led on/off control code for adruino & app inventor by Mayoogh Girish

Published on

June 11, 2019

Members who respect this project

Fktrctr19

and 6 others

See similar projects
you might like

Similar projects you might like

Hacking A RC Car To Control It Using An Android Device

Project tutorial by MJRoBot

  • 23,585 views
  • 0 comments
  • 43 respects

Line Follower Robot - PID Control - Android Setup

Project tutorial by MJRoBot

  • 31,794 views
  • 9 comments
  • 41 respects

Control Robot Arm with your Android Phone

Project tutorial by Ammar Atef Ali

  • 10,605 views
  • 0 comments
  • 22 respects

Health Kit: Humidity and Temperature Control

Project tutorial by Diana Khalipina

  • 3,417 views
  • 2 comments
  • 32 respects

Bluetooth Smart phone control with remote arduino

Project tutorial by DFRobot

  • 5,355 views
  • 1 comment
  • 13 respects

Control Arduino Robot Arm with Android App

Project tutorial by Slant Concepts

  • 14,058 views
  • 8 comments
  • 31 respects
Add projectSign up / Login