Project showcase
Bluetooth Control Hat

Bluetooth Control Hat © CC BY-NC

The ultimate upgrade to your hat.

  • 13,696 views
  • 13 comments
  • 57 respects

Components and supplies

11114 01a
SparkFun Arduino Pro Mini 328 - 3.3V/8MHz
×1
09873 01a
SparkFun FTDI Basic Breakout - 3.3V
×1
61pby065esl  sx679  tnr8syww5d
HC-05 Bluetooth Module
×1
Addressable LED Strip ws2812b
I used 16 LEDs with 30 leds/m
×1
a HAT
×1
3.7 V LiPo Battery
×1

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

About this project

I wanted to upgrade my hat with LEDs but not just something static or a solution that will require me to program the hat each time I want to change the colors.

Code

Arduino CodeArduino
// Pro Mini 3.3V
// Blutooth pin 3 - RX, pin 4 - TX
// LED Strip 16 leds - pin 6 - DATA
// Lipo 3.7V

#include <Adafruit_NeoPixel.h>
#include <SoftwareSerial.h>

#define  SERIAL_PORT_SPEED  115200
#define  BT_PORT_SPEED  9600

#define PINLED 6
#define NumLED 16

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NumLED, PINLED, NEO_GRB + NEO_KHZ800);

int Mode = 0;
int ParameterR = 0;
int ParameterG = 0;
int ParameterB = 170;
int ParameterSpeed = 60;
int ParameterBrightness = 130;
String MsgBT = "";
String strTemp;
char c;
SoftwareSerial BT(3, 4);// RX | TX


void setup() {
  strip.begin();
  strip.setBrightness(ParameterBrightness);
  strip.show(); // Initialize all pixels to 'off'
  BT.begin(BT_PORT_SPEED);
  Serial.begin(SERIAL_PORT_SPEED);
  MsgBT.reserve(150);
}

void loop() {

  if (BT.available())
  {
    MsgBT = BT.readString();

    Serial.print("bytes read: ");
    Serial.println(MsgBT.length());
    Serial.println(MsgBT);

    if (MsgBT == "999") { // Turn Off
      TurnOff();
      Mode = 1;
    } else
    {
      strTemp = (MsgBT.substring(0, MsgBT.indexOf(",")));
      ParameterR = strTemp.toInt();
      MsgBT = MsgBT.substring(MsgBT.indexOf(",") + 1);

      strTemp = (MsgBT.substring(0, MsgBT.indexOf(",")));
      ParameterG = strTemp.toInt();
      MsgBT = MsgBT.substring(MsgBT.indexOf(",") + 1);

      strTemp = (MsgBT.substring(0, MsgBT.indexOf(",")));
      ParameterB = strTemp.toInt();
      MsgBT = MsgBT.substring(MsgBT.indexOf(",") + 1);

      strTemp = (MsgBT.substring(0, MsgBT.indexOf(",")));
      ParameterSpeed = strTemp.toInt();
      MsgBT = MsgBT.substring(MsgBT.indexOf(",") + 1);

      strTemp = (MsgBT.substring(0, MsgBT.indexOf("#")));
      ParameterBrightness = strTemp.toInt();

      Serial.print(ParameterR);
      Serial.print(",");
      Serial.print(ParameterG);
      Serial.print(",");
      Serial.print(ParameterB);
      Serial.print(",");
      Serial.print(ParameterSpeed);
      Serial.print(",");
      Serial.print(ParameterBrightness);
      Serial.println();

      Mode = 0;
      MsgBT = "";
    }
  }

  switch (Mode) {
    case 0:
      strip.setBrightness(ParameterBrightness);
      strip.show();
      if (ParameterSpeed == 400) {
        for (uint16_t i = 0; i < strip.numPixels(); i++)
          strip.setPixelColor(i, strip.Color(ParameterR, ParameterG, ParameterB));
        strip.show();
        Mode = 1;
      }
      else {
        colorWipe(strip.Color(ParameterR, ParameterG, ParameterB), ParameterSpeed);
        if (BT.available()) break;
        colorWipe(strip.Color(0, 0, 0), ParameterSpeed);

      }
      break;
    case 1:
      Serial.println("Mode 1");
      break;
  }
}


// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    if (BT.available()) return;
    delay(wait);
  }
}

void TurnOff() {
  for (uint16_t i = 0; i < strip.numPixels(); i++)
    strip.setPixelColor(i, strip.Color(0, 0, 0));
  strip.show();
}
Android AppJava
The Android App was built using MIT app inventor.
No preview (download only).

Schematics

Schematics
Hat bb n1le4gg6vn

Comments

Similar projects you might like

Car Control with Arduino Uno and Bluetooth

Project tutorial by Mehmet SARI

  • 8,665 views
  • 10 comments
  • 48 respects

Arduino Robot w/ GoPro and FPV iPhone Control via Bluetooth

Project in progress by AlxArd

  • 7,236 views
  • 7 comments
  • 41 respects

Bluetooth Control RC Car

Project tutorial by electronicprojects

  • 3,357 views
  • 2 comments
  • 15 respects

ClearWalker Bluetooth Control

Project showcase by Jeremy S. Cook

  • 3,116 views
  • 4 comments
  • 11 respects

Voice Control Bluetooth TV Remote

Project in progress by pravin.desai

  • 2,166 views
  • 0 comments
  • 5 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 13,026 views
  • 6 comments
  • 35 respects
Add projectSign up / Login