Devices & Components
Arduino Uno Rev3
NeoPixel Ring: WS2812 5050 RGB LED
HC-06 Bluetooth Module
Hardware & Tools
Android Smartphone
Software & Tools
Notiduino Android App
Project description
Code
Notification IoT platform using Neo Pixel and Notiduino App
c_cpp
This code shows how to receive the values from Notiduino App when it gets important notification messages.
1#include <SoftwareSerial.h> 2#include <Adafruit_NeoPixel.h> 3#ifdef __AVR__ 4#include <avr/power.h> 5#endif 6#define PIN 10 7#define NUMPIXELS 24 8 9#define rxPin 4 10#define txPin 3 11 12SoftwareSerial BT(txPin, rxPin); 13Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); 14 15int delayval = 50; // delay for half a second 16 17void setup() { 18 BT.begin(9600); 19 Serial.begin(9600); 20 pixels.begin(); // This initializes the NeoPixel library. 21} 22 23void loop() { 24 25 if (BT.available() >0) 26 { 27 28 //Receive values from Notiduino Android App whenever it gets notification messages 29 //Use semicolon and comma as seperator to retrieve header message and RGB color value 30 String BT_receive_data = BT.readStringUntil((char)3); 31 String Message_Head = getValue(BT_receive_data, ';', 0); 32 String ColorValue = getValue(BT_receive_data, ';', 1); 33 int R = getValue(ColorValue, ',', 0).toInt(); 34 int G = getValue(ColorValue, ',', 1).toInt(); 35 int B = getValue(ColorValue, ',', 2).toInt(); 36 37 Serial.println(Message_Head); 38 Serial.println(ColorValue); 39 40 for (int i = 0; i<NUMPIXELS; i++) 41 { 42 pixels.setPixelColor(i, pixels.Color(R, G, B)); // Moderately bright green color. 43 pixels.show(); // This sends the updated pixel color to the hardware. 44 delay(10); 45 pixels.setPixelColor(i, pixels.Color(0, 0, 0)); 46 } 47 } 48 49} 50 51#pragma region get Value 52String getValue(String data, char separator, int index) 53{ 54 int found = 0; 55 int strIndex[] = { 0, -1 }; 56 int maxIndex = data.length() - 1; 57 58 for (int i = 0; i <= maxIndex && found <= index; i++){ 59 if (data.charAt(i) == separator || i == maxIndex){ 60 found++; 61 strIndex[0] = strIndex[1] + 1; 62 strIndex[1] = (i == maxIndex) ? i + 1 : i; 63 } 64 } 65 66 return found > index ? data.substring(strIndex[0], strIndex[1]) : ""; 67} 68#pragma endregion
Downloadable files
Notification IoT platform Circuit
This picture shows how to connect bluetooth, neopixel and Arduino to make it as Notification IoT platform.
Notification IoT platform Circuit

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

Comments
Only logged in users can leave comments