notiduino
Published © LGPL

Notification IoT Using NeoPixel and Smartphone

Show important notifications from your smartphone using a NeoPixel ring and Arduino.

BeginnerShowcase (no instructions)11,942
Notification IoT Using NeoPixel and Smartphone

Things used in this project

Hardware components

NeoPixel Ring: WS2812 5050 RGB LED
Adafruit NeoPixel Ring: WS2812 5050 RGB LED
×1
Arduino UNO
Arduino UNO
×1
HC-06 Bluetooth Module
×1

Software apps and online services

Notiduino Android App

Hand tools and fabrication machines

Android Smartphone

Story

Read more

Schematics

Notification IoT platform Circuit

This picture shows how to connect bluetooth, neopixel and Arduino to make it as Notification IoT platform.

Code

Notification IoT platform using Neo Pixel and Notiduino App

C/C++
This code shows how to receive the values from Notiduino App when it gets important notification messages.
#include <SoftwareSerial.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN            10
#define NUMPIXELS      24

#define rxPin 4
#define txPin 3

SoftwareSerial BT(txPin, rxPin);
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 50; // delay for half a second

void setup() {
  BT.begin(9600);
  Serial.begin(9600);
  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {
  
  if (BT.available() >0)
  {

    //Receive values from Notiduino Android App whenever it gets notification messages
    //Use semicolon and comma as seperator to retrieve header message and RGB color value
    String BT_receive_data = BT.readStringUntil((char)3);
    String Message_Head = getValue(BT_receive_data, ';', 0);
    String ColorValue = getValue(BT_receive_data, ';', 1);
    int R = getValue(ColorValue, ',', 0).toInt();
    int G = getValue(ColorValue, ',', 1).toInt();
    int B = getValue(ColorValue, ',', 2).toInt();

    Serial.println(Message_Head);
    Serial.println(ColorValue);

      for (int i = 0; i<NUMPIXELS; i++)
      {
        pixels.setPixelColor(i, pixels.Color(R, G, B)); // Moderately bright green color.
        pixels.show(); // This sends the updated pixel color to the hardware.
        delay(10);
        pixels.setPixelColor(i, pixels.Color(0, 0, 0));
      }
  }
  
}

#pragma region get Value
String getValue(String data, char separator, int index)
{
  int found = 0;
  int strIndex[] = { 0, -1 };
  int maxIndex = data.length() - 1;

  for (int i = 0; i <= maxIndex && found <= index; i++){
    if (data.charAt(i) == separator || i == maxIndex){
      found++;
      strIndex[0] = strIndex[1] + 1;
      strIndex[1] = (i == maxIndex) ? i + 1 : i;
    }
  }

  return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}
#pragma endregion

Credits

notiduino

notiduino

1 project • 2 followers

Comments