Punch Through
Published © MIT

Smartphone controlled mood light

This tutorial teaches you how to make a mood light that you can change color and intensity of using your iPhone.

AdvancedFull instructions provided3,320
Smartphone controlled mood light

Things used in this project

Hardware components

LightBlue Bean
Punch Through LightBlue Bean
×1
NeoPixel Ring: WS2812 5050 RGB LED
Adafruit NeoPixel Ring: WS2812 5050 RGB LED
×1
Resistor 2.21k ohm
Resistor 2.21k ohm
×1
Resistor 10k ohm
Resistor 10k ohm
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
Globe Lightshade
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Drill
Hot glue gun (generic)
Hot glue gun (generic)
Wire Stripper
Knife

Story

Read more

Code

Code snippet #1

C/C++
#include <Adafruit_NeoPixel.h>
// The pin that is connected to the NeoPixels
#define PIN 5
// The amount of LEDs in the NeoPixels
#define NUMPIXELS 16
// LedReading is the type we get when we call Bean.getLedValues();
// For example, to get the amount of red in the Bean's LED,
// we use ledColor.red to get a value from 0 to 255
LedReading ledColor;
// previousLedColor will be used to check if the LED's color has changed
LedReading previousLedColor;
// Set up the NeoPixel library
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(
  NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  pixels.begin();  //  Initialize the NeoPixels
  Bean.enableWakeOnConnect(true);
}

void loop() {
  if(Bean.getConnectionState()) {
    ledColor = Bean.getLed();
    if(ledColor.red != previousLedColor.red ||
      ledColor.green != previousLedColor.green ||
      ledColor.blue != previousLedColor.blue) {
      for(int i = 0; i < NUMPIXELS; i++) {
        pixels.setPixelColor(
          i, pixels.Color(ledColor.red, ledColor.green, ledColor.blue));
        pixels.show();
      }
    previousLedColor = ledColor;
    }
  }
  else {
    Bean.sleep(0xFFFFFFF);
  }
}

Credits

Punch Through

Punch Through

16 projects • 41 followers
We’ve been building connected products since 2009. Our diverse team has expertise in every layer from hardware to software to web.

Comments